@@ -5,6 +5,7 @@ import type { ViteDevServer } from 'vite'
55import type { defineWorkspace } from 'vitest/config'
66import type { SerializedCoverageConfig } from '../runtime/config'
77import type { ArgumentsType , ProvidedContext , UserConsoleLog } from '../types/general'
8+ import type { CliOptions } from './cli/cli-api'
89import type { ProcessPool , WorkspaceSpec } from './pool'
910import type { TestSpecification } from './spec'
1011import type { ResolvedConfig , TestProjectConfiguration , UserConfig , VitestRunMode } from './types/config'
@@ -97,7 +98,7 @@ export class Vitest {
9798 resolvedProjects : TestProject [ ] = [ ]
9899 /** @internal */ _browserLastPort = defaultBrowserPort
99100 /** @internal */ _browserSessions = new BrowserSessions ( )
100- /** @internal */ _options : UserConfig = { }
101+ /** @internal */ _cliOptions : CliOptions = { }
101102 /** @internal */ reporters : Reporter [ ] = [ ]
102103 /** @internal */ vitenode : ViteNodeServer = undefined !
103104 /** @internal */ runner : ViteNodeRunner = undefined !
@@ -118,8 +119,10 @@ export class Vitest {
118119
119120 constructor (
120121 public readonly mode : VitestRunMode ,
122+ cliOptions : UserConfig ,
121123 options : VitestOptions = { } ,
122124 ) {
125+ this . _cliOptions = cliOptions
123126 this . logger = new Logger ( this , options . stdout , options . stderr )
124127 this . packageInstaller = options . packageInstaller || new VitestPackageInstaller ( )
125128 this . specifications = new VitestSpecifications ( this )
@@ -192,13 +195,12 @@ export class Vitest {
192195 }
193196
194197 /** @deprecated internal */
195- setServer ( options : UserConfig , server : ViteDevServer , cliOptions : UserConfig ) : Promise < void > {
196- return this . _setServer ( options , server , cliOptions )
198+ setServer ( options : UserConfig , server : ViteDevServer ) : Promise < void > {
199+ return this . _setServer ( options , server )
197200 }
198201
199202 /** @internal */
200- async _setServer ( options : UserConfig , server : ViteDevServer , cliOptions : UserConfig ) {
201- this . _options = options
203+ async _setServer ( options : UserConfig , server : ViteDevServer ) {
202204 this . watcher . unregisterWatcher ( )
203205 clearTimeout ( this . _rerunTimer )
204206 this . restartsCount += 1
@@ -274,7 +276,7 @@ export class Vitest {
274276 }
275277 catch { }
276278
277- const projects = await this . resolveWorkspace ( cliOptions )
279+ const projects = await this . resolveWorkspace ( this . _cliOptions )
278280 this . resolvedProjects = projects
279281 this . projects = projects
280282
@@ -287,7 +289,7 @@ export class Vitest {
287289 } ) )
288290 } ) )
289291
290- if ( options . browser ?. enabled ) {
292+ if ( this . _cliOptions . browser ?. enabled ) {
291293 const browserProjects = this . projects . filter ( p => p . config . browser . enabled )
292294 if ( ! browserProjects . length ) {
293295 throw new Error ( `Vitest received --browser flag, but no project had a browser configuration.` )
@@ -327,7 +329,7 @@ export class Vitest {
327329 const currentNames = new Set ( this . projects . map ( p => p . name ) )
328330 const workspace = await resolveWorkspace (
329331 this ,
330- this . _options ,
332+ this . _cliOptions ,
331333 undefined ,
332334 Array . isArray ( config ) ? config : [ config ] ,
333335 currentNames ,
@@ -1308,7 +1310,7 @@ export class Vitest {
13081310 * Check if the project with a given name should be included.
13091311 */
13101312 matchesProjectFilter ( name : string ) : boolean {
1311- const projects = this . _config ?. project || this . _options ?. project
1313+ const projects = this . _config ?. project || this . _cliOptions ?. project
13121314 // no filters applied, any project can be included
13131315 if ( ! projects || ! projects . length ) {
13141316 return true
0 commit comments