fbjs icon indicating copy to clipboard operation
fbjs copied to clipboard

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

Open sdumjahn opened this issue 3 years ago • 2 comments

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 https://github.com/facebook/jest/commit/858c50b9afd1fa280cd004105ef0662407b87e0b#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.

sdumjahn avatar Jun 07 '21 13:06 sdumjahn

Should be fixed by https://github.com/facebook/fbjs/pull/408

eps1lon avatar Jun 25 '21 05:06 eps1lon

As far as I can see #408 was merged, and I'm still experiencing this issue with "jest": "^27.5.1". Although, curiously only in a single test suite.

Elias-Graf avatar Feb 18 '22 08:02 Elias-Graf