Skip to content

Add cleanup hook helpers - #3457

Open
jamilahmadzai wants to merge 6 commits into
avajs:mainfrom
jamilahmadzai:issue-928-cleanup-hooks-v2
Open

Add cleanup hook helpers#3457
jamilahmadzai wants to merge 6 commits into
avajs:mainfrom
jamilahmadzai:issue-928-cleanup-hooks-v2

Conversation

@jamilahmadzai

@jamilahmadzai jamilahmadzai commented Jun 15, 2026

Copy link
Copy Markdown

Fixes #928

Summary

  • Add test.cleanup() and test.cleanupEach() as paired setup and guaranteed-cleanup hooks.
  • Add serial and .skip() variants while preserving conditional-chain access.
  • Register the helpers through the existing AVA hook machinery, so no runner-specific task type is needed.
  • Clone declaration arguments for each paired registration because argument parsing consumes its input array.
  • Document the public API and cover metadata, runtime order, failure paths, skipped pairs, and TypeScript declarations.
  • Refresh the Node 26 TAP edge-case snapshot for Node 26.5.0 internal line-number output.

Validation

Run locally:

  • Node.js 24.12: npx test-ava test/create-chain/test.js - 25 passed
  • Node.js 24.12: npx tap test-tap/hooks.js - 32 passed
  • Node.js 26.5.0: npx tap test-tap/reporters/tap.js - 5 passed
  • npx tsc --noEmit - passed
  • npx xo - passed (10 existing TODO/FIXME warnings)

A complete npm test run passed lint, TypeScript, and all 217 core tests (2 skipped). The broader TAP run passed 1,625/1,628 assertions; the only three failures were existing Node 24 default-reporter snapshot mismatches, reproduced unchanged on upstream/main.

Bounty

IssueHunt funded amount: $82. Payout GitHub user: @jamilahmadzai.


IssueHunt Summary

Referenced issues

This pull request has been submitted to:


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.

Make it easier to write reliable cleanup tasks

1 participant