Jest No Tests Found
Solution 1:
Your output says that testMatch had 1 match, which may be your __tests__/index.test.js file. It seems that your testPathIgnorePatterns is causing that test suite to be ignored. No tests found In /usr/src/app says that Jest is looking for tests in /usr/src/app, and testPathIgnorePatterns: /node_modules/,/src,src says that Jest is ignoring files in /src directories.
Either point Jest to look at the location of your __tests__/index.test.js file if it is outside the /src directory, or stop testPathIgnorePatterns from ignoring the /src directory.
Solution 2:
If you have file structure such as the following
myFolder
│ myFile1.js
│ myFile2.js
│ ...
│
└───__tests__ myFile1.spec.js
myFile2.spec.js
...
then you need to have in jest.config.js the following pattern for testMatch property:
testMatch: ['**/__tests__/*.js?(x)'],The simple example of jest.config.js:
constjestConfig= {
verbose: true,
testURL: "http://localhost/",
'transform': {
'^.+\\.jsx?$': 'babel-jest',
},
testMatch: ['**/__tests__/*.js?(x)'],
}
module.exports = jestConfig
Solution 3:
In package.json there is a pattern that is used to find test file. In this pattern, you can change it according to your file location or make it the global pattern.
I wrote a test, not in the specific folder and follow a naming convention *.test.js and change testMatch
"testMatch":["<rootDir>/src/**/*.(test).{js,jsx,ts,tsx}","<rootDir>/src/**/?(*.)(spec|test).{js,jsx,ts,tsx}"],Solution 4:
You can try running jest without any parameters. A key thing to note is the test file names have to follow the convention *.test.js or *.spec.js.
Solution 5:
If you want to run all the tests inside the tests folder you can simply do the following
jest __tests__ --watch
Post a Comment for "Jest No Tests Found"