Skip to content

Commit c3292cf

Browse files
committed
fix(runner): run onTestFinished and onTestFailed during retry and repeats
1 parent 9edfa19 commit c3292cf

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

packages/runner/src/run.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,26 @@ export async function runTest(test: Test | Custom, runner: VitestRunner): Promis
271271
failTask(test.result, e, runner.config.diffOptions)
272272
}
273273

274+
try {
275+
await callTaskHooks(test, test.onFinished || [], 'stack')
276+
}
277+
catch (e) {
278+
failTask(test.result, e, runner.config.diffOptions)
279+
}
280+
281+
if (test.result.state === 'fail') {
282+
try {
283+
await callTaskHooks(
284+
test,
285+
test.onFailed || [],
286+
runner.config.sequence.hooks,
287+
)
288+
}
289+
catch (e) {
290+
failTask(test.result, e, runner.config.diffOptions)
291+
}
292+
}
293+
274294
if (test.result.state === 'pass') {
275295
break
276296
}
@@ -286,26 +306,6 @@ export async function runTest(test: Test | Custom, runner: VitestRunner): Promis
286306
}
287307
}
288308

289-
try {
290-
await callTaskHooks(test, test.onFinished || [], 'stack')
291-
}
292-
catch (e) {
293-
failTask(test.result, e, runner.config.diffOptions)
294-
}
295-
296-
if (test.result.state === 'fail') {
297-
try {
298-
await callTaskHooks(
299-
test,
300-
test.onFailed || [],
301-
runner.config.sequence.hooks,
302-
)
303-
}
304-
catch (e) {
305-
failTask(test.result, e, runner.config.diffOptions)
306-
}
307-
}
308-
309309
// if test is marked to be failed, flip the result
310310
if (test.fails) {
311311
if (test.result.state === 'pass') {

0 commit comments

Comments
 (0)