Skip to content

Commit cc73597

Browse files
authored
fix(runner): mark repeated tests as finished on last run (#9707)
1 parent 0bd2bb4 commit cc73597

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

packages/runner/src/run.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -658,12 +658,7 @@ export async function runTest(test: Test, runner: VitestRunner): Promise<void> {
658658
})
659659

660660
if (test.result!.state !== 'fail') {
661-
if (!test.repeats) {
662-
test.result!.state = 'pass'
663-
}
664-
else if (test.repeats && retry === retryCount) {
665-
test.result!.state = 'pass'
666-
}
661+
test.result!.state = 'pass'
667662
}
668663
}
669664
catch (e) {

test/cli/fixtures/reported-tasks/1_first.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ it('registers a metadata', (ctx) => {
8686
ctx.task.meta.key = 'value'
8787
})
8888

89+
it('should not show up as pending test when finished (#9689)', { retry: 2, repeats: 2 }, ({ task }) => {
90+
expect(task.result?.state).toBe('run')
91+
})
92+
8993
declare module 'vitest' {
9094
interface TaskMeta {
9195
key?: string

test/cli/test/reported-tasks.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ it('correctly reports a file', ({ testModule, files, project }) => {
7676
expect(testModule.location).toBeUndefined()
7777
expect(testModule.moduleId).toBe(resolve(root, './1_first.test.ts'))
7878
expect(testModule.project).toBe(project)
79-
expect(testModule.children.size).toBe(17)
79+
expect(testModule.children.size).toBe(18)
8080

8181
const tests = [...testModule.children.tests()]
82-
expect(tests).toHaveLength(12)
82+
expect(tests).toHaveLength(13)
8383
const deepTests = [...testModule.children.allTests()]
84-
expect(deepTests).toHaveLength(22)
84+
expect(deepTests).toHaveLength(23)
8585

8686
expect.soft([...testModule.children.allTests('skipped')]).toHaveLength(8)
87-
expect.soft([...testModule.children.allTests('passed')]).toHaveLength(9)
87+
expect.soft([...testModule.children.allTests('passed')]).toHaveLength(10)
8888
expect.soft([...testModule.children.allTests('failed')]).toHaveLength(5)
8989
expect.soft([...testModule.children.allTests('pending')]).toHaveLength(0)
9090

0 commit comments

Comments
 (0)