1
1
import type { UserConfig as ViteUserConfig } from 'vite'
2
2
import type { UserConfig } from 'vitest/node'
3
3
import type { VitestRunnerCLIOptions } from '../../test-utils'
4
+ import { cpus } from 'node:os'
4
5
import { normalize , resolve } from 'pathe'
5
-
6
6
import { beforeEach , expect , test } from 'vitest'
7
7
import { version } from 'vitest/package.json'
8
8
import * as testUtils from '../../test-utils'
@@ -12,7 +12,7 @@ const names = ['edge', 'chromium', 'webkit', 'chrome', 'firefox', 'safari'] as c
12
12
const browsers = providers . map ( provider => names . map ( name => ( { name, provider } ) ) ) . flat ( )
13
13
14
14
function 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 )
16
16
}
17
17
18
18
function runVitestCli ( ...cliArgs : string [ ] ) {
@@ -553,3 +553,23 @@ test('non existing project name array will throw', async () => {
553
553
const { stderr } = await runVitest ( { project : [ 'non-existing-project' , 'also-non-existing' ] } )
554
554
expect ( stderr ) . toMatch ( 'No projects matched the filter "non-existing-project", "also-non-existing".' )
555
555
} )
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