Describe the bug
Jest test run finds no test
To reproduce
-
create app
npx create-react-app my-app --template typescript
-
run tests
cd my-app && npm run test
Run results in terminal
No tests found related to files changed since last commit.
Press a to run all tests, or run Jest with --watchAll.
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.
Fix
To fix this issue, create __tests__ directory under src and move App.test.tsx into that directory.
Did you try recovering your dependencies?
No this was a default ts install.
Which terms did you search for in User Guide?
Your original sample should work.
Environment
Tried mac os and devcontainer (linux).
Steps to reproduce
-
create app
npx create-react-app my-app --template typescript
-
run tests
cd my-app && npm run test
Expected behavior
App.test.tsx file is found and its test is run.
Actual behavior
No tests found related to files changed since last commit.
Press `a` to run all tests, or run Jest with `--watchAll`.
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.
Reproducible demo
Repo with example
Fix
To fix this issue, create __tests__ directory under src and move App.test.tsx into that directory. Fix test file import statement to the correct location of App in parent dir.
Describe the bug
Jest test run finds no test
To reproduce
create app
run tests
Run results in terminal
No tests found related to files changed since last commit.
Press
ato run all tests, or run Jest with--watchAll.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.
Fix
To fix this issue, create
__tests__directory undersrcand moveApp.test.tsxinto that directory.Did you try recovering your dependencies?
No this was a default ts install.
Which terms did you search for in User Guide?
Your original sample should work.
Environment
Tried mac os and devcontainer (linux).
Steps to reproduce
create app
run tests
Expected behavior
App.test.tsx file is found and its test is run.
Actual behavior
Reproducible demo
Repo with example
Fix
To fix this issue, create
__tests__directory undersrcand moveApp.test.tsxinto that directory. Fix test file import statement to the correct location of App in parent dir.