Skip to content

Commit 35675bd

Browse files
authoredJan 30, 2024
fix(typecheck): fix suite collection while-loop (#5065)
1 parent 8110540 commit 35675bd

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed
 

‎packages/vitest/src/typecheck/collect.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ export async function collectTests(ctx: WorkspaceProject, filepath: string): Pro
9999
})
100100
let lastSuite: ParsedSuite = file
101101
const updateLatestSuite = (index: number) => {
102-
const suite = lastSuite
103-
while (lastSuite !== file && lastSuite.end < index)
104-
lastSuite = suite.suite as ParsedSuite
102+
while (lastSuite.suite && lastSuite.end < index)
103+
lastSuite = lastSuite.suite as ParsedSuite
105104
return lastSuite
106105
}
107106
definitions.sort((a, b) => a.start - b.start).forEach((definition) => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { describe, test } from 'vitest'
2+
3+
describe('suite-A', () => {
4+
describe('suite-B', () => {
5+
test('case-X', () => {
6+
})
7+
})
8+
})
9+
10+
test('case-Y', () => {
11+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { describe, test } from 'vitest'
2+
3+
describe('suite-A', () => {
4+
describe('suite-B', () => {
5+
test('case-X', () => {
6+
})
7+
8+
describe('suite-C', () => {
9+
test('case-Y', () => {
10+
})
11+
})
12+
})
13+
14+
describe('suite-D', () => {
15+
test('case-Z', () => {
16+
})
17+
})
18+
})

0 commit comments

Comments
 (0)
Please sign in to comment.