facebook / fbjs

A collection of utility libraries used by other Meta JS projects.
MIT License
1.95k stars 313 forks source link

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

Open sdumjahn opened 3 years ago

sdumjahn commented 3 years ago

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.

eps1lon commented 3 years ago

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

Elias-Graf commented 2 years ago

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.