-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1afd26
commit 9fbb8d3
Showing
42 changed files
with
487 additions
and
543 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,82 @@ | ||
import { expect, test } from 'vitest' | ||
import type { UserConfig } from 'vitest/config' | ||
import { version } from 'vitest/package.json' | ||
|
||
import { runVitest } from './utils' | ||
import * as testUtils from '../../test-utils' | ||
|
||
function runVitest(config: NonNullable<UserConfig['test']> & { shard?: any }) { | ||
return testUtils.runVitest(config, ['fixtures/test/']) | ||
} | ||
|
||
function runVitestCli(...cliArgs: string[]) { | ||
return testUtils.runVitestCli('run', 'fixtures/test/', ...cliArgs) | ||
} | ||
|
||
test('shard cannot be used with watch mode', async () => { | ||
const { error } = await runVitest('watch', ['--shard', '1/2']) | ||
const { stderr } = await runVitest({ watch: true, shard: '1/2' }) | ||
|
||
expect(error).toMatch('Error: You cannot use --shard option with enabled watch') | ||
expect(stderr).toMatch('Error: You cannot use --shard option with enabled watch') | ||
}) | ||
|
||
test('shard must be positive number', async () => { | ||
const { error } = await runVitest('run', ['--shard', '"-1"']) | ||
const { stderr } = await runVitest({ shard: '-1' }) | ||
|
||
expect(error).toMatch('Error: --shard <count> must be a positive number') | ||
expect(stderr).toMatch('Error: --shard <count> must be a positive number') | ||
}) | ||
|
||
test('shard index must be smaller than count', async () => { | ||
const { error } = await runVitest('run', ['--shard', '2/1']) | ||
const { stderr } = await runVitest({ shard: '2/1' }) | ||
|
||
expect(error).toMatch('Error: --shard <index> must be a positive number less then <count>') | ||
expect(stderr).toMatch('Error: --shard <index> must be a positive number less then <count>') | ||
}) | ||
|
||
test('inspect requires changing threads or singleThread', async () => { | ||
const { error } = await runVitest('run', ['--inspect']) | ||
const { stderr } = await runVitest({ inspect: true }) | ||
|
||
expect(error).toMatch('Error: You cannot use --inspect without "threads: false" or "singleThread: true"') | ||
expect(stderr).toMatch('Error: You cannot use --inspect without "threads: false" or "singleThread: true"') | ||
}) | ||
|
||
test('inspect cannot be used with threads', async () => { | ||
const { error } = await runVitest('run', ['--inspect', '--threads', 'true']) | ||
const { stderr } = await runVitest({ inspect: true, threads: true }) | ||
|
||
expect(error).toMatch('Error: You cannot use --inspect without "threads: false" or "singleThread: true"') | ||
expect(stderr).toMatch('Error: You cannot use --inspect without "threads: false" or "singleThread: true"') | ||
}) | ||
|
||
test('inspect-brk cannot be used with threads', async () => { | ||
const { error } = await runVitest('run', ['--inspect-brk', '--threads', 'true']) | ||
const { stderr } = await runVitest({ inspectBrk: true, threads: true }) | ||
|
||
expect(error).toMatch('Error: You cannot use --inspect-brk without "threads: false" or "singleThread: true"') | ||
expect(stderr).toMatch('Error: You cannot use --inspect-brk without "threads: false" or "singleThread: true"') | ||
}) | ||
|
||
test('c8 coverage provider cannot be used with browser', async () => { | ||
const { error } = await runVitest('run', ['--coverage.enabled', '--browser']) | ||
const { stderr } = await runVitest({ coverage: { enabled: true }, browser: { enabled: true, name: 'chrome' } }) | ||
|
||
expect(stderr).toMatch('Error: @vitest/coverage-c8 does not work with --browser. Use @vitest/coverage-istanbul instead') | ||
}) | ||
|
||
expect(error).toMatch('Error: @vitest/coverage-c8 does not work with --browser. Use @vitest/coverage-istanbul instead') | ||
test('version number is printed when coverage provider fails to load', async () => { | ||
const { stderr, stdout } = await runVitest({ | ||
coverage: { | ||
enabled: true, | ||
provider: 'custom', | ||
customProviderModule: './non-existing-module.ts', | ||
}, | ||
}) | ||
|
||
expect(stdout).toMatch(`RUN v${version}`) | ||
expect(stderr).toMatch('Error: Failed to load custom CoverageProviderModule from ./non-existing-module.ts') | ||
}) | ||
|
||
test('boolean coverage flag without dot notation, with more dot notation options', async () => { | ||
const { error } = await runVitest('run', ['--coverage', '--coverage.reporter', 'text']) | ||
const { stderr } = await runVitestCli('--coverage', '--coverage.reporter', 'text') | ||
|
||
expect(error).toMatch('Error: A boolean argument "--coverage" was used with dot notation arguments "--coverage.reporter".') | ||
expect(error).toMatch('Please specify the "--coverage" argument with dot notation as well: "--coverage.enabled"') | ||
expect(stderr).toMatch('Error: A boolean argument "--coverage" was used with dot notation arguments "--coverage.reporter".') | ||
expect(stderr).toMatch('Please specify the "--coverage" argument with dot notation as well: "--coverage.enabled"') | ||
}) | ||
|
||
test('boolean browser flag without dot notation, with more dot notation options', async () => { | ||
const { error } = await runVitest('run', ['--browser', '--browser.name', 'chrome']) | ||
|
||
expect(error).toMatch('Error: A boolean argument "--browser" was used with dot notation arguments "--browser.name".') | ||
expect(error).toMatch('Please specify the "--browser" argument with dot notation as well: "--browser.enabled"') | ||
}) | ||
const { stderr } = await runVitestCli('run', '--browser', '--browser.name', 'chrome') | ||
|
||
test('version number is printed when coverage provider fails to load', async () => { | ||
const { error, output } = await runVitest('run', [ | ||
'--coverage.enabled', | ||
'--coverage.provider', | ||
'custom', | ||
'--coverage.customProviderModule', | ||
'./non-existing-module.ts', | ||
]) | ||
|
||
expect(output).toMatch(`RUN v${version}`) | ||
expect(error).toMatch('Error: Failed to load custom CoverageProviderModule from ./non-existing-module.ts') | ||
expect(stderr).toMatch('Error: A boolean argument "--browser" was used with dot notation arguments "--browser.name".') | ||
expect(stderr).toMatch('Please specify the "--browser" argument with dot notation as well: "--browser.enabled"') | ||
}) |
Oops, something went wrong.