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/projects/resolveProjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ async function resolveTestProjectConfigs(

for (const definition of projectsDefinition) {
if (typeof definition === 'string') {
const stringOption = definition.replace('<rootDir>', parentConfig.root)
const stringOption = definition.replace('<rootDir>', () => parentConfig.root)
// if the string doesn't contain a glob, we can resolve it directly
// ['./vitest.config.js']
if (!isDynamicPattern(stringOption)) {
Expand Down
17 changes: 16 additions & 1 deletion test/e2e/test/projects.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Vitest } from 'vitest/node'
import type { TestFsStructure } from '#test-utils'
import { relative, resolve } from 'pathe'
import { describe, expect, it } from 'vitest'
import { runInlineTests, runVitest, ts } from '#test-utils'
import { runInlineTests, runVitest, ts, useFS } from '#test-utils'

it('runs the workspace if there are several vitest config files', async () => {
const { stderr, stdout } = await runVitest({
Expand All @@ -25,6 +25,21 @@ it('correctly resolves workspace projects with a several folder globs', async ()
expect(stdout).toContain('test - b')
})

it('preserves replacement patterns in the root directory of project definitions', async () => {
const fs = useFS(resolve(process.cwd(), "vitest-test-$&-$'-$`"), {
'vitest.config.js': {
test: {
projects: ['<rootDir>/project'],
},
},
'project/basic.test.js': `import { test } from 'vitest'; test('runs', () => {})`,
})
const { stderr, ctx } = await runVitest({ root: fs.root })

expect(stderr).toBe('')
expect(ctx!.projects.map((project) => project.config.root)).toEqual([resolve(fs.root, 'project')])
})

it('supports glob negation pattern', async () => {
const { stderr, stdout } = await runVitest({
root: 'fixtures/workspace/negated',
Expand Down
Loading