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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 27.0.0 and above break running snapshots and unit tests in react native project #11474

Closed
aryojamousi opened this issue May 28, 2021 · 10 comments

Comments

@aryojamousi
Copy link

aryojamousi commented May 28, 2021

馃挜 Regression Report

Last working version

Worked up to version: 26.6.3

Stopped working in version: >=27.0.0

To Reproduce

Steps to reproduce the behavior:

  • clone the repo linked below
  • install the dependencies
  • run yarn test:jest

Expected behavior

The default tests bootstraped with npx react-native init <project> should pass but they do not and the error below is triggered:

TypeError: Cannot destructure property 'config' of 'options' as it is undefined.

      at Object.getCacheKey (node_modules/@jest/create-cache-key-function/build/index.js:62:12)
      at ScriptTransformer._getCacheKey (node_modules/@jest/transform/build/ScriptTransformer.js:280:41)
      at ScriptTransformer._getFileCachePath (node_modules/@jest/transform/build/ScriptTransformer.js:351:27)
      at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:588:32)
      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:758:40)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:815:19)

Link to repl or repo (highly encouraged)

https://github.com/aryojamousi/JestExampleProject

Run npx envinfo --preset jest

Paste the results here:

  System:
    OS: macOS 11.2.3
    CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
  Binaries:
    Node: 14.15.5 - ~/.nvm/versions/node/v14.15.5/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 6.14.11 - ~/.nvm/versions/node/v14.15.5/bin/npm
  npmPackages:
    jest: ^27.0.1 => 27.0.1 

After debugging, the error could be is triggered in the getCacheKeyFunction in the built index.js in create-cache-key-function directory.
When the below

var _default = (files = [], values = []) =>
  getCacheKeyFunction(getGlobalCacheKey(files, values));

exports.default = _default;

gets replaced with

var _default = (files = [], values = []) =>
  getGlobalCacheKey(files, values);

exports.default = _default;

then the tests work as they should.

@SimenB
Copy link
Member

SimenB commented May 28, 2021

See facebook/react-native#30637

/cc @thymikee

@SimenB SimenB closed this as completed May 28, 2021
@ahsatha
Copy link

ahsatha commented May 29, 2021

x2

@aryojamousi
Copy link
Author

aryojamousi commented Jun 15, 2021

I am still experiencing the same behaviour upon upgrading React Native to 0.64.2 and using Jest to 27.0.2 @SimenB

@florian-milky
Copy link

So what's the minimum react-native version to get it to work with jest 27?

@ahsatha
Copy link

ahsatha commented Jun 18, 2021

So what's the minimum react-native version to get it to work with jest 27?

I'm using v26, not for react-native though and v26 jest, working fine

@aryojamousi
Copy link
Author

@ahsatha Yes, this is a react-native specific problem

@joaorbdg
Copy link

Happening with Vue v2 also.

Cannot destructure property 'config' of 'undefined' as it is undefined.

@voskresla
Copy link

voskresla commented Jun 21, 2021

Vue2 the same problem

TypeError: Cannot destructure property 'config' of 'cacheKeyOptions' as it is undefined.

      at Object.getCacheKey (node_modules/babel-jest/build/index.js:194:14)
      at ScriptTransformer._getCacheKey (node_modules/@jest/transform/build/ScriptTransformer.js:280:41)
      at ScriptTransformer._getFileCachePath (node_modules/@jest/transform/build/ScriptTransformer.js:351:27)
      at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:588:32)
      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:758:40)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:815:19)
System:
    OS: macOS 10.15.7
    CPU: (8) x64 Intel(R) Core(TM) i7-8557U CPU @ 1.70GHz
  Binaries:
    Node: 14.15.0 - ~/.nvm/versions/node/v14.15.0/bin/node
    npm: 6.14.8 - ~/.nvm/versions/node/v14.15.0/bin/npm
  npmPackages:
    jest: 27.0.4 => 27.0.4 

@SimenB
Copy link
Member

SimenB commented Jun 22, 2021

Like with RN, whatever transformer (or preset) you're using with Vue will need to be updated to support the new API from #10834.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants