Skip to content

Commit

Permalink
fix(typecheck): fix suite collection while-loop (#5065)
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa authored Jan 30, 2024
1 parent 8110540 commit 35675bd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/vitest/src/typecheck/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ export async function collectTests(ctx: WorkspaceProject, filepath: string): Pro
})
let lastSuite: ParsedSuite = file
const updateLatestSuite = (index: number) => {
const suite = lastSuite
while (lastSuite !== file && lastSuite.end < index)
lastSuite = suite.suite as ParsedSuite
while (lastSuite.suite && lastSuite.end < index)
lastSuite = lastSuite.suite as ParsedSuite
return lastSuite
}
definitions.sort((a, b) => a.start - b.start).forEach((definition) => {
Expand Down
11 changes: 11 additions & 0 deletions test/typescript/test-d/nested-suite1.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { describe, test } from 'vitest'

describe('suite-A', () => {
describe('suite-B', () => {
test('case-X', () => {
})
})
})

test('case-Y', () => {
})
18 changes: 18 additions & 0 deletions test/typescript/test-d/nested-suite2.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { describe, test } from 'vitest'

describe('suite-A', () => {
describe('suite-B', () => {
test('case-X', () => {
})

describe('suite-C', () => {
test('case-Y', () => {
})
})
})

describe('suite-D', () => {
test('case-Z', () => {
})
})
})

0 comments on commit 35675bd

Please sign in to comment.