Skip to content

Got error "Cannot destructure property 'instrument' of 'options' as it is undefined" when using with jest:27.0.4 #441

@sdumjahn

Description

@sdumjahn

I have jest 27.0.4 and got the following error:

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

      at Object.getCacheKey (node_modules/fbjs-scripts/jest/createCacheKeyFunction.js:38: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)

When visiting the changes made in jest 27.0, I found the following commit jestjs/jest@858c50b#diff-d656d5ec636ff72f9f481b12a586d4048922a9f8e42e31521ea6f071530f3882 .
In this commit they moved the 3rd parameter inside the options (which was the 4th parameter) and call the transformer with only 3 parameters.
Since the code expect to find the options in the 4th parameter, wich is not there anymore the value of options is undefined and lead to this error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions