You can limit which tests are run through the following environmental variables: TEST_NAME
, TEST_FILE
and TEST_DIR
.
You can run only tests that match a given name (usually only one test) like:
TEST_NAME="calculate sum" npm test
You can also use a wildcard in the name like:
TEST_NAME="calculate population of *" npm test
You can run only run tests in files with a specific name like:
TEST_FILE="test.max.js" npm test
You can run only run tests in folders with a specific name like:
TEST_DIR="v1" npm test
You can log the time it takes to run each test like
TEST_TIMED=true npm test
Output will look like this:
success (324ms): name of test success (461ms): name of another test
You can suppress logging the information about which tests were skipped.
This can be helpful when you are skipping hundreds of tests.
LOG_SKIP=false npm test
You can pause in between tests. This helps if there are side effects
that need time to complete. Gap time is in seconds.
TEST_GAP_TIME=3.5 npm test