test: migrate test suite from jest to the node:test runner#597
test: migrate test suite from jest to the node:test runner#597alexander-akait wants to merge 3 commits into
Conversation
- Replace jest globals and `expect` matchers with `node:test` and `node:assert` equivalents across all test files. - Convert the five `toMatchSnapshot` assertions to inline `assert.deepStrictEqual` checks and drop the `__snapshots__` directory. - Add `scripts/test.js` to run the suite with an explicit file list so `test/fixtures` is never executed as tests and behavior is identical on every supported Node.js version and OS. - Wire coverage through `node --test --experimental-test-coverage` with the built-in lcov reporter and keep uploading to Codecov. - Remove `jest`, `@types/jest` and `prettier-2`; update the CI matrix to Node.js 18-25 (coverage collected on 22+).
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #597 +/- ##
==========================================
+ Coverage 96.54% 98.05% +1.51%
==========================================
Files 50 47 -3
Lines 3036 9096 +6060
Branches 971 0 -971
==========================================
+ Hits 2931 8919 +5988
- Misses 89 177 +88
+ Partials 16 0 -16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Migrates the test suite from Jest to Node's built-in node:test runner. All Jest globals (expect, toEqual, toBeNull, toMatchSnapshot, lifecycle hooks) are replaced with node:assert calls and node:test equivalents; snapshots are inlined; the CI matrix and dev dependencies are adjusted accordingly.
Changes:
- Add
scripts/test.jswrapper aroundnode --test(explicit file enumeration) and rewirenpm test*scripts; dropjest,@types/jest,prettier-2, andjest.config.js. - Convert every
test/*.test.jstonode:test/assert, replace(done)with(t, done), and inline former snapshot fixtures (alias,fallback,restrictions,exportsField,importsField); deletetest/__snapshots__/. - Update CI matrix to Node 18–25 only, gate coverage to Node ≥22, and add ESLint/tsconfig overrides for tests using
node:test.
Reviewed changes
Copilot reviewed 50 out of 52 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| package.json, jest.config.js | Drop Jest deps/config; route npm test through new script. |
| scripts/test.js | New wrapper invoking node --test with an explicit file list. |
| .github/workflows/test.yml | Drop old Node versions, split coverage vs. non-coverage runs. |
| eslint.config.mjs, tsconfig.types.test.json | Allow modern Node builtins and drop jest types for tests. |
| test/*.test.js | Replace Jest globals/matchers with assert/node:test; inline snapshots. |
| test/snapshots/*.snap | Removed; expectations moved inline. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The node:test based suite requires Node.js 18+, but the library still supports Node.js >= 10.13. Add `scripts/smoke-test.js`, which loads the public entry point and performs sync/async resolves using only APIs available on the oldest supported Node.js version, and run it in a dedicated CI job (installing runtime dependencies only) across Node.js 10/12/14/16 on Linux and Windows.
`assert.ok(err instanceof Error)` already narrows `err` to `Error`, so the following `/** @type {Error} */` cast was inert (and reflowed into a misleading position). Remove it and access `err.message` directly.
Summary
use built-in node tester instead jest
What kind of change does this PR introduce?
test
Did you add tests for your changes?
this pr is only about test
Does this PR introduce a breaking change?
No
If relevant, what needs to be documented once your changes are merged or what have you already documented?
Nothing
Use of AI
Claude