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
  • #8637
Closed
Open
Issue created Mar 11, 2020 by Administrator@rootContributor

Add support for Jest option "testMatch"

Created by: mljohns89

Problem

Jest has a configuration option called "testMatch" which CRA doesn't currently allow you to override out of the box.

If I try adding the following to my package.json:

  "jest": {
    "testMatch": [
      "**/*.steps.ts"
    ]
  }

I get the following error when running npm test:

Out of the box, Create React App only supports overriding these Jest options:

  • clearMocks
  • collectCoverageFrom
  • coveragePathIgnorePatterns
  • coverageReporters
  • coverageThreshold
  • displayName
  • extraGlobals
  • globalSetup
  • globalTeardown
  • moduleNameMapper
  • resetMocks
  • resetModules
  • restoreMocks
  • snapshotSerializers
  • transform
  • transformIgnorePatterns
  • watchPathIgnorePatterns.

These options in your package.json Jest configuration are not currently supported by Create React App:

  • testMatch

If you wish to override other Jest options, you need to eject from the default setup. You can do so by running npm run eject but remember that this is a one-way operation. You may also file an issue with Create React App to discuss supporting more options out of the box.

Proposed Solution

It would be nice if this was supported without having to go through the process of ejecting

Ideally, adding this configuration option would just extend the existing Jest testMatch options:

  • Files with .js suffix in __tests__ folders.
  • Files with .test.js suffix.
  • Files with .spec.js suffix.

And not completely override them.

Additional Info

I am somewhat new to React Development, only been developing with React for about 2 years now; so if there is a decent work-around, I am all ears. I prefer using Typescript, React and CRA added Typescript support and files with the extension test.tsx are supported out of the box. It would just be nice to have support for this Jest option too though as it seems to be a common Jest option that people will change depending on their preferences in test file naming conventions.

Assignee
Assign to
Time tracking