Skip to content
New issue

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

Jest - testMatch and testRegex cannot be used together with RN 0.59.1 #24060

Closed
NemanjaManot opened this issue Mar 20, 2019 · 2 comments
Closed
Labels
Bug Resolution: Locked This issue was locked by the bot.

Comments

@NemanjaManot
Copy link

🐛 Bug Report

I had project on 0.58.0 and upgraded to 0.59.1 and jest tests stopped working with an error

● Validation Error:

Configuration options testMatch and testRegex cannot be used together.

Configuration Documentation:
https://jestjs.io/docs/configuration.html

This is my jest configuration in package.json:

  "jest": {
    "preset": "react-native",
    "transform": {
      "^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
    },
    "transformIgnorePatterns": [
      "node_modules/(?!react-native|react-navigation)"
    ],
    "setupFiles": [
      "<rootDir>/__mocks__/mocks.js"
    ],
    "globals": {
      "window": {}
    },
    "testRegex": "(/__tests__/.*|\\.(test))\\.jsx?$"
  }

Nowhere do I have testMatch.

To Reproduce

Have 0.58 project and upgrade to 0.59.1

Expected Behavior

Tests to start running

Code Example

Environment

  React Native Environment Info:
    System:
      OS: Ubuntu 18.04.2 LTS
      CPU: Intel® Core™ i5-4440 CPU @ 3.10GHz × 4 
      Memory: 15,6 GiB
    Binaries:
      Node: 10.10.0
      npm: 6.4.1 
      Watchman: 4.9.0 - /usr/local/bin/watchman
    IDEs:
      Android Studio: 3.4.1
    npmPackages:
      react: 16.8.4 
      react-native: 0.59.1
@thymikee
Copy link
Contributor

You're using react-native Jest preset, which includes testMatch, that's why you get the error. Please consider changing testRegex to testMatch (or just remove it) for now.

Btw, it seems like the testMatch config in RN preset

testMatch: [
'**/__tests__/**/*.(js|ts|tsx)',
'**/?(*.)+(spec|test).(js|ts|tsx)',
],

pretty much aligns with the default from Jest 24:
https://github.com/facebook/jest/blob/c5fd7aae93764c13c259ae9a73846c10e84ae2a3/packages/jest-config/src/Defaults.ts#L70

So soon enough we should be able to get rid of this from the config.

To satisfy "working with TypeScript by default" constraint though, RN would need to require Jest 24+. @cpojer are we good to change it in 0.60 (I believe we are)?

@cpojer
Copy link
Contributor

cpojer commented Mar 20, 2019

@thymikee yeah, the latest Jest 24 should be part of RN on master.

grabbou pushed a commit that referenced this issue Apr 8, 2019
Summary:
Jest 24 includes [`testMatch` and `moduleFileExtensions`](https://github.com/facebook/jest/blob/c5fd7aae93764c13c259ae9a73846c10e84ae2a3/packages/jest-config/src/Defaults.ts#L70) that align with the ones that are currently there on master, because it added default handling for TypeScript as well. I think it's time for us to move to Jest 24. Is there a way we can tell users to upgrade Jest to certain version?

Fixes #24060

[General] [Changed] - update Jest preset to align with Jest 24
Pull Request resolved: #24062

Differential Revision: D14538988

Pulled By: cpojer

fbshipit-source-id: d8d152b8e8517b34144970f1cc1ed0b49f8b4e54
aleclarson pushed a commit to alloc/react-native-macos that referenced this issue Nov 15, 2019
Summary:
Jest 24 includes [`testMatch` and `moduleFileExtensions`](https://github.com/facebook/jest/blob/c5fd7aae93764c13c259ae9a73846c10e84ae2a3/packages/jest-config/src/Defaults.ts#L70) that align with the ones that are currently there on master, because it added default handling for TypeScript as well. I think it's time for us to move to Jest 24. Is there a way we can tell users to upgrade Jest to certain version?

Fixes facebook/react-native#24060

[General] [Changed] - update Jest preset to align with Jest 24
Pull Request resolved: facebook/react-native#24062

Differential Revision: D14538988

Pulled By: cpojer

fbshipit-source-id: d8d152b8e8517b34144970f1cc1ed0b49f8b4e54
@facebook facebook locked as resolved and limited conversation to collaborators Mar 20, 2020
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

4 participants