Test Not Running (File Not Discovered)
Error message
No tests found — 0 tests run
Quick summary
Jest can't find your test files. The files might not match Jest's naming convention or the testMatch config is wrong.
Why this happens
Test files don't match the default pattern (*.test.js, *.spec.js, __tests__/).
Jest's testMatch or testRegex configuration is wrong.
Test files are in a directory excluded by Jest (e.g., node_modules).
The file extension isn't in Jest's moduleFileExtensions.
Minimal example
// File named: utils.tests.js (wrong — should be .test.js)
// Jest doesn't find it with default config// Rename to: utils.test.js
// Jest discovers it with default testMatch patternUse the correct naming convention (.test.js or .spec.js) so Jest discovers the file.
How to diagnose
Check the test file naming — it should be *.test.js, *.spec.js, or in a __tests__ folder.
Check jest.config.js for testMatch or testRegex settings.
Verify the test file is in a directory Jest searches (not excluded).
Run jest --listTests to see which files Jest discovers.
How to fix
Rename test files to match Jest's convention: utils.test.js or utils.spec.js.
Update testMatch in jest.config.js: testMatch: ['**/*.test.js'].
Move test files to a directory Jest searches.
Add the file extension to moduleFileExtensions if using TypeScript or JSX.
How to prevent
Follow consistent test file naming conventions across the project.
Document the expected test file pattern for the team.
Related Resources
Related Glossary
Related Lessons
- Jest Basics
Getting started with Jest.