@@ -5,6 +5,7 @@ import type { ViteDevServer } from 'vite'
5
5
import type { defineWorkspace } from 'vitest/config'
6
6
import type { SerializedCoverageConfig } from '../runtime/config'
7
7
import type { ArgumentsType , ProvidedContext , UserConsoleLog } from '../types/general'
8
+ import type { CliOptions } from './cli/cli-api'
8
9
import type { ProcessPool , WorkspaceSpec } from './pool'
9
10
import type { TestSpecification } from './spec'
10
11
import type { ResolvedConfig , TestProjectConfiguration , UserConfig , VitestRunMode } from './types/config'
@@ -97,7 +98,7 @@ export class Vitest {
97
98
resolvedProjects : TestProject [ ] = [ ]
98
99
/** @internal */ _browserLastPort = defaultBrowserPort
99
100
/** @internal */ _browserSessions = new BrowserSessions ( )
100
- /** @internal */ _options : UserConfig = { }
101
+ /** @internal */ _cliOptions : CliOptions = { }
101
102
/** @internal */ reporters : Reporter [ ] = [ ]
102
103
/** @internal */ vitenode : ViteNodeServer = undefined !
103
104
/** @internal */ runner : ViteNodeRunner = undefined !
@@ -118,8 +119,10 @@ export class Vitest {
118
119
119
120
constructor (
120
121
public readonly mode : VitestRunMode ,
122
+ cliOptions : UserConfig ,
121
123
options : VitestOptions = { } ,
122
124
) {
125
+ this . _cliOptions = cliOptions
123
126
this . logger = new Logger ( this , options . stdout , options . stderr )
124
127
this . packageInstaller = options . packageInstaller || new VitestPackageInstaller ( )
125
128
this . specifications = new VitestSpecifications ( this )
@@ -192,13 +195,12 @@ export class Vitest {
192
195
}
193
196
194
197
/** @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 )
197
200
}
198
201
199
202
/** @internal */
200
- async _setServer ( options : UserConfig , server : ViteDevServer , cliOptions : UserConfig ) {
201
- this . _options = options
203
+ async _setServer ( options : UserConfig , server : ViteDevServer ) {
202
204
this . watcher . unregisterWatcher ( )
203
205
clearTimeout ( this . _rerunTimer )
204
206
this . restartsCount += 1
@@ -274,7 +276,7 @@ export class Vitest {
274
276
}
275
277
catch { }
276
278
277
- const projects = await this . resolveProjects ( cliOptions )
279
+ const projects = await this . resolveProjects ( this . _cliOptions )
278
280
this . resolvedProjects = projects
279
281
this . projects = projects
280
282
@@ -287,7 +289,7 @@ export class Vitest {
287
289
} ) )
288
290
} ) )
289
291
290
- if ( options . browser ?. enabled ) {
292
+ if ( this . _cliOptions . browser ?. enabled ) {
291
293
const browserProjects = this . projects . filter ( p => p . config . browser . enabled )
292
294
if ( ! browserProjects . length ) {
293
295
throw new Error ( `Vitest received --browser flag, but no project had a browser configuration.` )
@@ -327,7 +329,7 @@ export class Vitest {
327
329
const currentNames = new Set ( this . projects . map ( p => p . name ) )
328
330
const projects = await resolveProjects (
329
331
this ,
330
- this . _options ,
332
+ this . _cliOptions ,
331
333
undefined ,
332
334
Array . isArray ( config ) ? config : [ config ] ,
333
335
currentNames ,
@@ -1335,7 +1337,7 @@ export class Vitest {
1335
1337
* Check if the project with a given name should be included.
1336
1338
*/
1337
1339
matchesProjectFilter ( name : string ) : boolean {
1338
- const projects = this . _config ?. project || this . _options ?. project
1340
+ const projects = this . _config ?. project || this . _cliOptions ?. project
1339
1341
// no filters applied, any project can be included
1340
1342
if ( ! projects || ! projects . length ) {
1341
1343
return true
0 commit comments