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
  • Merge requests
  • !9760

Add `.d.ts` to Jest's moduleFileExtensions

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/ViieeS/patch-1 into main Oct 07, 2020
  • Overview 10
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: ViieeS

Without it test fails when you try to import .d.ts modules using shorten form (eg. import {TODO_ANY} from 'src/react-app-env';)

Reproduction:

  1. Create basic TypeScript CRA app
  2. Add import './react-app-env' to src/App.tsx.
  3. npm run test

Error:

> react-ts-app@0.1.0 test /react-ts-app
> react-scripts test
 FAIL  src/App.test.tsx
  ● Test suite failed to run

    Cannot find module './react-app-env' from 'App.tsx'

    However, Jest was able to find:
        './react-app-env.d.ts'

    You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'].

    See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string

    However, Jest was able to find:
        './App.css'
        './App.test.tsx'
        './App.tsx'

    You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'].
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/ViieeS/patch-1