You, or a user in your organization with “Intelligent Test Runner Activation” permissions, must activate the Intelligent Test Runner on the Test Service Settings page.
Application key and permissions
The Intelligent Test Runner requires an application key mapped to an owner role with the CI Visibility Read (ci_visibility_read) permission.
After setting these environment variables, run your tests as you normally do:
NODE_OPTIONS="-r dd-trace/ci/init"DD_ENV=ci DD_SERVICE=my-javascript-app DD_CIVISIBILITY_AGENTLESS_ENABLED=trueDD_API_KEY=$DD_API_KEYDD_APPLICATION_KEY=$DD_APPLICATION_KEY yarn test
Cypress setup
For Intelligent Test Runner for Cypress to work, you must instrument your web application with code coverage. You can read more about enabling code coverage in the Cypress documentation. To check that you’ve successfully enabled code coverage, navigate to your web app with Cypress and check the global variable window.__coverage__. This is what dd-trace uses to collect code coverage for Intelligent Test Runner.
Suite skipping
Intelligent Test Runner for Javascript skips entire test suites (test files) rather than individual tests.
Inconsistent test durations
In some frameworks, such as jest, there are cache mechanisms that make tests faster after other tests have run (see jest cache docs). If Intelligent Test Runner is skipping all but a few test files, these suites might run slower than they usually do. This is because they run with a colder cache. Regardless of this, total execution time for your test command should still be reduced.
Further Reading
Additional helpful documentation, links, and articles: