Skip to content

chore: consolidate tests; require node 22 or newer - #43

Open
yowainwright wants to merge 1 commit into
mainfrom
dev-toolchain/node-tests
Open

yowainwright wants to merge 1 commit into
mainfrom
dev-toolchain/node-tests

Conversation

@yowainwright

@yowainwright yowainwright commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

Proposed Changes

This PR:

  • moves fixtures and unit-test helpers out of src/ into tests/.
  • replaces Sinon with built-in Node mocks, and
  • compiles ts before running node --test. The import-map smoke test runs its loader in one child process.

we don't need to switch from ts to js to run node tests.
this is only done to avoid adding `.ts to all of the import statements.


Read about referenced issues here. Replace words with this Pull Request's context.

@yowainwright
yowainwright added this pull request to stack #46 November 7, 2026 02:27
@yowainwright yowainwright changed the title chore!: consolidate tests and require Node 22 or newer chore: consolidate tests; require node 22 or newer Nov 7, 2026
@yowainwright
yowainwright marked this pull request as ready for review November 7, 2026 03:15

@guybedford guybedford left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/loader.test.ts Outdated

describe("loader", () => {
test("resolved with basic config", async (t) => {
const nextResolve = t.mock.fn(async () => ({ url: "resolved-url" }));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typed the loader mocks and added the tests to chomp typecheck.

Comment thread tests/cache-path.test.ts Resolved
Comment thread package.json Resolved
Comment thread package.json
},
"engines": {
"node": ">=18.0.0"
"node": ">=22.0.0"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread .gitignore Resolved
Comment thread readme.md Resolved
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.
@yowainwright
yowainwright force-pushed the dev-toolchain/node-tests branch from 9eb78c6 to 4c7d809 Compare November 20, 2026 00:42
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.

2 participants