Skip to content

Commit

Permalink
Migrate from ts-jest to @swc/jest
Browse files Browse the repository at this point in the history
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 `ts-jest` (or at least the interplay
between `ts-jest` and Jest) and from what I could tell in the issues and
code, this isn't solved yet. The solution to the underlying issue was "fixed"
by suggesting the use of a custom resolver, which is not part of the main
`ts-jest` package (see kulshekhar/ts-jest#1057).

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 so instead of trying to fix `ts-jest`
and use the custom resolver, I opt for using `@swc/jest` which instead
removes the types entirely.
  • Loading branch information
jo-sm committed Dec 12, 2023
1 parent 89c8392 commit 2077058
Show file tree
Hide file tree
Showing 4 changed files with 363 additions and 113 deletions.
5 changes: 3 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
clearMocks: true,
preset: "ts-jest",
testEnvironment: "node",
testPathIgnorePatterns: ["/node_modules/", "dist/"],
transform: {
"^.+\\.(t|j)s?$": "@swc/jest",
},
};
Loading

0 comments on commit 2077058

Please sign in to comment.