Skip to content

Add cleanup and cleanupEach hook pairs - #3492

Open
woahwhattheheck wants to merge 8 commits into
avajs:mainfrom
woahwhattheheck:sol56/ava928-cleanup-semantics-20261004
Open

woahwhattheheck wants to merge 8 commits into
avajs:mainfrom
woahwhattheheck:sol56/ava928-cleanup-semantics-20261004

Conversation

@woahwhattheheck

@woahwhattheheck woahwhattheheck commented Oct 6, 2026 •

Copy link
Copy Markdown

Fixes #928

Add two cleanup helpers using the existing hook-registration mechanism:

  • test.cleanup() registers the callback before the test file and once again as after.always.
  • test.cleanupEach() registers it before each test and once again as the final after.always, preserving the issue's proposed lifecycle rather than adding an afterEach hook.
  • Both helpers support serial and skip chains, with public TypeScript declarations, focused hook-pair tests, conditional-chain type examples, and writing-tests documentation.

Validation: reviewed all five changed paths on the exact source at 3cac5dcc7b915019dcbf9b8c45a8c4d5d768b529, five commits ahead and zero behind main at the publication check. Four focused direct checks passed on the exact create-chain module with Node24.19.0: file cleanup before/final-after pairing; beforeEach with one final after hook; serial/skip propagation to both hooks; and independent registration argument arrays. These checks exercise registration semantics only. The full AVA suite, hook-runner lifecycle and TypeScript compilation were not run for this submission.

Hosted CI receipt

Workflow run 37427496881 on exact head 3cac5dcc7b915019dcbf9b8c45a8c4d5d768b529 completed with 12 of 14 jobs passing.

Passing jobs include Node 22 on Ubuntu/macOS/Windows; Node 24 on macOS/Windows; Node 26 on macOS/Windows; TypeScript 5.9 and 6.0; lint; lockfile install; and no-lock install.

The only failures are the Ubuntu Node 24.12 and Node 26 matrix jobs, each on one TAP golden comparison whose stack-source line shifted in Node's internal esm/utils: Node 24 reports line 319 where the fixture expects 318; Node 26 reports 355 where it expects 354. Those TAP fixture files are not part of this PR's five-file diff. This receipt therefore records the current hosted matrix without treating those unrelated fixture expectations as a source failure in this change, and it does not claim a fully green CI matrix.


IssueHunt Summary

Referenced issues

This pull request has been submitted to:


@woahwhattheheck

Copy link
Copy Markdown
Author

Current-head handoff for 8ec14ea3ac8e48fd5232587a5836198b4f341341:

  • Added actual Runner lifecycle coverage proving test.cleanup() runs before the file and again after a failing test.
  • Added Runner coverage proving test.cleanupEach() runs before each serial test and once after the file, rather than registering afterEach cleanup.
  • Focused validation: npx tap test-tap/hooks.js — 26 subtests / 31 assertions passed on Node 24.19.0.

This remains my original contribution and IssueHunt submission for #928. Claimant and payee: @woahwhattheheck. The issue displays an $82 funded pool; I affirmatively request maintainer review, eligible allocation, and the applicable $82 payout through the existing IssueHunt submission process if this contribution is accepted. This is not an assertion that the PR has been accepted, awarded, invoiced, settled, or paid.

…[skip ci]

Apply the optional comparison sanitizer to expected and actual output for the edge-case fixture only. Preserve user stack locations, diagnostic text and other reporter comparisons. The retained fixture comparison has a focused discriminator receipt; do not dispatch repository-wide suites for this forward.
@woahwhattheheck

Copy link
Copy Markdown
Author

Current head is 16e81507acbdd3fc5f831132527d3bda62d29cf0. The TAP edge-case comparison now normalizes the compileSourceTextModule internal ESM frame on both expected and actual output. Other reporter comparisons remain exact; user-code locations and diagnostic text retain their differences.

One focused discriminator used the retained first-party Node24 fixture: the baseline line319-versus318 variation failed, the new comparison passed, and changed error text/user-code locations still failed. No full AVA or TAP suite was rerun. This forward uses [skip ci] to avoid repository-wide reruns, so it does not establish successful required CI checks. Please review the focused repair and specify the narrow acceptance check still needed.

My original IssueHunt submission for #928 remains tied to this PR. I am requesting acceptance, the eligible allocation from its displayed $82 funded pool and payment through that existing submission. Please confirm approval and payout timing; no compensation is being waived or second claim created.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make it easier to write reliable cleanup tasks

2 participants