|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const common = require('../common'); |
| 4 | +const assert = require('node:assert'); |
| 5 | +const { beforeEach, afterEach, test } = require('node:test'); |
| 6 | + |
| 7 | +let beforeEachTotal = 0; |
| 8 | +let afterEachRuntimeSkip = 0; |
| 9 | +let afterEachTotal = 0; |
| 10 | + |
| 11 | +beforeEach(common.mustCall(() => { |
| 12 | +beforeEachTotal++; |
| 13 | +}, 2)); |
| 14 | + |
| 15 | +afterEach(common.mustCall((t) => { |
| 16 | +afterEachTotal++; |
| 17 | +if (t.name === 'runtime skip') { |
| 18 | +afterEachRuntimeSkip++; |
| 19 | +} |
| 20 | +}, 2)); |
| 21 | + |
| 22 | +test('normal test', (t) => { |
| 23 | +t.assert.ok(true); |
| 24 | +}); |
| 25 | + |
| 26 | +test('runtime skip', (t) => { |
| 27 | +t.skip('skip after setup'); |
| 28 | +}); |
| 29 | + |
| 30 | +test('static skip', { skip: true }, common.mustNotCall()); |
| 31 | + |
| 32 | +process.on('exit', () => { |
| 33 | +assert.strictEqual(beforeEachTotal, 2); |
| 34 | +assert.strictEqual(afterEachRuntimeSkip, 1); |
| 35 | +assert.strictEqual(afterEachTotal, 2); |
| 36 | +}); |