Sometimes, we want to fix the Jest ‘No Tests found’ error.
In this article, we’ll look at to fix the Jest ‘No Tests found’ error.
How to fix the Jest ‘No Tests found’ error?
To fix the Jest ‘No Tests found’ error, we should make sure the testMatch setting in jest.config.js is set to an array of paths with the test files.
For instance, we write
const jestConfig = {
verbose: true,
testURL: "http://localhost/",
'transform': {
'^.+\.jsx?$': 'babel-jest',
},
testMatch: ['**/__tests__/*.js?(x)'],
}
module.exports = jestConfig
to set testMatch to an array with '**/__tests__/*.js?(x)' to make sure that Jest runs the test files in the __tests__ folder with extension .js or .jsx.
Conclusion
To fix the Jest ‘No Tests found’ error, we should make sure the testMatch setting in jest.config.js is set to an array of paths with the test files.