-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jest-transform: testRegex value shows empty object instead of RegExp object #9778
Comments
The workaround transformer can do is don’t use the value from jestConfig string but use the value from the last parameter which is an object and it contains the original config object |
Yeah, the string is just meant to be used for cache busting purposes (i.e. "any config change should bust the cache") - if you want to actually read any value you should use the last parameter. We should fix the serialization though - I think we currently just do essentially |
I saw internal jest uses |
Yeah, feel free to ignore it if you want - it's just there as a convenience |
ping @SimenB , we observe another issue related to
When debugging
Currently Related to kulshekhar/ts-jest#1552 |
I'm guessing, without running the reproduction, that this is due to workers (which will get empty object) and running in band (which will get the regexp). I'm currently away from a computer, so I can't verify |
hmm, I thought workers share the same config object which shouldn't be different. Or before creating Is there an alternative way I can detect if that is a test file besides relying on UPDATE: You were right. At this point https://github.com/facebook/jest/blob/fa4cbbf87cb3c97fe44f1fee30663715a9dbba71/packages/jest-runner/src/index.ts#L120 |
also seem to be strange that only occurs when there is a js next to that ts. I have a repo which only contains ts and no issues in parallel mode. |
I discovered that Updated I've tested |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
Custom transformer receives jest config string via
getCacheKey
. Ints-jest
recently we rely ontestRegex
to do some logic. However, the value oftestRegex
which is passed to transformer is unusable. Instead of receiving the real value of the regex, transformer receives it as[{}]
Related to kulshekhar/ts-jest#1509
To Reproduce
Steps to reproduce the behavior:
yarn
, runyarn test
and see the exceptiongetCacheKey
and inspectjestConfigStr
, observe the value in the picture below (red circle)ScriptTransformer.js
constructor, observe the input value ofconfig
is[{}]
and it is unusable.Expected behavior
testRegex
value which is passed to transformer should be usable and retain its original value.Link to repl or repo (highly encouraged)
https://github.com/ahnpnl/ts-jest-babel-example/tree/test-regex-transformer
envinfo
The text was updated successfully, but these errors were encountered: