You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a custom transform I want to chain after babel-jest, and being able to use this package to do so has been a great help to me!
This custom transform's file lives in my project directory as a separate .js file. When using it without chaining it, I could apply it by doing the following in jest.config.js:
Cannot find module '<rootDir>/frontend/webpack_polyfill.js'
at requireTransformer (../node_modules/jest-chain-transform/lib/transformer.js:51:24)
at flatTransformers (../node_modules/jest-chain-transform/lib/transformer.js:66:33)
at getFlattenTransformers (../node_modules/jest-chain-transform/lib/transformer.js:85:31)
at Object.getCacheKey (../node_modules/jest-chain-transform/lib/transformer.js:94:32)
at ScriptTransformer._getCacheKey (../node_modules/@jest/transform/build/ScriptTransformer.js:281:41)
at ScriptTransformer._getFileCachePath (../node_modules/@jest/transform/build/ScriptTransformer.js:352:27)
I did manage to figure out that I could get the correct transform to be used by passing a path relative to ../node_modules/jest-chain-transform/lib/transformer.js:
Although this does work, I do feel like this path is easy to break accidentally.
My first suggestion would be to add support for <rootDir>1 to this package, so that transformers can be configured in a similar way as in the rest of jest's config.
Another option that would work for me is to make my transformer into a package. If I understand correctly, I then should be able to apply it by just configuring jest-chain-transform to import 'webpack-polyfill' instead of '../../../spec/frontend/webpack_polyfill.js'.
The text was updated successfully, but these errors were encountered:
ajclaasen
changed the title
Brittle path when transformer is a local file instead of an installed package
Brittle path when transformer is a local file
Jun 15, 2022
ajclaasen
changed the title
Brittle path when transformer is a local file
Brittle path when transformer is local file
Jun 15, 2022
ajclaasen
changed the title
Brittle path when transformer is local file
Add support for <rootDir>
Jun 15, 2022
ajclaasen
changed the title
Add support for <rootDir>
Add support for <rootDir>Jun 15, 2022
Hey, thanks so much for the package!
I have a custom transform I want to chain after
babel-jest
, and being able to use this package to do so has been a great help to me!This custom transform's file lives in my project directory as a separate
.js
file. When using it without chaining it, I could apply it by doing the following injest.config.js
:However, using
<rootDir>
when chaining to another transformer usingjest-chain-transform
raises an exception:Error:
I did manage to figure out that I could get the correct transform to be used by passing a path relative to
../node_modules/jest-chain-transform/lib/transformer.js
:Although this does work, I do feel like this path is easy to break accidentally.
My first suggestion would be to add support for
<rootDir>
1 to this package, so that transformers can be configured in a similar way as in the rest of jest's config.Another option that would work for me is to make my transformer into a package. If I understand correctly, I then should be able to apply it by just configuring
jest-chain-transform
to import'webpack-polyfill'
instead of'../../../spec/frontend/webpack_polyfill.js'
.Footnotes
https://jestjs.io/docs/configuration#rootdir-string ↩
The text was updated successfully, but these errors were encountered: