test: migrate from AVA to Node.js native test runner by parkerbxyz · Pull Request #346 · actions/create-github-app-token (original) (raw)
changed the base branch from main to beta
Copilot AI review requested due to automatic review settings
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
avaimport withnode:testin tests/index.js - Update
t.snapshot()calls tot.assert.snapshot() - Update test script from
avatonode --test - Remove
avafrom 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
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
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
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 added a commit that referenced this pull request
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 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
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
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 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
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
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 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
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})