test_runner: run afterEach for runtime t.skip()#61525
test_runner: run afterEach for runtime t.skip()#61525igor-shevelenkov wants to merge 4 commits intonodejs:mainfrom
Conversation
Signed-off-by: Igor <igorshevelenkov4@gmail.com>
|
Review requested:
|
Increment a beforeEach counter and assert it runs twice when a test is skipped at runtime. Signed-off-by: Igor <igorshevelenkov4@gmail.com>
|
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.78% 89.77% -0.01%
==========================================
Files 672 672
Lines 203809 203811 +2
Branches 39183 39189 +6
==========================================
- Hits 182980 182963 -17
- Misses 13166 13177 +11
- Partials 7663 7671 +8
🚀 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. |
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