|
| 1 | +import type { InlineConfig } from 'vitest' |
| 2 | +import { expect, test } from 'vitest' |
| 3 | +import { runVitest } from '../../test-utils' |
| 4 | + |
| 5 | +function run(sequence: InlineConfig['sequence']) { |
| 6 | + return runVitest({ |
| 7 | + sequence, |
| 8 | + include: [], |
| 9 | + }) |
| 10 | +} |
| 11 | + |
| 12 | +class CustomSequencer { |
| 13 | + sort() { |
| 14 | + return [] |
| 15 | + } |
| 16 | + |
| 17 | + shard() { |
| 18 | + return [] |
| 19 | + } |
| 20 | +} |
| 21 | + |
| 22 | +test.each([ |
| 23 | + false, |
| 24 | + { files: false, tests: false }, |
| 25 | + { files: false, tests: true }, |
| 26 | +], |
| 27 | +)('should use BaseSequencer if shuffle is %o', async (shuffle) => { |
| 28 | + const { vitest } = await run({ shuffle }) |
| 29 | + expect(vitest?.config.sequence.sequencer.name).toBe('BaseSequencer') |
| 30 | +}) |
| 31 | + |
| 32 | +test.each([ |
| 33 | + true, |
| 34 | + { files: true, tests: false }, |
| 35 | + { files: true, tests: true }, |
| 36 | +])('should use RandomSequencer if shuffle is %o', async (shuffle) => { |
| 37 | + const { vitest } = await run({ shuffle }) |
| 38 | + expect(vitest?.config.sequence.sequencer.name).toBe('RandomSequencer') |
| 39 | +}) |
| 40 | + |
| 41 | +test.each([ |
| 42 | + false, |
| 43 | + true, |
| 44 | + { files: true, tests: false }, |
| 45 | + { files: true, tests: true }, |
| 46 | +])('should always use CustomSequencer if passed', async (shuffle) => { |
| 47 | + const { vitest } = await run({ shuffle, sequencer: CustomSequencer }) |
| 48 | + expect(vitest?.config.sequence.sequencer.name).toBe('CustomSequencer') |
| 49 | +}) |
0 commit comments