Skip to content

test: migrate from tape to node:test, borp, and c8 - #125

Merged
mcollina merged 2 commits into
masterfrom
chore/node-test-borp
Oct 19, 2026
Merged

mcollina merged 2 commits into
masterfrom
chore/node-test-borp

Conversation

@mcollina

Copy link
Copy Markdown
Owner

Summary

Moves the test suite off tape onto node:test (run through borp) and adds c8 V8 coverage.

What changed

  • 56 test files rewritten from the tape API to node:test:
    • Assertions now use the test context's t.assert.* (these count toward t.plan, which is the idiomatic node:test pairing). t.equal/t.equals become t.assert.strictEqual (tape's equal is strict ===), t.deepEqual → t.assert.deepStrictEqual, t.throws/t.doesNotThrow/t.ok/t.true/t.error map to their t.assert equivalents, and t.pass → t.assert.ok(true, msg).
    • t.end() and the require('tape').test imports are removed.
    • Event/callback-driven suites (streams.js, levelup-encoding.js, reserved-byte.js, max-depth.js) became async functions that await stream completion (node:events once or a small per-test promise), because t.plan in node:test does not keep a test open when its callback returns synchronously.
    • t.plan(n) is preserved.
  • package.json:
    • "test": "standard && borp --pattern \"test/*.js\""
    • "test:coverage": "standard && c8 borp --pattern \"test/*.js\""
    • devDependencies: add borp, c8; remove tape, tap-mocha-reporter.
  • .c8rc.json added to scope coverage to index.js and lib/.
  • AGENTS.md updated test guidance.

Test/coverage check

  • npm test → 2486 test cases pass (all pass), lint clean.
  • npm run test:coverage → ~95% line / ~93% branch / ~97% function coverage on index.js + lib/.

Counting note

The migration runs the same test cases. The old tape run 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 # ok trailer). No tests were dropped.

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.
@mcollina
mcollina merged commit 6794c10 into master Oct 19, 2026
20 checks passed
@mcollina
mcollina deleted the chore/node-test-borp branch October 19, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant