Closed
Description
Is this a bug report?
Yes
Did you try recovering your dependencies?
No
Which terms did you search for in User Guide?
typescript, jest, setupTests
Environment
Environment:
OS: Windows 10
Node: 9.11.2
Yarn: 1.12.1
npm: 6.4.1
Watchman: Not Found
Xcode: N/A
Android Studio: Not Found
Packages: (wanted => installed)
react: ^16.6.0 => 16.6.0
react-dom: ^16.6.0 => 16.6.0
react-scripts: 2.1.1 => 2.1.1
Steps to Reproduce
npx create-react-app cra
cd cra
yarn add typescript @types/node @types/react @types/react-dom @types/jest enzyme enzyme-adapter-react-16 enzyme-to-json
- Rename
App.js
,App.test.js
,index.js
,serviceWorker.js
->App.tsx
,App.test.tsx
,index.tsx
,serviceWorker.ts
- create
setupTests.ts
with:
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });
export default undefined;
- Add the following lines to
App.test.tsx
import { shallow } from 'enzyme';
it('matches snapshot', () => {
expect(shallow(<App />)).toMatchSnapshot();
});
- Add the following to
package.json
"jest": {
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
}
yarn test
Expected Behavior
For Jest to create write __snapshots__/App.test.tsx.snap
with a snapshot of <App />
Actual Behavior
● Validation Error:
Module /src/setupTests.js in the setupTestFrameworkScriptFile option was not found.
is: (...dir...)Configuration Documentation:
https://jestjs.io/docs/configuration.htmlerror Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Notes
Renaming setupTests.ts
-> setupTests.js
does work