mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
fix: don't call "afterAll" hooks, if suite was skipped (#2802)
This commit is contained in:
parent
5eeb6f3863
commit
aa1aa4daa2
@ -270,14 +270,14 @@ export async function runSuite(suite: Suite, runner: VitestRunner) {
|
||||
catch (e) {
|
||||
failTask(suite.result, e)
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await callSuiteHook(suite, suite, 'afterAll', runner, [suite])
|
||||
await callCleanupHooks(beforeAllCleanups)
|
||||
}
|
||||
catch (e) {
|
||||
failTask(suite.result, e)
|
||||
try {
|
||||
await callSuiteHook(suite, suite, 'afterAll', runner, [suite])
|
||||
await callCleanupHooks(beforeAllCleanups)
|
||||
}
|
||||
catch (e) {
|
||||
failTask(suite.result, e)
|
||||
}
|
||||
}
|
||||
|
||||
suite.result.duration = now() - start
|
||||
|
||||
@ -1,7 +1,23 @@
|
||||
import { assert, describe, expect, it } from 'vitest'
|
||||
import { afterAll, afterEach, assert, beforeAll, beforeEach, describe, expect, it } from 'vitest'
|
||||
import { timeout } from '../src/timeout'
|
||||
|
||||
describe.skip('skipped suite', () => {
|
||||
beforeAll(() => {
|
||||
throw new Error('should not run')
|
||||
})
|
||||
|
||||
beforeEach(() => {
|
||||
throw new Error('should not run')
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
throw new Error('should not run')
|
||||
})
|
||||
|
||||
afterAll(() => {
|
||||
throw new Error('should not run')
|
||||
})
|
||||
|
||||
it('no fail as suite is skipped', () => {
|
||||
assert.equal(Math.sqrt(4), 3)
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user