Skip to content

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

@aryojamousi

Description

@aryojamousi

💥 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions