-
-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Description
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
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.