Skip to content

test: migrate from AVA to Node.js native test runner#346

Merged
parkerbxyz merged 16 commits intobetafrom
migrate-ava-to-node-test
Mar 13, 2026
Merged

test: migrate from AVA to Node.js native test runner#346
parkerbxyz merged 16 commits intobetafrom
migrate-ava-to-node-test

Conversation

@parkerbxyz
Copy link
Contributor

@parkerbxyz parkerbxyz commented Mar 13, 2026

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.

Changes

  • 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

@parkerbxyz parkerbxyz changed the base branch from main to beta March 13, 2026 06:34
@parkerbxyz parkerbxyz force-pushed the migrate-ava-to-node-test branch from dea3da2 to 3676088 Compare March 13, 2026 06:38
@parkerbxyz parkerbxyz self-assigned this Mar 13, 2026
@parkerbxyz parkerbxyz marked this pull request as ready for review March 13, 2026 06:40
@parkerbxyz parkerbxyz requested a review from a team as a code owner March 13, 2026 06:41
Copilot AI review requested due to automatic review settings March 13, 2026 06:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.js with node:test + snapshot assertions and a custom snapshot serializer.
  • Switch snapshot artifacts from tests/snapshots/index.js.md to tests/index.js.snapshot.
  • Update npm test to run node --test under c8, and remove ava from 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]>
@parkerbxyz parkerbxyz force-pushed the migrate-ava-to-node-test branch from 3676088 to 016c18d Compare March 13, 2026 06:52
parkerbxyz and others added 6 commits March 12, 2026 23:54
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]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 test to run node --test with c8, and remove AVA/execa/fake-timers dev dependencies.
  • Replace the AVA-based aggregator (tests/index.js) with a node:test-based runner that snapshots per-scenario stdout/stderr into tests/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]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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) with node --test and child_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.

parkerbxyz and others added 2 commits March 13, 2026 08:21
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]>
@parkerbxyz parkerbxyz requested a review from Copilot March 13, 2026 15:27
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]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 with node:test and generate a text snapshot file.
  • Replaces fake timers usage with node:test mock timers in main-repo-skew test.
  • Updates docs and package.json scripts/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.

parkerbxyz and others added 2 commits March 13, 2026 08:40
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]>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.js with node:test + snapshots (tests/index.js.snapshot).
  • Update repo-skew test to use node:test mock 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.

@parkerbxyz parkerbxyz merged commit f863ba5 into beta Mar 13, 2026
4 checks passed
@parkerbxyz parkerbxyz deleted the migrate-ava-to-node-test branch March 13, 2026 16:05
@create-app-token-action-releaser

🎉 This PR is included in version 3.0.0-beta.5 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

parkerbxyz added a commit that referenced this pull request Mar 14, 2026
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)
parkerbxyz added a commit that referenced this pull request Mar 14, 2026
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)
parkerbxyz added a commit that referenced this pull request Mar 14, 2026
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate from AVA to Node.js native test runner

2 participants