Skip to content

Commit fb79792

Browse files
authoredSep 25, 2024··
fix(runner): mark tests as skipped when beforeAll failed (#6524)
1 parent 7727ca8 commit fb79792

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed
 

‎packages/runner/src/run.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -382,13 +382,19 @@ export async function runSuite(suite: Suite, runner: VitestRunner): Promise<void
382382
}
383383
else {
384384
try {
385-
beforeAllCleanups = await callSuiteHook(
386-
suite,
387-
suite,
388-
'beforeAll',
389-
runner,
390-
[suite],
391-
)
385+
try {
386+
beforeAllCleanups = await callSuiteHook(
387+
suite,
388+
suite,
389+
'beforeAll',
390+
runner,
391+
[suite],
392+
)
393+
}
394+
catch (e) {
395+
markTasksAsSkipped(suite, runner)
396+
throw e
397+
}
392398

393399
if (runner.runSuite) {
394400
await runner.runSuite(suite)

‎test/reporters/tests/__snapshots__/junit.test.ts.snap

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ exports[`addFileAttribute true 1`] = `
2525
exports[`emits <failure> when beforeAll/afterAll failed 1`] = `
2626
"<?xml version="1.0" encoding="UTF-8" ?>
2727
<testsuites name="vitest tests" tests="8" failures="2" errors="0" time="...">
28-
<testsuite name="basic.test.ts" timestamp="..." hostname="..." tests="8" failures="2" errors="0" skipped="2" time="...">
28+
<testsuite name="basic.test.ts" timestamp="..." hostname="..." tests="8" failures="2" errors="0" skipped="4" time="...">
2929
<testcase classname="basic.test.ts" name="suite with beforeAll &gt; ok 1" time="...">
30+
<skipped/>
3031
</testcase>
3132
<testcase classname="basic.test.ts" name="suite with beforeAll &gt; ok 2" time="...">
33+
<skipped/>
3234
</testcase>
3335
<testcase classname="basic.test.ts" name="suite with beforeAll &gt; skip 1" time="...">
3436
<skipped/>

0 commit comments

Comments
 (0)
Please sign in to comment.