Testim supports all LTS versions of Node.js (14.15+ and 16.13+)
Install Testim package.
npm install -g @testim/testim-cli
The Basic CLI command example is displayed in the Settings >CLI tab and includes your Token and Project ID,
To view your basic CLI command:
- Go to Settings > CLI tab.
- Click CI to run the test remotely or Local to run the test locally (this will open a local browser on your machine)
- Under CI Platform, select the desired CI platform (optional)
- Under Grid, select the desired grid on which to run the test.
The basic CLI command is displayed below.
The basic command includes the following elements:
--token: the authentication token
--project: the project ID
--grid: the name of the grid to run the tests on
- Copy the CLI, edit and add parameters according to your needs. You can run a specific test, label, configuration, etc., as explained in the following section.
Here is an example of a basic command with the most common options (see below detailed description for all the available options):
--project: see above
--token: see above
--label: use this to run specific tests that include the specified labels
--grid: see above
--report-file: specifies where to store the test results (so the CI server can read them)
testim --label "<YOUR LABEL>" --token "<YOUR ACCESS TOKEN>" --project "<YOUR PROJECT ID>" --grid "<Your grid name>" --report-file test-results/testim-tests-report.xml
Note: Instead of running on a grid, it is possible to use --use-local-chrome-driver. That way you can see the run in action on a clean, extension-free, Chrome browser.
--project the project ID.
To select a different project, go to the Company screen (see https://help.testim.io/docs/project-and-user-management), select the relevant project, go to Settings > CLI tab and extract the project ID from the basic CLI command example.
--token The access token. The access token can be obtained from the basic CLI command example, which is displayed in the Settings > CLI tab screen.
-l Run all tests that include one of the mentioned labels.
Note that you can also run more than one label, by adding more
-l sanity -l custom-label2
-n, the test name to run.
Note that you can also run more than one test by name, by adding more
-t, the test ID to run.
Note that you can also run more than one test by id, by adding more
--grid, the Selenium Grid name to use. You can use "Testim-Grid"/ your local selenium grid/ Saucelabs / Browserstack
Note: Read here how to configure your grid.
-r, where to print the report (by default to the output stream). The file is in the format of JUnitXMLReporter. This is used to integrate Testim results with the CI display. Usually, you'll need to set the build config in the CI to look for that file so make sure the CLI param value and the build config are set to the same location.
To override the classname in the report file, add this parameter :
--base-url, starting URL after browser opens
test-config specifies configuration parameters (e.g. browser, operating system, resolution, visual validation parameters, etc.) that will override the configuration defined for all tests in this run.
Read more here.
--test-config "1280x1024_SXGA_chrome" --test-config "1366x768_WXGA_firefox"
--mode, the mode of the run. When you run IE11, Edge (Legacy), Firefox or Safari, you'll need to add this parameter before you can run.
--suite, the test suite name to run. You can run more than one suite.
--suite "suite_name" --suite "suite_name2"
suite-id, specifies the test suite ID to run. You can run more than one suite.
--suite-id "suite1ID" --suite-id "suite2ID"
--test-plan, specifies the test plan name to run. You can run more than one plan. Since you define in the test plan the grid, test list, configuration, etc., you cannot override it from the CLI. Therefore when using
--test-plan you cannot use these flags:
--test-plan "Test Plan Demo"
--override-execution-name, the name of the execution in Testim suite runs.
--override-execution-name "Dev Sanity"
--override-report-file-classname The class name in the JUnitXML report file is Testim.io by default. To have the suite name in the class name instead, add the parameter below with no value. If you are looking to override the class name with a specific name, add it to the parameter.
--override-report-file-classname --override-report-file-classname "Regression"
--result-label, the result Labels option allows you to add textual labels to your remote runs. These labels will be shown in the runs page.
--timeout, timeout period in milliseconds to abort the test run if a timeout has elapsed. The default is set to 10 minutes.
--branch, to run on a specific branch (by name).
--parallel, how many tests should run in parallel.
-c, specifies all the configuration options from external configuration File.
Place the config file in a path accessible by the shell, specify in the command the path to the file.
Read more about configuration file here.
--retries, When this flag is used, a failed test will be executed repeatedly until either the test passes or the max number of retries has been reached - in which case the test will fail.
When a test passes after one or more retries, it will be indicated in the UI as follows:
Tests that only passed using retries, can be easily filtered under the testim library. To read more about that, see here.
--suppress-tms-reporting To suppress sending suite run results to TestRail.
--tunnel-port, Tunnels let you run your app from an internal server/localhost and view it in an external browser.
--tunnel #default application port 80
testim --tunnel --tunnel-port <APP PORT default 80>
For more info check out: This Article
--rerun-failed-by-run-id, The rerun failed tests option allows you to rerun all test which failed in a suite run.
Copy the suite run id from the suite's page :
Add the --rerun-failed-by-run-id flag with the suite's run id to the CLI :
--set-retention When you add the parameter --set-retention [whole number between 1 to 10] to a CLI run, all the test results of this execution will be marked for deletion (retention period) after the number of days specified in the parameter
Note: Our plan includes 30 days retention by default, for longer retention time, please reach out to support.
It is possible to abort a CLI run, by using the CTRL+c shortcut in your terminal. The run will have "Aborted" status under the run-list
The CLI can also be forced to quit by pressing CTRL+C multiple times or closing the terminal window.
This will cause the run to stop executing but the status will remain "Running" in the editor. The run status will change to “Timeout” after 120 minutes.
To add Chrome extra arguments, use the --chrome-extra-args which receives a comma-separated string with the needed flags (no spaces between the flags). For example:
testim --token "TOKEN" --project "PROJECT" --grid "Testim-Grid" --chrome-extra-args "enable-heavy-ad-intervention,heavy-ad-privacy-mitigations"
intersect-with flag can be used to run a subset of the specified tests (e.g. a test plan, a test suite, a label) that are intersected with a given label or suite. When running test plans the intersection is performed on the tests in the plan’s body (not the before or after tests).
intersect-with flags are available:
--intersect-with-label <labelName> --intersect-with-suite <suiteName> --intersect-with-suite-id <suiteId>
The following command example specifies a suite called "SuiteName" to run if they intersect with a label called "test":
testim --token “7jdSDFGbsdfrGsdrgsdrg” --project “EIPPYFgkS7oTesyRCnlj” --suite “SuiteName” --grid “Testim-Grid” --intersect-with-label “test”
The following command example specifies that tests with label "test" run if they intersect with suite "test1":
testim --token “7jyBS1mzOb5f6wOGE3o8ybE2tSRuWAY5rZteT1jwd4FAAJ2mPn” --project “EIPPYFgkS7oCnlOfNtOj” --label “test” --grid “Testim-Grid” --intersect-with-suite “test1”
intersect-with flag defines that from all the tests that were included in the original run command, Testim should only run the tests that are common (i.e., intersecting) with the specified label or suite.
Label A - contains tests: 1,2,3,4
Label B - contains tests: 5,6,7
Label C - contains tests: 3,4,5
Label D - contains tests: 8,9
Test Plan P contains Labels A and B
So if we run test plan P with --intersect-with-label C ==> tests 3,4,5 should run
If we run test plan P with --intersect-with-label D ==> no tests should run
It is possible to add multiple intersect flags.
For example, to run test plan P with --intersect-with-label C --intersect-with-label A
Testim will establish which tests are in the original run command and then calculate the intersect flags one after the other.
The intersection is performed between the tests in the flag and the requested, not between the flags themselves. So if you have --intersect-with-label A, and --intersect-with-label B, Testim will run all the tests in A OR B, that intersect with the tests requested.
Updated 3 days ago