Skip to content
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

Migrate from ts-jest to @swc/jest #889

Merged
merged 1 commit into from
Dec 12, 2023
Merged

Migrate from ts-jest to @swc/jest #889

merged 1 commit into from
Dec 12, 2023

Conversation

jo-sm
Copy link
Owner

@jo-sm jo-sm commented Dec 12, 2023

As part of looking into #887 I ran into a ton of difficulty getting ts-jest to work with ESM, with one of the main issues being related to importing ./utils.js style files.

This seems to be an issue with the combination of TypeScript + Jest when using ESM, and the ts-jest preset hasn't "fixed" this yet (by doing something like the moduleNameMapper approach mentioned in comments like this. Has there not been any PR from someone?

In any case, it's a bit frustrating that there wasn't a mention of this in the troubleshooting docs as the issue above was pretty well trafficked and commented on, and while there was a PR, it was closed and there was no follow up. What's worse is that this issue has been known for at least 4 years. There really should have been a troubleshooting section added here even without a community contributed PR, and so I don't have faith that either an additon to the preset or a mention in the troubleshooting docs will happen anytime soon, at least before I want to get Stylelint 16 in main.

While checking types in the test code is useful, it's not that important since the actual code is type checked separately (both with the linter and the compilation steps), and since @swc/jest is simpler and hopefully doesn't have the above frustration factor, I've decided to migrate from ts-jest to @swc/jest.

If at some point type checking the tests becomes important the lint:types task can be updated to check test code too.

As part of looking into #887 I
ran into a ton of difficulty getting `ts-jest` to work with ESM, with
one of the main issues being related to importing `./utils.js` style
files.

This seems to be an issue with the combination of TypeScript + Jest when using
ESM, and the `ts-jest` preset hasn't "fixed" this yet (by doing
something like the `moduleNameMapper` approach mentioned in
[comments like this](kulshekhar/ts-jest#1057 (comment)). Has
there not been any PR from someone?

In any case, it's a bit frustrating that there wasn't a mention of this
in the troubleshooting docs as the issue above was pretty well
trafficked and commented on, and while there was a PR, it was closed and
there was no follow up. What's worse is that this issue has been known
for at least 4 years. There really should have been a troubleshooting
section added here even without a community contributed PR, and so I
don't have faith that either an additon to the preset or a mention in
the troubleshooting docs will happen anytime soon, at least before I
want to get Stylelint 16 in main.

While checking types in the test code is useful, it's not that important
since the actual code is type checked separately (both with the linter
and the compilation steps), and since `@swc/jest` is simpler and
hopefully doesn't have the above frustration factor, I've decided to
migrate from `ts-jest` to `@swc/jest`.

If at some point type checking the tests becomes important the
lint:types task can be updated to check test code too.
@jo-sm jo-sm merged commit b94da49 into master Dec 12, 2023
2 checks passed
@jo-sm jo-sm deleted the use-swc-ts branch December 12, 2023 23:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant