-
Notifications
You must be signed in to change notification settings - Fork 455
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
Regression: no typescript transformation/compilation possible for JavaScript files any more #740
Regression: no typescript transformation/compilation possible for JavaScript files any more #740
Comments
Thanks @mkreidenweis this definitely is a bug which IMO get fixed by adding your |
Could you also try if it reads I've checked the log via |
@alvis I'm actually working on this right now, will check and add a test if not. But it should be, so check that you correctly specified the Update: when using the log file, use |
@alvis I think your config is wrong somewhere because I've added a E2E test related to this and all is good. Anyway, thanks as now there is a E2E test for that :D |
@huafu The reason of my problem is that I use the config in package.json, not jest.config. With the latest v23.10.1, it works again, but only if I put "transform": {
"^.+\\.(j|t)sx?$": "ts-jest"
} into the jest config in my package.json. I checked with the log, and I find that without the additional transform setting, the resulting jest config would be just "transform": [
[
"^.+\\.tsx?$",
"<path to my project>/node_modules/ts-jest/dist/index.js"
]
] The reason for that is the result of ts-jest/src/config/create-jest-preset.ts Lines 15 to 23 in e2f699c
However, it's always Line 4 in e2f699c
|
Yeah, because by default we leverage js compilation to jest which knows how to handle it. The default preset is for ts-jest to handle typescript files. We cannot make a dynamic preset unless you call the function yourself. |
@huafu: Can we look for |
Long story short: no A preset is static. The only way to use the preset with When loading a preset, Jest will |
@alvis that's why it's recommended to use |
@huafu I think by default we should honor what's stated in In fact, I am wondering if the statements below already controls whether a JS file is allowed to be transpiled or not. Lines 74 to 76 in 25e1c63
I've checked that If so, we don't even need to evaluate ts-jest/src/config/create-jest-preset.ts Line 23 in e2f699c
and therefore probably we can even take away |
@alvis it's not as easy, when jest loads the preset, NOTHING from ts-jest is loaded yet, just it loads the preset. It could be possible if jest was calling some kind of If you want to discuss this more I'm on slack. Also you could look at some quick diagrams I've made which explains how jest works with transformers: https://kulshekhar.github.io/ts-jest/tech/process/ |
@alvis I found a way of providing multiple preset, will provide a PR later. In your particular case you'll set There will be 3 presets:
|
Ooo! Amazing! Very glad we have a way to get around the issue without creating an extra jest.config. Thanks so much @huafu |
@alvis for now you don't have to create a jest.config.js in your case anyway, simply add the |
Issue :
Hi. I think #724 (v23.10.0) introduced a regression: Running a test of ours fails with a message like this:
ts-jest doesn't seem to typescript-compile
.js
files at all any more.Expected behavior :
ts-jest passes
.js
files through typescript compilation, tests finish without error. (The version we were using before (22.4.4) didn't have the issue.)Suggested fix:
IMO the problem is here: 6c32a93#diff-969086a2836a7b1045fc24603a3b6cbeR114
Line 114 should actually read
Right now we always run in the
else
case, even though the condition in line 110 and the comment in line 118 makes me expect that we take thetsCompiler.compile
for.js
files as well.Please let me know if you need more info.
The text was updated successfully, but these errors were encountered: