Suppose you add async to componentDidmount and start a snapshot test
- public componentDidMount() {
+ public async componentDidMount() {
const { setup } = this.props;
setup();
}
run test
you will show below, sometime
● Test suite failed to run
Configuration error:
Could not locate module @/containers
import OpenDialogButton from mapped as:
/Users/morita.kenji/Desktop/projectName/src/containers.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"/@\/(.*)/": "/Users/morita.kenji/Desktop/projectName/src/$1"
},
"resolver": null
}
at createNoMappedModuleFoundError (node_modules/jest-runtime/node_modules/jest-resolve/build/index.js:501:17)
at Array.reduce (<anonymous>)
at SearchSource.findRelatedTests (node_modules/@jest/core/build/SearchSource.js:280:30)
at SearchSource.findTestRelatedToChangedFiles (node_modules/@jest/core/build/SearchSource.js:363:14)
To fix
add option your command --watchAll
in my case,
npm test -- --u --watchAll
npm test -- --u --watchAll
is just ailias, In fact tsc --noEmit && react-app-rewired test --watchAll
)
not npm test -- --u --watch
If you try it with --watch, you'll get an error again