This project tests our CLI's hs <*>
commands as if they were being used by an end-user.
The main test execution is kicked off by running yarn test-cli
from the root of hubspot-cli
. This will run the run-tests
script which itself is a CLI, so to see the available options, you can run-tests --help
. This was done so that the tests can be installed against any given version of the CLI and tested against it. In addition, it was done to keep the test logic separated from the CLI library.
Note that if you are testing against a QA portal, not a PROD one, you'll need to add the --qa
flag when running the script. There is still an outstanding issue with this because we attempt to add the --qa
flag to all hs
commands, however it is not available for all commands.
To setup these tests, there are two required arguments and one optional one:
- The ID of a HubSpot account that you are a user in
- Your generated personal access key in that account (available in personal access key ui)
- [Optional] A path to an instance of the CLI. The test runner will execute the commands against this provided instance
- The default behavior is to use
../packages/cli/bin/hs
- The default behavior is to use
There are three ways to pass in necessary configuration to the script.
- Creating a
.env
file inacceptance-tests
folder.
ACCOUNT_ID="123456789"
PERSONAL_ACCESS_KEY="AiRiNGU2Y***************m1wLi2s8k2UlMYHEX"
CLI_PATH="hs"
- Through environment variables.
export ACCOUNT_ID="123456789"
export PERSONAL_ACCESS_KEY="AiRiNGU2Y***************m1wLi2s8k2UlMYHEX"
export CLI_PATH="hs"
- Through arguments on the
run-tests
script
yarn run-tests --accountId=123456789 --personalAccessKey="*********" --cliPath=hs
Alternatively, we support the following aliases:
yarn run-tests --a=123456789 --pak="*********" --c=hs
- Run
lerna bootstrap
to install dependencies - Run
yarn test-cli
from the root of the CLI repo
NOTE: Include the --debug
flag for more verbose output
You may be wondering why we are using Jasmine, and not Jest. The reason is because Jest does not provide an API for executing the tests within code. We need to do this since we are wrapping the tests within a CLI.
A couple of accounts have been set up specifically for testing. They are QA Account 105786502 and Prod Account 9289088. If you add any test data to the accounts for testing, ensure you add it to the above two.
The .env
file does not get recognized when running act locally to run the tests within the github action. To bypass this, you can comment out the .env
line in the .gitignore
file and run act again
. See nektos/act#193 for more info.
-
Currently the personal-access-key test is flakey. Run the tests again and it should pass.
-
The tests seem to trip up on usages of the
ora
library. To get around this, we have a list of blacklisted strings. If your test is being picky about ora, add the error message to the blacklist incmd.js