Repository navigation
chore: consolidate tests; require node 22 or newer - #43
yowainwright wants to merge 1 commit into
Conversation
node 22 or newer
guybedford
left a comment
There was a problem hiding this comment.
Thanks for this, it's a really nice cleanup! The new tests are a big step up - the utils and parser tests now exercise the real src functions against temp directories and a mocked fetch rather than inline re-implementations, and the e2e now properly asserts on the loaded modules via a child process. Dropping sinon and tsx for the node:test built-ins is great to see too.
I ran this locally on Node 26 and everything passes (35 unit + 1 e2e), and confirmed the e2e fixture does fail without the loader, so it is testing the right thing.
Just a few small suggestions inline, none of them major.
|
|
||
| describe("loader", () => { | ||
| test("resolved with basic config", async (t) => { | ||
| const nextResolve = t.mock.fn(async () => ({ url: "resolved-url" })); |
There was a problem hiding this comment.
Since tests/ is excluded from tsconfig.json and tsup only strips types, the tests aren't currently typechecked. Including them in tsc shows one small thing here - the mock takes no parameters, so nextResolve.mock.calls[0].arguments[0] below is a TS2493 (6 occurrences in this file). Typing the parameter fixes it:
const nextResolve = t.mock.fn(async (_specifier: string) => ({ url: "resolved-url" }));It could be nice to have chomp typecheck cover tests/ as well so this stays checked.
There was a problem hiding this comment.
Typed the loader mocks and added the tests to chomp typecheck.
| }, | ||
| "engines": { | ||
| "node": ">=18.0.0" | ||
| "node": ">=22.0.0" |
There was a problem hiding this comment.
Fine with moving the floor to 22 - just noting that since this is a breaking change for consumers it will need to go out as a minor bump (0.3.0) rather than a patch.
Moves fixtures and unit-test helpers out of src/ into tests/, replaces Sinon with built-in Node mocks, and compiles TypeScript before running node --test. The import-map smoke test runs its loader in one child process. Requires Node 22 or newer at runtime and uses Node 26 for development. Removes Sinon, its types, and tsx. Validation: build, typecheck, existing ESLint configuration, 35 unit tests and 1 end-to-end test pass.
9eb78c6 to
4c7d809
Compare
Proposed Changes
This PR:
src/intotests/.Sinonwith built-in Node mocks, and