Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions docs/.vitepress/scripts/cli-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const skipConfig = new Set([
'coverage.thresholds.lines',
'standalone',
'clearScreen',
'configRunner',
'color',
'run',
'hideSkippedTests',
Expand Down
1 change: 1 addition & 0 deletions packages/browser/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export async function createBrowserServer(
},
},
mode: project.config.mode,
configLoader: project.config.configLoader,
configFile: configPath,
// watch is handled by Vitest
server: {
Expand Down
5 changes: 5 additions & 0 deletions packages/vitest/src/node/cli/cli-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,11 @@ export const cliOptionsConfig: VitestCLIOptions = {
description:
'Clear terminal screen when re-running tests during watch mode (default: `true`)',
},
configLoader: {
description:
'Use `bundle` to bundle the config with esbuild or `runner` (experimental) to process it on the fly (default: `bundle`)',
argument: '<loader>',
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

documentation should also mention this is only available from newer Vite version.

standalone: {
description:
'Start Vitest without running tests. File filters will be ignored, tests will be running only on change (default: `false`)',
Expand Down
1 change: 1 addition & 0 deletions packages/vitest/src/node/config/resolveConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export function resolveConfig(
}

resolved.clearScreen = resolved.clearScreen ?? viteConfig.clearScreen ?? true
resolved.configLoader = resolved.configLoader ?? viteConfig.inlineConfig.configLoader ?? 'bundle'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am actually unsure about this part. Not sure if this is needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I commented in #7574 (review), configLoader is something meaningful before resolving config, so it's likely we don't need to care about and thus should be removed.


if (options.shard) {
if (resolved.watch) {
Expand Down
1 change: 1 addition & 0 deletions packages/vitest/src/node/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export async function createVitest(

const config: ViteInlineConfig = {
configFile: configPath,
configLoader: options.configLoader,
// this will make "mode": "test" | "benchmark" inside defineConfig
mode: options.mode || mode,
plugins: await VitestPlugin(options, ctx),
Expand Down
1 change: 1 addition & 0 deletions packages/vitest/src/node/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ export async function initializeProject(
const config: ViteInlineConfig = {
...restOptions,
configFile,
configLoader: options.test?.configLoader,
// this will make "mode": "test" | "benchmark" inside defineConfig
mode: options.test?.mode || options.mode || ctx.config.mode,
plugins: [
Expand Down
8 changes: 8 additions & 0 deletions packages/vitest/src/node/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ export interface InlineConfig {
*/
minWorkers?: number | string

/** @experimental */
configLoader?: 'bundle' | 'runner' | 'native'

/**
* Should all test files run in parallel. Doesn't affect tests running in the same file.
* Setting this to `false` will override `maxWorkers` and `minWorkers` options to `1`.
Expand Down Expand Up @@ -945,6 +948,11 @@ export interface UserConfig extends InlineConfig {
*/
clearScreen?: boolean

/**
* Override vite config's configLoader from cli
*/
configLoader?: 'bundle' | 'runner' | 'native'

/**
* benchmark.compare option exposed at the top level for cli
*/
Expand Down
Loading