Config loading raises exceptions in Jest 27
ajclaasen opened this issue · comments
Hello,
I am running into the following error message when using jest-erb-transformer with Jest 27:
TypeError: Cannot read property 'filter' of undefined
at loadConfig (../node_modules/jest-erb-transformer/index.js:68:48)
at Object.process (../node_modules/jest-erb-transformer/index.js:129:20)
at ScriptTransformer.transformSource (../node_modules/@jest/transform/build/ScriptTransformer.js:612:31)
at ScriptTransformer._transformAndBuildScript (../node_modules/@jest/transform/build/ScriptTransformer.js:758:40)
at ScriptTransformer.transform (../node_modules/@jest/transform/build/ScriptTransformer.js:815:19)
I have done some digging in the way configs are loaded, and it seems that config object is not approached correctly. On the line raising the exception:
const erbTransformers = jestConfig.transform.filter(e => e[1] === __filename)
changing it to
const erbTransformers = jestConfig.config.transform.filter(e => e[1] === __filename)
fixes the issue.
When I use Jest 26 instead of Jest 27 in my project, this line does not raise an exception and the transformer works as expected.
I don't have enough knowledge or skill to point out the breaking change in Jest 27 with certainty, but I think somewhere in there the way options are passed to transformers has been changed. I think in jestjs/jest#10834?
PR with a hotfix for the issue: #17
Thank you for all of your work, I am very happy with this transformer, and please let me know if I can help in any way!
Hi @rjclaasen,
Yeah looks like they've updated how the config gets passed through in v27, thanks for catching this error and taking the time to make PR 💯
I'll take a look at the PR and update the circleci config to let it pass the CI checks.
Thanks, Chris
@rjclaasen I've merged and released your changes in v1.2.4
Thanks again for spotting this and contributing :)