forked from nodejs/node
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_runner: call {before,after}Each() on suites
Prior to this commit, beforeEach() and afterEach() hooks were not called on test suites (describe()). This commit addresses that. Fixes: nodejs#45028 PR-URL: nodejs#45161 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Flags: --no-warnings --test-name-pattern=enabled --test-name-pattern=/pattern/i | ||
'use strict'; | ||
const common = require('../common'); | ||
const { | ||
after, | ||
afterEach, | ||
before, | ||
beforeEach, | ||
describe, | ||
it, | ||
test, | ||
} = require('node:test'); | ||
|
||
test('top level test disabled', common.mustNotCall()); | ||
test('top level skipped test disabled', { skip: true }, common.mustNotCall()); | ||
test('top level skipped test enabled', { skip: true }, common.mustNotCall()); | ||
it('top level it enabled', common.mustCall()); | ||
it('top level it disabled', common.mustNotCall()); | ||
it.skip('top level skipped it disabled', common.mustNotCall()); | ||
it.skip('top level skipped it enabled', common.mustNotCall()); | ||
describe('top level describe disabled', common.mustNotCall()); | ||
describe.skip('top level skipped describe disabled', common.mustNotCall()); | ||
describe.skip('top level skipped describe enabled', common.mustNotCall()); | ||
test('top level runs because name includes PaTtErN', common.mustCall()); | ||
|
||
test('top level test enabled', common.mustCall(async (t) => { | ||
t.beforeEach(common.mustCall()); | ||
t.afterEach(common.mustCall()); | ||
await t.test( | ||
'nested test runs because name includes PATTERN', | ||
common.mustCall() | ||
); | ||
})); | ||
|
||
describe('top level describe enabled', () => { | ||
before(common.mustCall()); | ||
beforeEach(common.mustCall(4)); | ||
afterEach(common.mustCall(4)); | ||
after(common.mustCall()); | ||
|
||
it('nested it disabled', common.mustNotCall()); | ||
it('nested it enabled', common.mustCall()); | ||
describe('nested describe disabled', common.mustNotCall()); | ||
describe('nested describe enabled', common.mustCall(() => { | ||
it('is enabled', common.mustCall()); | ||
})); | ||
}); |