test: migrate from AVA to Node.js native test runner#346
Conversation
dea3da2 to
3676088
Compare
There was a problem hiding this comment.
Pull request overview
Migrates the repository’s test harness from AVA snapshot testing to Node’s built-in node:test runner + snapshot support, updating snapshot storage and removing the AVA dependency.
Changes:
- Replace AVA-based runner in
tests/index.jswithnode:test+ snapshot assertions and a custom snapshot serializer. - Switch snapshot artifacts from
tests/snapshots/index.js.mdtotests/index.js.snapshot. - Update
npm testto runnode --testunderc8, and removeavafrom dependencies/lockfile.
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/snapshots/index.js.md | Removes AVA-generated markdown snapshot report. |
| tests/index.js.snapshot | Adds Node node:test snapshot file with expected stdout/stderr outputs. |
| tests/index.js | Migrates test harness to node:test and updates snapshot assertions/serialization. |
| package.json | Updates test script to node --test and removes ava devDependency. |
| package-lock.json | Removes ava and its transitive dependencies from the lockfile. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Replace AVA with the built-in node:test module for testing. This changes snapshots from AVA's binary format to human-readable text files, which are more efficient for Git to track and easier to review in pull requests. Changes: - Replace `ava` import with `node:test` in tests/index.js - Update `t.snapshot()` calls to `t.assert.snapshot()` - Update test script from `ava` to `node --test` - Remove `ava` from devDependencies - Replace binary snapshots with text-based .snapshot file Closes #344 Co-authored-by: Copilot <[email protected]>
3676088 to
016c18d
Compare
Update references from ava/npx to node --test, point snapshot link to the new index.js.snapshot file, and add instructions for updating snapshots. Co-authored-by: Copilot <[email protected]>
Fix formatting for test execution instructions
Use subtests so snapshot keys include '> stderr' and '> stdout' labels instead of opaque numeric counters, making the snapshot file easier to read and review. Co-authored-by: Copilot <[email protected]>
Use strictEqual for empty stderr/stdout instead of snapshotting them. This removes all the noisy empty-string entries from the snapshot file, cutting it from 355 to 228 lines. Co-authored-by: Copilot <[email protected]>
Use the built-in mock.timers.enable() from node:test instead of the @sinonjs/fake-timers package, removing another test dependency. Co-authored-by: Copilot <[email protected]>
Use the built-in execFile from node:child_process instead of execa, removing another dev dependency. Strip trailing newline from output to match execa's default behavior. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR migrates the repository’s test harness from AVA/execa/@sinonjs-fake-timers to Node’s built-in node:test runner and snapshot mechanism, updating docs and lockfiles accordingly.
Changes:
- Switch
npm testto runnode --testwithc8, and remove AVA/execa/fake-timers dev dependencies. - Replace the AVA-based aggregator (
tests/index.js) with anode:test-based runner that snapshots per-scenario stdout/stderr intotests/index.js.snapshot. - Update test docs and adjust the repo-skew test to use
node:test’s mock timers.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/snapshots/index.js.md | Removes the old AVA-generated markdown snapshot report. |
| tests/index.js.snapshot | Adds Node test-runner snapshot output file. |
| tests/index.js | Replaces AVA runner with node:test + child_process.execFile execution and snapshots. |
| tests/main-repo-skew.test.js | Switches from @sinonjs/fake-timers to node:test mock timers. |
| tests/README.md | Updates instructions to use Node’s built-in test runner and snapshot updates. |
| package.json | Updates test script and removes AVA/execa/fake-timers dev deps. |
| package-lock.json | Lockfile updates reflecting removed dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Handle Windows-style line endings in execFile output by stripping \r?\n instead of just \n. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
Migrates the repository’s test harness from AVA to Node’s built-in node:test runner, updating snapshot handling and removing now-unneeded dev dependencies.
Changes:
- Replace AVA-based test runner (
ava+execa) withnode --testandchild_process.execFile. - Switch snapshot format/location to Node’s native snapshot file (
tests/index.js.snapshot) and remove the AVA-generated snapshot report markdown. - Update test documentation and dependency/lockfile to reflect the new runner and tooling.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/index.js | Reworks the test harness to use node:test + Node snapshots while spawning scenario tests via execFile. |
| tests/index.js.snapshot | Adds the new Node snapshot file containing captured stdout/stderr expectations. |
| tests/main-repo-skew.test.js | Replaces @sinonjs/fake-timers usage with node:test mock timers. |
| tests/README.md | Updates test running and snapshot update instructions for node --test. |
| tests/snapshots/index.js.md | Removes the legacy AVA snapshot report markdown. |
| package.json | Updates the test script to node --test and drops AVA/execa/fake-timers dev deps. |
| package-lock.json | Lockfile update reflecting removed test tooling dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Set maxBuffer to 10MB for execFile to avoid ENOBUFS on larger test output. Add mock.timers.reset() in a finally block for proper cleanup. Co-authored-by: Copilot <[email protected]>
The default 1MB maxBuffer is sufficient for test output. The try/finally inside the callback doesn't work because the test helper runs the main script after the callback returns, so the timer reset must happen on the outer promise via .finally(). Co-authored-by: Copilot <[email protected]>
Simplify the snapshot serializer to a plain identity function since we only snapshot strings. Replace the spread-then-delete env pattern with destructuring rest syntax to cleanly omit unwanted env vars. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
Migrates the test suite from AVA to Node.js’ native node:test runner to get text-based, reviewable snapshots and reduce dev dependencies.
Changes:
- Rewrites the test harness (
tests/index.js) to run scenario tests withnode:testand generate a text snapshot file. - Replaces fake timers usage with
node:testmock timers inmain-repo-skewtest. - Updates docs and
package.jsonscripts/devDependencies to reflect the new runner and snapshot update flow.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/snapshots/index.js.md | Removes AVA-generated snapshot report (no longer needed). |
| tests/main-repo-skew.test.js | Switches from @sinonjs/fake-timers to node:test mock timers and adds teardown. |
| tests/index.js.snapshot | Adds new text-based snapshot file produced by node:test. |
| tests/index.js | Replaces AVA/execa harness with node:test + child_process.execFile and snapshots per stdout/stderr subtest. |
| tests/README.md | Updates instructions for node --test and snapshot updating. |
| package.json | Updates test script and removes AVA/fake-timers/execa dev dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Sort test files for deterministic snapshot order across filesystems. Revert try/await/finally back to .finally() since test() is async and can never throw synchronously. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
There was a problem hiding this comment.
Pull request overview
Migrates the repository’s integration test harness from AVA/execa/@sinonjs/fake-timers to Node’s built-in node:test runner with native snapshot support, updating docs and dependency metadata accordingly.
Changes:
- Replace AVA-based runner in
tests/index.jswithnode:test+ snapshots (tests/index.js.snapshot). - Update repo-skew test to use
node:testmock timers instead of@sinonjs/fake-timers. - Remove AVA/execa/fake-timers dependencies and delete the old markdown snapshot report.
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/snapshots/index.js.md | Removes the old AVA-generated markdown snapshot report. |
| tests/README.md | Updates test execution and snapshot update instructions for node --test. |
| tests/main-repo-skew.test.js | Switches fake timers implementation to node:test’s mock timers. |
| tests/index.js.snapshot | Adds the new Node snapshot file used by node:test. |
| tests/index.js | Rewrites the test runner to use node:test and child_process.execFile output capture + snapshots. |
| package.json | Updates test script to node --test and removes AVA/execa/fake-timers dev deps. |
| package-lock.json | Lockfile updates reflecting removed AVA/execa/fake-timers dependency tree. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
🎉 This PR is included in version 3.0.0-beta.5 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
AVA stores snapshots in a binary format (`.snap`), which produces no meaningful diffs and bloats Git history. This replaces AVA with the built-in `node:test` module, whose snapshot support generates human-readable text files that are easy to diff and review in pull requests. The migration also replaces `@sinonjs/fake-timers` and `execa` with Node.js built-ins (`node:test` mock timers and `node:child_process`), removing three dev dependencies total. - **`tests/index.js`**: Rewritten to use `node:test` with a custom snapshot serializer that renders strings with actual newlines. Uses subtests for labeled `stderr`/`stdout` snapshots, and only snapshots non-empty output. - **`tests/main-repo-skew.test.js`**: Replace `@sinonjs/fake-timers` with `mock.timers.enable()` from `node:test`. - **`tests/README.md`**: Updated documentation to reflect `node --test` and the new snapshot file. - **`package.json`**: Remove `ava`, `@sinonjs/fake-timers`, and `execa` from devDependencies. Update test script to `c8 --100 node --test tests/index.js`. - **`tests/index.js.snapshot`**: New text-based snapshot file replacing binary `tests/snapshots/index.js.snap`. - **`tests/snapshots/`**: Deleted. All 22 test scenarios (66 subtests) pass with 100% code coverage. Closes #344 --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]> (cherry picked from commit f863ba5)
AVA stores snapshots in a binary format (`.snap`), which produces no meaningful diffs and bloats Git history. This replaces AVA with the built-in `node:test` module, whose snapshot support generates human-readable text files that are easy to diff and review in pull requests. The migration also replaces `@sinonjs/fake-timers` and `execa` with Node.js built-ins (`node:test` mock timers and `node:child_process`), removing three dev dependencies total. - **`tests/index.js`**: Rewritten to use `node:test` with a custom snapshot serializer that renders strings with actual newlines. Uses subtests for labeled `stderr`/`stdout` snapshots, and only snapshots non-empty output. - **`tests/main-repo-skew.test.js`**: Replace `@sinonjs/fake-timers` with `mock.timers.enable()` from `node:test`. - **`tests/README.md`**: Updated documentation to reflect `node --test` and the new snapshot file. - **`package.json`**: Remove `ava`, `@sinonjs/fake-timers`, and `execa` from devDependencies. Update test script to `c8 --100 node --test tests/index.js`. - **`tests/index.js.snapshot`**: New text-based snapshot file replacing binary `tests/snapshots/index.js.snap`. - **`tests/snapshots/`**: Deleted. All 22 test scenarios (66 subtests) pass with 100% code coverage. Closes #344 --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]> (cherry picked from commit f863ba5)
AVA stores snapshots in a binary format (`.snap`), which produces no meaningful diffs and bloats Git history. This replaces AVA with the built-in `node:test` module, whose snapshot support generates human-readable text files that are easy to diff and review in pull requests. The migration also replaces `@sinonjs/fake-timers` and `execa` with Node.js built-ins (`node:test` mock timers and `node:child_process`), removing three dev dependencies total. - **`tests/index.js`**: Rewritten to use `node:test` with a custom snapshot serializer that renders strings with actual newlines. Uses subtests for labeled `stderr`/`stdout` snapshots, and only snapshots non-empty output. - **`tests/main-repo-skew.test.js`**: Replace `@sinonjs/fake-timers` with `mock.timers.enable()` from `node:test`. - **`tests/README.md`**: Updated documentation to reflect `node --test` and the new snapshot file. - **`package.json`**: Remove `ava`, `@sinonjs/fake-timers`, and `execa` from devDependencies. Update test script to `c8 --100 node --test tests/index.js`. - **`tests/index.js.snapshot`**: New text-based snapshot file replacing binary `tests/snapshots/index.js.snap`. - **`tests/snapshots/`**: Deleted. All 22 test scenarios (66 subtests) pass with 100% code coverage. Closes #344 --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Copilot Autofix powered by AI <[email protected]> (cherry picked from commit f863ba5)
AVA stores snapshots in a binary format (
.snap), which produces no meaningful diffs and bloats Git history. This replaces AVA with the built-innode:testmodule, whose snapshot support generates human-readable text files that are easy to diff and review in pull requests.The migration also replaces
@sinonjs/fake-timersandexecawith Node.js built-ins (node:testmock timers andnode:child_process), removing three dev dependencies total.Changes
tests/index.js: Rewritten to usenode:testwith a custom snapshot serializer that renders strings with actual newlines. Uses subtests for labeledstderr/stdoutsnapshots, and only snapshots non-empty output.tests/main-repo-skew.test.js: Replace@sinonjs/fake-timerswithmock.timers.enable()fromnode:test.tests/README.md: Updated documentation to reflectnode --testand the new snapshot file.package.json: Removeava,@sinonjs/fake-timers, andexecafrom devDependencies. Update test script toc8 --100 node --test tests/index.js.tests/index.js.snapshot: New text-based snapshot file replacing binarytests/snapshots/index.js.snap.tests/snapshots/: Deleted.All 22 test scenarios (66 subtests) pass with 100% code coverage.
Closes #344