test: migrate from AVA to Node.js native test runner by parkerbxyz · Pull Request #346 · actions/create-github-app-token

@parkerbxyz changed the base branch from main to beta

March 13, 2026 06:34

Copilot AI review requested due to automatic review settings

March 13, 2026 06:41

@parkerbxyz

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 <223556219+Copilot@users.noreply.github.com>
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 <223556219+Copilot@users.noreply.github.com>
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 <223556219+Copilot@users.noreply.github.com>
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 <223556219+Copilot@users.noreply.github.com>
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 <223556219+Copilot@users.noreply.github.com>
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 <223556219+Copilot@users.noreply.github.com>

@parkerbxyz

Handle Windows-style line endings in execFile output by stripping
\r?\n instead of just \n.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 <223556219+Copilot@users.noreply.github.com>
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 <223556219+Copilot@users.noreply.github.com>

@parkerbxyz

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 <223556219+Copilot@users.noreply.github.com>
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 <223556219+Copilot@users.noreply.github.com>

@parkerbxyz

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@parkerbxyz

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 <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
(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 <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
(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 <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
(cherry picked from commit f863ba5)