In a React project built with create-react-app
where the test files resides in the same folder next to the code they need to test, like follows:
|- /src/path
| |- List.tsx
| |- List.test.tsx
when trying to run npx jest
, or using the global jest
, I get the following result:
No tests found
In C:\src\path
34 files checked.
testMatch: **\*test.tsx,**/*test.tsx,src\**\*.test.tsx,src/**/*.test.tsx,C:\src\path\src\**\*.test.tsx,C:\src\path\src\**\*.test.tsx - 0 matches
testPathIgnorePatterns: \\node_modules\\ - 34 matches
Pattern: - 0 matches
Running npm test
- which in turns run the script react-scripts test
from package.json
- works fine and is able to find and run all the tests in the project (in watch mode).
Any idea how to solve this problem?
Environment
- node:
10.15.0
- npm:
6.4.1
- react-scripts:
2.1.3
- Operating system:
Windows 10 1809 17763.316
jest.config.js
module.exports = {
testMatch: [
'**\\*test.tsx',
'**/*test.tsx',
'src\\**\\*.test.tsx',
'src/**/*.test.tsx',
'<rootDir>\\src\\**\\*.test.tsx',
'<rootDir>/src/**/*.test.tsx',
'src/.*|(.|/)(.test).tsx?$'
],
};