test_runner: run afterEach for runtime t.skip()#61525
test_runner: run afterEach for runtime t.skip()#61525nodejs-github-bot merged 2 commits intonodejs:mainfrom
Conversation
|
Review requested:
|
|
This looks fine, but |
|
Thanks @ljharb. I see from tape-testing/tape#545 that in tape, |
| process.on('exit', () => { | ||
| assert.strictEqual(beforeEachTotal, 2); | ||
| assert.strictEqual(afterEachRuntimeSkip, 1); | ||
| assert.strictEqual(afterEachTotal, 2); | ||
| }); |
There was a problem hiding this comment.
You don't need the beforeEachTotal or afterEachTotal variables. The common.mustCall()s will enforce those for you.
|
@igor-shevelenkov deviating from TAP semantics seems like a pretty big design issue, but fair that it'd be a breaking change. I'd still suggest making it (in a different PR ofc) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #61525 +/- ##
=======================================
Coverage 89.72% 89.73%
=======================================
Files 676 676
Lines 205988 205990 +2
Branches 39490 39489 -1
=======================================
+ Hits 184830 184846 +16
+ Misses 13295 13291 -4
+ Partials 7863 7853 -10
🚀 New features to boost your workflow:
|
|
@ljharb i'll research this topic, pros and cons and come back with possible solutions |
I think that this might be a good discussion point for the next cc @nodejs/test_runner |
|
FWIW, I would strongly advise against letting TAP influence any decisions outside of the TAP reporter itself. |
|
@cjihrig true, it's not TAP specifically, it's the prior art of pre-existing TAP-generating test frameworks, most of which (possibly all) don't have a dynamic mechanism to skip a test from inside the test that's already begun. |
|
I can't speak to whether or not anything else supports them, but they have been there for three and a half years (#43730) at this point. It doesn't seem like a good idea to break users who are depending on it at this point when this seems to be a straightforward fix. |
|
This was discussed in a couple test runner team meetings, and we reached consensus that this PR is 👍 I read through the remaining comments and I see no outstanding items that weren't addressed in the meeting. I'm adding |
This comment has been minimized.
This comment has been minimized.
Commit Queue failed- Loading data for nodejs/node/pull/61525 ✔ Done loading data for nodejs/node/pull/61525 ----------------------------------- PR info ------------------------------------ Title test_runner: run afterEach for runtime t.skip() (#61525) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch igor-shevelenkov:main -> nodejs:main Labels author ready, needs-ci, commit-queue-squash, test_runner Commits 4 - test_runner: run afterEach on runtime skip - Merge branch 'nodejs:main' into main - test: track beforeEach calls in runtime-skip test - Merge branch 'nodejs:main' into main Committers 2 - Igor <[email protected]> - GitHub <[email protected]> PR-URL: https://github.com/nodejs/node/pull/61525 Fixes: https://github.com/nodejs/node/issues/61462 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Pietro Marchini <[email protected]> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/61525 Fixes: https://github.com/nodejs/node/issues/61462 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Pietro Marchini <[email protected]> -------------------------------------------------------------------------------- ℹ This PR was created on Mon, 26 Jan 2026 10:50:20 GMT ✔ Approvals: 4 ✔ - Colin Ihrig (@cjihrig): https://github.com/nodejs/node/pull/61525#pullrequestreview-3707520585 ✔ - Chemi Atlow (@atlowChemi): https://github.com/nodejs/node/pull/61525#pullrequestreview-3713408859 ✔ - Moshe Atlow (@MoLow): https://github.com/nodejs/node/pull/61525#pullrequestreview-3718102648 ✔ - Pietro Marchini (@pmarchini): https://github.com/nodejs/node/pull/61525#pullrequestreview-3846531064 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2026-02-25T18:44:10Z: https://ci.nodejs.org/job/node-test-pull-request/71459/ - Querying data for job/node-test-pull-request/71459/ ✔ Build data downloaded ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/main up to date... From https://github.com/nodejs/node * branch main -> FETCH_HEAD ✔ origin/main is now up-to-date - Downloading patch for 61525 From https://github.com/nodejs/node * branch refs/pull/61525/merge -> FETCH_HEAD ✔ Fetched commits as 764e9a756082..3a29ef0407fa -------------------------------------------------------------------------------- Auto-merging lib/internal/test_runner/test.js error: commit 332f669ee2e3a7674327867145e02ac3d5053846 is a merge but no -m option was given. fatal: cherry-pick failed [main e85a169712] test_runner: run afterEach on runtime skip Author: Igor <[email protected]> Date: Mon Jan 26 13:06:41 2026 +0300 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-runner-aftereach-runtime-skip.js ✘ Failed to apply patcheshttps://github.com/nodejs/node/actions/runs/22413356910 |
|
Uuuugh. @igor-shevelenkov I think there's a conflict with If that doesn't produce a conflict, it's something else (don't push). If it does produce a conflict, could you resolve it and force-push? I'll have to re-run CI etc. |
|
@JakobJingleheimer, I rebased my branch onto the latest main and got no conflicts. |
|
Ahh, I see the problem:
Our tooling does not support merges. The merge commits will have to be removed. The easiest way is:
I'll re-run CI etc when that's done. |
Signed-off-by: Igor <[email protected]>
Increment a beforeEach counter and assert it runs twice when a test is skipped at runtime. Signed-off-by: Igor <[email protected]>
3a29ef0 to
2127b04
Compare
Failed to start CI- Validating Jenkins credentials ✔ Jenkins credentials valid - Starting PR CI job ✘ Failed to start PR CI: 200 OKhttps://github.com/nodejs/node/actions/runs/22451470137 |
|
Landed in 2ae6d8f |

Ensure afterEach runs when a test is skipped at runtime (t.skip()), while keeping static { skip: true } behavior unchanged.
Runtime t.skip() previously set skipped and prevented afterEach, even if beforeEach ran.
This left resources uncleaned and differed from user expectations.
Fixes: #61462