test: migrate from AVA to Node.js native test runner (#346)
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 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
+10
-4
@@ -2,14 +2,14 @@
|
||||
|
||||
Add one test file per scenario. You can run them in isolation with:
|
||||
|
||||
```bash
|
||||
```
|
||||
node tests/post-token-set.test.js
|
||||
```
|
||||
|
||||
All tests are run together in [tests/index.js](index.js), which can be executed with ava
|
||||
All tests are run together in [tests/index.js](index.js), which can be executed with Node's built-in test runner
|
||||
|
||||
```
|
||||
npx ava tests/index.js
|
||||
node --test tests/index.js
|
||||
```
|
||||
|
||||
or with npm
|
||||
@@ -20,7 +20,13 @@ npm test
|
||||
|
||||
## How the tests work
|
||||
|
||||
The output from the tests is captured into a snapshot ([tests/snapshots/index.js.md](snapshots/index.js.md)). It includes all requests sent by our scripts to verify it's working correctly and to prevent regressions.
|
||||
The output from the tests is captured into a snapshot ([tests/index.js.snapshot](index.js.snapshot)). It includes all requests sent by our scripts to verify it's working correctly and to prevent regressions.
|
||||
|
||||
To update snapshots after an intentional change:
|
||||
|
||||
```
|
||||
node --test --test-update-snapshots tests/index.js
|
||||
```
|
||||
|
||||
## How to add a new test
|
||||
|
||||
|
||||
Reference in New Issue
Block a user