11import type { UserConfig as ViteUserConfig } from 'vite'
22import type { UserConfig } from 'vitest/node'
33import type { VitestRunnerCLIOptions } from '../../test-utils'
4+ import { cpus } from 'node:os'
45import { normalize , resolve } from 'pathe'
5-
66import { beforeEach , expect , test } from 'vitest'
77import { version } from 'vitest/package.json'
88import * as testUtils from '../../test-utils'
@@ -12,7 +12,7 @@ const names = ['edge', 'chromium', 'webkit', 'chrome', 'firefox', 'safari'] as c
1212const browsers = providers . map ( provider => names . map ( name => ( { name, provider } ) ) ) . flat ( )
1313
1414function runVitest ( config : NonNullable < UserConfig > & { shard ?: any } , viteOverrides : ViteUserConfig = { } , runnerOptions ?: VitestRunnerCLIOptions ) {
15- return testUtils . runVitest ( { root : './fixtures/test' , ...config } , [ ] , undefined , viteOverrides , runnerOptions )
15+ return testUtils . runVitest ( { root : './fixtures/test' , include : [ 'example.test.ts' ] , ...config } , [ ] , undefined , viteOverrides , runnerOptions )
1616}
1717
1818function runVitestCli ( ...cliArgs : string [ ] ) {
@@ -553,3 +553,23 @@ test('non existing project name array will throw', async () => {
553553 const { stderr } = await runVitest ( { project : [ 'non-existing-project' , 'also-non-existing' ] } )
554554 expect ( stderr ) . toMatch ( 'No projects matched the filter "non-existing-project", "also-non-existing".' )
555555} )
556+
557+ test ( 'minWorkers must be smaller than maxWorkers' , async ( ) => {
558+ const { stderr } = await runVitest ( { minWorkers : 2 , maxWorkers : 1 } )
559+
560+ expect ( stderr ) . toMatch ( 'RangeError: options.minThreads and options.maxThreads must not conflict' )
561+ } )
562+
563+ test ( 'minWorkers higher than maxWorkers does not crash' , async ( { skip } ) => {
564+ skip ( cpus ( ) . length < 2 , 'Test requires +2 CPUs' )
565+
566+ const { stdout, stderr } = await runVitest ( {
567+ maxWorkers : 1 ,
568+
569+ // Overrides defaults of "runVitest" of "test-utils"
570+ minWorkers : undefined ,
571+ } )
572+
573+ expect ( stdout ) . toMatch ( '✓ example.test.ts > it works' )
574+ expect ( stderr ) . toBe ( '' )
575+ } )
0 commit comments