Skip to content

Commit

Permalink
fix(runner): mark tests as skipped when beforeAll failed (#6524)
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa authored Sep 25, 2024
1 parent 7727ca8 commit fb79792
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
20 changes: 13 additions & 7 deletions packages/runner/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,19 @@ export async function runSuite(suite: Suite, runner: VitestRunner): Promise<void
}
else {
try {
beforeAllCleanups = await callSuiteHook(
suite,
suite,
'beforeAll',
runner,
[suite],
)
try {
beforeAllCleanups = await callSuiteHook(
suite,
suite,
'beforeAll',
runner,
[suite],
)
}
catch (e) {
markTasksAsSkipped(suite, runner)
throw e
}

if (runner.runSuite) {
await runner.runSuite(suite)
Expand Down
4 changes: 3 additions & 1 deletion test/reporters/tests/__snapshots__/junit.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ exports[`addFileAttribute true 1`] = `
exports[`emits <failure> when beforeAll/afterAll failed 1`] = `
"<?xml version="1.0" encoding="UTF-8" ?>
<testsuites name="vitest tests" tests="8" failures="2" errors="0" time="...">
<testsuite name="basic.test.ts" timestamp="..." hostname="..." tests="8" failures="2" errors="0" skipped="2" time="...">
<testsuite name="basic.test.ts" timestamp="..." hostname="..." tests="8" failures="2" errors="0" skipped="4" time="...">
<testcase classname="basic.test.ts" name="suite with beforeAll &gt; ok 1" time="...">
<skipped/>
</testcase>
<testcase classname="basic.test.ts" name="suite with beforeAll &gt; ok 2" time="...">
<skipped/>
</testcase>
<testcase classname="basic.test.ts" name="suite with beforeAll &gt; skip 1" time="...">
<skipped/>
Expand Down

0 comments on commit fb79792

Please sign in to comment.