We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yes
No
typescript, jest, setupTests
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
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
App.js
App.test.js
index.js
serviceWorker.js
App.tsx
App.test.tsx
index.tsx
serviceWorker.ts
setupTests.ts
import { configure } from 'enzyme'; import Adapter from 'enzyme-adapter-react-16'; configure({ adapter: new Adapter() }); export default undefined;
import { shallow } from 'enzyme'; it('matches snapshot', () => { expect(shallow(<App />)).toMatchSnapshot(); });
package.json
"jest": { "snapshotSerializers": [ "enzyme-to-json/serializer" ] }
yarn test
For Jest to create write __snapshots__/App.test.tsx.snap with a snapshot of <App />
__snapshots__/App.test.tsx.snap
<App />
● Validation Error: Module /src/setupTests.js in the setupTestFrameworkScriptFile option was not found. is: (...dir...) Configuration Documentation: https://jestjs.io/docs/configuration.html error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
● Validation Error:
Module /src/setupTests.js in the setupTestFrameworkScriptFile option was not found. is: (...dir...)
Configuration Documentation: https://jestjs.io/docs/configuration.html
error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Renaming setupTests.ts -> setupTests.js does work
setupTests.js
The text was updated successfully, but these errors were encountered:
This works for us, but we've import a shared config (which is JS). And we don't export anything from that file.
So, our setupTests.ts looks like:
import 'path-to-our-config/jest'; // a JavaScript file
Sorry, something went wrong.
We're facing the same issue, and it seems to happen on Windows only... works on my machine 😂
brunolemos
ianschmitz
No branches or pull requests
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
App.js
,App.test.js
,index.js
,serviceWorker.js
->App.tsx
,App.test.tsx
,index.tsx
,serviceWorker.ts
setupTests.ts
with:App.test.tsx
package.json
yarn test
Expected Behavior
For Jest to create write
__snapshots__/App.test.tsx.snap
with a snapshot of<App />
Actual Behavior
Notes
Renaming
setupTests.ts
->setupTests.js
does workThe text was updated successfully, but these errors were encountered: