diff --git a/packages/vitest/src/constants.ts b/packages/vitest/src/constants.ts index 0de9c876a2e6..71437653e236 100644 --- a/packages/vitest/src/constants.ts +++ b/packages/vitest/src/constants.ts @@ -50,7 +50,7 @@ export const configDefaults: UserConfig = Object.freeze({ watchIgnore: [/\/node_modules\//, /\/dist\//], update: false, run: !!process.env.CI, - watch: false, + watch: !process.env.CI, reporters: 'default', silent: false, api: false, diff --git a/packages/vitest/src/node/cli.ts b/packages/vitest/src/node/cli.ts index da2da4b803ee..e9b7de56708c 100644 --- a/packages/vitest/src/node/cli.ts +++ b/packages/vitest/src/node/cli.ts @@ -35,7 +35,7 @@ cli cli .command('run [...filters]') - .action(runInRunMode) + .action((cliFilters: string[], argv: UserConfig) => run(cliFilters, { ...argv, run: true, watch: false })) cli .command('related [...filters]') @@ -55,10 +55,6 @@ cli cli.parse() -async function runInRunMode(cliFilters: string[], argv: UserConfig) { - await run(cliFilters, { ...argv, run: true }) -} - async function runRelated(relatedFiles: string[] | string, argv: UserConfig) { argv.related = relatedFiles argv.passWithNoTests ??= true diff --git a/packages/vitest/src/node/plugins/index.ts b/packages/vitest/src/node/plugins/index.ts index 8c4c2a3654f7..b9ef3402ce06 100644 --- a/packages/vitest/src/node/plugins/index.ts +++ b/packages/vitest/src/node/plugins/index.ts @@ -56,7 +56,7 @@ export async function VitestPlugin(options: UserConfig = {}, ctx = new Vitest()) options, ) options.api = resolveApiConfig(options) - options.watch = !options.run + options.watch &&= !options.run }, async configureServer(server) { if (haveStarted)