The inso run test
command enables you to execute unit tests written inside Insomnia from your terminal or in a CI/CD environment. On execution, Inso CLI will report test results, and exit with an exit code. Inso CLI will exit with a non-zero exit code if linting fails.
inso run test [identifier]
This prompts user for unit test suite and environment selection. After selection it will execute the selected unit test suite against the selected environment. You may choose to specify the suite and environment directly as well, see examples below.
identifier
can be the name or id of a Document, or unit test suite.
The test runner is built on top of Mocha, thus many of the options behave as they would in Mocha. The options currently supported are:
Option | Alias | Description |
---|---|---|
--env <identifier> |
-e | the environment to use - an environment name or id |
--reporter <value> |
-r | reporter to use, options are dot, list, spec, min and progress (default: spec ) |
--testNamePattern <regex> |
-t | run tests that match the regex |
--bail |
-b | abort (“bail”) after the first test failure |
--keepFile |
do not delete the generated test file (useful for debugging) | |
--disableCertValidation |
disable certificate validation for requests with SSL |
Option | Alias | Description |
---|---|---|
--workingDir <path> |
-w | Specify a working directory/file, to find .insomnia folder, *.db.json, export.yaml |
The following commands work when running in the example git-repo directory.
When you don’t specify any arguments, you’ll be prompted with:
inso run test
Scope tests to the Document name or ID:
inso run test "Sample Specification" --env "OpenAPI env"
inso run test spc_46c5a4 --env env_env_ca046a
Scope tests to a test suite name or ID:
inso run test "Math Suite" --env "OpenAPI env"
inso run test uts-7f0f85 --env env_env_ca046a
Scope tests by test name regex, and control test running and reporting:
inso run test "Sample Specification" --testNamePattern Math --env env_env_ca046a
inso run test spc_46c5a4 --reporter progress --bail --keepFile