3

I was trying to generate test coverage for my react tests using react-testing-library in windows Powershell. But on running yarn test .\src\components\ --coverage PowerShell shows this statement Invalid testPattern .\src\components\ supplied. Running all tests instead..

Running without a path like this yarn test --coverage is also not working, it is giving this output

Press `a` to run all tests, or run Jest with `--watchAll`.
----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |        0 |        0 |        0 |        0 |                   |
----------|----------|----------|----------|----------|-------------------|

Watch Usage
 › Press a to run all tests.
 › Press f to run only failed tests.
 › Press q to quit watch mode.
 › Press p to filter by a filename regex pattern.
 › Press t to filter by a test name regex pattern.
 › Press Enter to trigger a test run.

How do I run react test in windows PowerShell?

suvodipMondal
  • 656
  • 10
  • 27

2 Answers2

2

Try using --watchAll=false flag, something like: yarn test --coverage --watchAll=false

1

This command works for me:

npm t -- --coverage --watchAll=false

Fateme
  • 11
  • 1