Repository navigation
test: migrate from tape to node:test, borp, and c8 - #125
Merged
Merged
Conversation
Replace the tape test runner with node:test (run through borp) and add
V8 coverage via c8.
- Convert all 56 test files from the tape API (assertions on the test
context) to node:test, using the test context's t.assert.* (which count
toward t.plan) and async functions for event/callback-driven streaming,
memdb, and decoder-error tests. t.plan(n) is kept; t.end() and the tape
imports are removed.
- Assertion mapping is behavior-preserving: t.equal/t.equals are strict
(===) so they become t.assert.strictEqual, t.deepEqual becomes
t.assert.deepStrictEqual, t.throws/t.doesNotThrow/t.ok/t.error map to
their t.assert equivalents, and t.pass becomes t.assert.ok(true, msg).
- package.json: scripts.test is now "standard && borp"; add
scripts.test:coverage ("standard && c8 borp"); drop tape and
tap-mocha-reporter devDependencies; add borp and c8.
- Add .c8rc.json to scope coverage to index.js and lib/.
- Update AGENTS.md test guidance.
The converted node:test suite runs the same 2486 test cases and all pass
(tape reported 4391 because it counts each assertion as a TAP test line,
while node:test counts test-case blocks); coverage is ~95% lines.
node:test on Node 22 cancels subtests when the parent test callback returns synchronously without awaiting them (Node 24+ no longer does). Convert the 35 subtest-driving files so the parent test and its helper functions are async and every t.test(...) is awaited, which keeps the subtests alive on every supported Node version. - Parents become 'async function (t)' and forEach loops that spawn subtests become 'for...of' loops so their t.test calls can be awaited (the original forEach callback closing paren was brace-matched away). - The two files that route subtests through a local 'doTest' helper make that helper async and await it at the call sites. - Subtest callbacks are also 'async'; harmless for the synchronous assertion bodies. Verified: all 2486 tests pass on Node 22.23.3, 24.21.0, and 26.10.0 with no failures or cancellations.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves the test suite off
tapeontonode:test(run through borp) and adds c8 V8 coverage.What changed
node:test:t.assert.*(these count towardt.plan, which is the idiomatic node:test pairing).t.equal/t.equalsbecomet.assert.strictEqual(tape'sequalis strict===),t.deepEqual→t.assert.deepStrictEqual,t.throws/t.doesNotThrow/t.ok/t.true/t.errormap to theirt.assertequivalents, andt.pass→t.assert.ok(true, msg).t.end()and therequire('tape').testimports are removed.streams.js,levelup-encoding.js,reserved-byte.js,max-depth.js) becameasyncfunctions thatawaitstream completion (node:eventsonceor a small per-test promise), becauset.planin node:test does not keep a test open when its callback returns synchronously.t.plan(n)is preserved."test": "standard && borp --pattern \"test/*.js\"""test:coverage": "standard && c8 borp --pattern \"test/*.js\""borp,c8; removetape,tap-mocha-reporter..c8rc.jsonadded to scope coverage toindex.jsandlib/.Test/coverage check
npm test→ 2486 test cases pass (all pass), lint clean.npm run test:coverage→ ~95% line / ~93% branch / ~97% function coverage onindex.js+lib/.Counting note
The migration runs the same test cases. The old
taperun reported 4391 because tape counts every assertion as an individual TAP test line; node:test counts test-case blocks (2486 — an exact match for tape's test-block count when you exclude the# oktrailer). No tests were dropped.