Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/vitest/src/node/ast-collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function astParseFile(filepath: string, code: string) {
const property = callee?.property?.name
let mode = !property || property === name ? 'run' : property
// they will be picked up in the next iteration
if (['each', 'for', 'skipIf', 'runIf', 'extend', 'scoped'].includes(mode)) {
if (['each', 'for', 'skipIf', 'runIf', 'extend', 'scoped', 'override'].includes(mode)) {
return
}

Expand Down
51 changes: 51 additions & 0 deletions test/cli/test/static-collect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,57 @@ test('collects nested suites with custom test functions', async () => {
`)
})

test('ignores test.scoped and test.override', async () => {
const testModule = await collectTests(`
import { test as base } from 'vitest'

const test = base.extend({
fixture: async ({}, use) => {
await use('value')
},
})

test.scoped({ fixture: 'value' })
test.override({ fixture: 'value' })

describe('extended tests', () => {
test('uses extended test', () => {})
test.skip('skips extended test', () => {})
test.only('only extended test', () => {})
})
`)
expect(testModule).toMatchInlineSnapshot(`
{
"extended tests": {
"only extended test": {
"errors": [],
"fullName": "extended tests > only extended test",
"id": "-1732721377_0_2",
"location": "16:6",
"mode": "run",
"state": "pending",
},
"skips extended test": {
"errors": [],
"fullName": "extended tests > skips extended test",
"id": "-1732721377_0_1",
"location": "15:6",
"mode": "skip",
"state": "skipped",
},
"uses extended test": {
"errors": [],
"fullName": "extended tests > uses extended test",
"id": "-1732721377_0_0",
"location": "14:6",
"mode": "skip",
"state": "skipped",
},
},
}
`)
})

test('collects tests from test.extend', async () => {
const testModule = await collectTests(`
import { test as base } from 'vitest'
Expand Down
Loading