-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test_runner: skip each hooks for skipped tests
When a test is skipped, the corresponding beforeEach and afterEach hooks should also be skipped. Fixes: #52112 PR-URL: #52115 Reviewed-By: Raz Luvaton <rluvaton@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
- Loading branch information
Showing
6 changed files
with
120 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Flags: --test-reporter=spec | ||
'use strict'; | ||
const { after, afterEach, before, beforeEach, test } = require('node:test'); | ||
|
||
before(() => { | ||
console.log('BEFORE'); | ||
}); | ||
|
||
beforeEach(() => { | ||
console.log('BEFORE EACH'); | ||
}); | ||
|
||
after(() => { | ||
console.log('AFTER'); | ||
}); | ||
|
||
afterEach(() => { | ||
console.log('AFTER EACH'); | ||
}); | ||
|
||
test('skipped test', { skip: true }); |
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,11 @@ | ||
BEFORE | ||
AFTER | ||
﹣ skipped test (*ms) # SKIP | ||
ℹ tests 1 | ||
ℹ suites 0 | ||
ℹ pass 0 | ||
ℹ fail 0 | ||
ℹ cancelled 0 | ||
ℹ skipped 1 | ||
ℹ todo 0 | ||
ℹ duration_ms * |
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,60 @@ | ||
// Flags: --test-reporter=spec | ||
'use strict'; | ||
const { | ||
after, | ||
afterEach, | ||
before, | ||
beforeEach, | ||
describe, | ||
it, | ||
} = require('node:test'); | ||
|
||
describe('skip all hooks in this suite', { skip: true }, () => { | ||
before(() => { | ||
console.log('BEFORE 1'); | ||
}); | ||
|
||
beforeEach(() => { | ||
console.log('BEFORE EACH 1'); | ||
}); | ||
|
||
after(() => { | ||
console.log('AFTER 1'); | ||
}); | ||
|
||
afterEach(() => { | ||
console.log('AFTER EACH 1'); | ||
}); | ||
|
||
it('should not run'); | ||
}); | ||
|
||
describe('suite runs with mixture of skipped tests', () => { | ||
before(() => { | ||
console.log('BEFORE 2'); | ||
}); | ||
|
||
beforeEach(() => { | ||
console.log('BEFORE EACH 2'); | ||
}); | ||
|
||
after(() => { | ||
console.log('AFTER 2'); | ||
}); | ||
|
||
afterEach(() => { | ||
console.log('AFTER EACH 2'); | ||
}); | ||
|
||
it('should not run', { skip: true }); | ||
|
||
it('should run 1', () => { | ||
console.log('should run 1'); | ||
}); | ||
|
||
it('should not run', { skip: true }); | ||
|
||
it('should run 2', () => { | ||
console.log('should run 2'); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
test/fixtures/test-runner/output/suite-skip-hooks.snapshot
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,24 @@ | ||
BEFORE 2 | ||
BEFORE EACH 2 | ||
should run 1 | ||
AFTER EACH 2 | ||
BEFORE EACH 2 | ||
should run 2 | ||
AFTER EACH 2 | ||
AFTER 2 | ||
﹣ skip all hooks in this suite (*ms) # SKIP | ||
▶ suite runs with mixture of skipped tests | ||
﹣ should not run (*ms) # SKIP | ||
✔ should run 1 (*ms) | ||
﹣ should not run (*ms) # SKIP | ||
✔ should run 2 (*ms) | ||
▶ suite runs with mixture of skipped tests (*ms) | ||
|
||
ℹ tests 4 | ||
ℹ suites 2 | ||
ℹ pass 2 | ||
ℹ fail 0 | ||
ℹ cancelled 0 | ||
ℹ skipped 2 | ||
ℹ todo 0 | ||
ℹ duration_ms * |
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