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
5 changes: 4 additions & 1 deletion packages/vitest/src/node/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,11 @@ export class Vitest {
'testTimeout',
'pool',
'globals',
'mode',
'expandSnapshotDiff',
'retry',
'testNamePattern',
'passWithNoTests',
'bail',
] as const

const cliOverrides = overridesOptions.reduce((acc, name) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function initializeProject(workspacePath: string | number, ctx: Vit
logLevel: 'error',
configFile,
// this will make "mode": "test" | "benchmark" inside defineConfig
mode: options.mode || ctx.config.mode,
mode: options.test?.mode || options.mode || ctx.config.mode,
plugins: [
...options.plugins || [],
WorkspaceVitestPlugin(project, { ...options, root, workspacePath }),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { it, expect } from 'vitest';

it('math', () => {
expect(1).toBe(1)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {}
1 change: 1 addition & 0 deletions test/config/fixtures/workspace-flags/vitest.workspace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default ['projects']
38 changes: 38 additions & 0 deletions test/config/test/flags.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { expect, it } from 'vitest'
import { runVitest } from '../../test-utils'

it('correctly inherit from the cli', async () => {
const { vitest } = await runVitest({
root: 'fixtures/workspace-flags',
logHeapUsage: true,
allowOnly: true,
sequence: {
seed: 123,
},
testTimeout: 5321,
pool: 'forks',
globals: true,
expandSnapshotDiff: true,
retry: 6,
testNamePattern: 'math',
passWithNoTests: true,
bail: 100,
})
const project = vitest!.projects[0]
const config = project.getSerializableConfig()
expect(config).toMatchObject({
logHeapUsage: true,
allowOnly: true,
sequence: expect.objectContaining({
seed: 123,
}),
testTimeout: 5321,
pool: 'forks',
globals: true,
expandSnapshotDiff: true,
retry: 6,
passWithNoTests: true,
bail: 100,
})
expect(config.testNamePattern?.test('math')).toBe(true)
})