Skip to main content

How to Run Specific Tests

Problem

Sometimes you may need to run specific tests rather than the entire set of tests in your project.

For example, you developed a feature and covered it with functional tests. You might want to first check the correctness of the new tests.

Or you are fixing a flaky test, found bugs, fixed them, and want to verify that the test now passes correctly.

Solution 1: Running a Specific File

If you want to run a whole group of tests located in a specific file, specify the path to this file as an input parameter for testplane:

testplane src/features/Reviews/Reviews.test/MyReview/MyReview.a11y@touch-phone.testplane.js

Solution 2: --grep Option

If you want to run a specific test, use the --grep option by providing the full name of the test as its value:

testplane --grep "Accessibility Leaving a review"

Solution 3: .only Directive

You can also use the .only directive for a suite of tests (describe) or a specific test (it), similar to what is implemented in mocha (see the exclusive tests section):

For example:

describe.only("Accessibility", function () {
// Test suite...
});

or

it.only("Leaving a review", async function () {
// Test code...
});

Keywords

  • grep
  • describe.only
  • it.only