-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Switch from Jest to Node.js built-in test runner #2463
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
base: release/15.x
Are you sure you want to change the base?
Switch from Jest to Node.js built-in test runner #2463
Conversation
|
I have converted all the tests starting with |
This comment was marked as outdated.
This comment was marked as outdated.
Just a heads up in case you're running into problems - there is no globbing in Node 20. |
|
Thanks @cjihrig for clarifying. I was doing some quick hacking to reduce build failures with current state of files and hadn't nailed down the difference in behaviour with node version. |
|
So, Node 20 goes EOL in a couple months. In the interim, I've seen people do a few different things (assuming you want to use node:test):
|
|
Main conversion done, and in particular can run Jest counts on
There were 8 tests in ts-imports.test.ts. Will have a look for the other 12 difference in tests count. Might be a loop moved inside a test, but intended pattern for porting was Edit: found missing true/false loop in |
|
For reference, this was the prompt and example file I was using with agents
|
|
Future work, but does not need to be part of this PR unless preferred now:
|
|
Mega merge! Feel free to ask style questions. I used AI agents for lots of conversion and while I did review each file, there may be some weirdness I ignored, or some patterns we would like to use consistently. |
|
Added (One of ideas in #2463 (comment)) |


Problem
I do like writing tests using Jest, but the ESM support is still experimental (relies on a Node.js experimental flag). I hit this quickly when looking at converting Commander to esm-only.
Solution
The radical approach in this PR is to switch to native Node.js test runner! Zero dependencies compared with large Jest install. Fast test runner. Potential downsides are simpler API patterns and switch to
node:assert.The Node.js test runner does have test coverage support but still experimental. Given we do not currently enforce coverage percentage, I don't think that is a blocker.
Another alternative is we could switch to vitest which has a similar API to Jest and natively supports ESM. I have not used vitest, but seems to be fast and well regarded.
ToDo
ts-imports.test.js)no-undefeslint rule (when finish conversion).example-conversion.test.js(when finish conversion)ChangeLog
node:testtest runner