Run all the unit test cases from npm run test

44 Views Asked by At

In my React front end project, jest library is used for unit test cases. I am trying to run the front-end unit test cases from build pipeline. To do that, I am planning to add a new task in the task group. The task

npm run test

executes the unit test cases which are related to the recent changes. When I run the same command from the VS Code terminal, it is asking to press "a" to run all the test cases. Even if I run the below command with "--watchAll"

npm run test --watchAll

*No tests found related to files changed since last commit. Press a to run all tests, or run Jest with --watchAll. *

But I am planning to run all the test cases every time the pipeline is being executed. What would be the command to achieve that?

I tried goggling for the solution but not found anything concrete.

1

There are 1 best solutions below

0
quyentho On

The default of jest command is run all tests, but looks like your test files are not following the convention:

Jest will look for test files with any of the following popular naming conventions:

  • Files with .js suffix in __tests__ folders.
  • Files with .test.js suffix.
  • Files with .spec.js suffix.

Checkout CRA documentation for more detail