|
| 1 | +import { expect, test } from 'vitest' |
| 2 | +import * as testUtils from '../../test-utils' |
| 3 | + |
| 4 | +test.each([ |
| 5 | + { expectedMode: 'test', command: ['run'] }, |
| 6 | + { expectedMode: 'benchmark', command: ['bench', '--run'] }, |
| 7 | +])(`env.mode should have the $expectedMode value when running in $name mode`, async ({ command, expectedMode }) => { |
| 8 | + const { stdout } = await testUtils.runVitestCli(...(command), 'fixtures/mode', '-c', `fixtures/mode/vitest.${expectedMode}.config.ts`) |
| 9 | + |
| 10 | + expect(stdout).toContain(`✓ fixtures/mode/example.${expectedMode}.ts`) |
| 11 | +}) |
| 12 | + |
| 13 | +test.each([ |
| 14 | + { expectedMode: 'test', command: ['bench', '--run'], actualMode: 'benchmark' }, |
| 15 | + { expectedMode: 'benchmark', command: ['run'], actualMode: 'test' }, |
| 16 | +])(`should return error if actual mode $actualMode is different than expected mode $expectedMode`, async ({ command, expectedMode, actualMode }) => { |
| 17 | + const { stdout, stderr } = await testUtils.runVitestCli(...(command), 'fixtures/mode', '-c', `fixtures/mode/vitest.${expectedMode}.config.ts`) |
| 18 | + |
| 19 | + expect(stderr).toContain(`env.mode: ${actualMode}`) |
| 20 | + expect(stderr).toContain('⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯') |
| 21 | + expect(stderr).toContain(`Error: env.mode should be equal to "${expectedMode}"`) |
| 22 | + expect(stdout).toBe('') |
| 23 | +}) |
0 commit comments