Skip to content

Commit

Permalink
fix(runner): run onTestFinished and onTestFailed during retry a…
Browse files Browse the repository at this point in the history
…nd `repeats`
  • Loading branch information
hi-ogawa committed Oct 2, 2024
1 parent 9edfa19 commit c3292cf
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions packages/runner/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,26 @@ export async function runTest(test: Test | Custom, runner: VitestRunner): Promis
failTask(test.result, e, runner.config.diffOptions)
}

try {
await callTaskHooks(test, test.onFinished || [], 'stack')
}
catch (e) {
failTask(test.result, e, runner.config.diffOptions)
}

if (test.result.state === 'fail') {
try {
await callTaskHooks(
test,
test.onFailed || [],
runner.config.sequence.hooks,
)
}
catch (e) {
failTask(test.result, e, runner.config.diffOptions)
}
}

if (test.result.state === 'pass') {
break
}
Expand All @@ -286,26 +306,6 @@ export async function runTest(test: Test | Custom, runner: VitestRunner): Promis
}
}

try {
await callTaskHooks(test, test.onFinished || [], 'stack')
}
catch (e) {
failTask(test.result, e, runner.config.diffOptions)
}

if (test.result.state === 'fail') {
try {
await callTaskHooks(
test,
test.onFailed || [],
runner.config.sequence.hooks,
)
}
catch (e) {
failTask(test.result, e, runner.config.diffOptions)
}
}

// if test is marked to be failed, flip the result
if (test.fails) {
if (test.result.state === 'pass') {
Expand Down

0 comments on commit c3292cf

Please sign in to comment.