Skip to content

Commit 2127b04

Browse files
test: track beforeEach calls in runtime-skip test
Increment a beforeEach counter and assert it runs twice when a test is skipped at runtime. Signed-off-by: Igor <igorshevelenkov4@gmail.com>
1 parent 25b0646 commit 2127b04

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/parallel/test-runner-aftereach-runtime-skip.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
'use strict';
22

3-
const assert = require('node:assert');
43
const common = require('../common');
4+
const assert = require('node:assert');
55
const { beforeEach, afterEach, test } = require('node:test');
66

7+
let beforeEachTotal = 0;
78
let afterEachRuntimeSkip = 0;
89
let afterEachTotal = 0;
910

10-
beforeEach(common.mustCall(() => {}, 2));
11+
beforeEach(common.mustCall(() => {
12+
beforeEachTotal++;
13+
}, 2));
1114

1215
afterEach(common.mustCall((t) => {
1316
afterEachTotal++;
@@ -27,6 +30,7 @@ test('runtime skip', (t) => {
2730
test('static skip', { skip: true }, common.mustNotCall());
2831

2932
process.on('exit', () => {
33+
assert.strictEqual(beforeEachTotal, 2);
3034
assert.strictEqual(afterEachRuntimeSkip, 1);
3135
assert.strictEqual(afterEachTotal, 2);
3236
});

0 commit comments

Comments
 (0)