Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #5666
Closed
Open
Issue created Nov 01, 2018 by Administrator@rootContributor

[Typescript] setupTests.ts not being respected

Created by: christianchown

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

  1. npx create-react-app cra
  2. cd cra
  3. yarn add typescript @types/node @types/react @types/react-dom @types/jest enzyme enzyme-adapter-react-16 enzyme-to-json
  4. Rename App.js, App.test.js, index.js, serviceWorker.js -> App.tsx, App.test.tsx, index.tsx, serviceWorker.ts
  5. create setupTests.ts with:
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

export default undefined;
  1. Add the following lines to App.test.tsx
import { shallow } from 'enzyme';

it('matches snapshot', () => {
  expect(shallow(<App />)).toMatchSnapshot();
});
  1. Add the following to package.json
  "jest": {
    "snapshotSerializers": [
      "enzyme-to-json/serializer"
    ]
  }
  1. 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.html

error 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

Assignee
Assign to
Time tracking