forked from vitest-dev/vitest
/
failures.test.ts
73 lines (52 loc) · 3.01 KB
/
failures.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import { expect, test } from 'vitest'
import { version } from 'vitest/package.json'
import { runVitest } from './utils'
test('shard cannot be used with watch mode', async () => {
const { error } = await runVitest('watch', ['--shard', '1/2'])
expect(error).toMatch('Error: You cannot use --shard option with enabled watch')
})
test('shard must be positive number', async () => {
const { error } = await runVitest('run', ['--shard', '"-1"'])
expect(error).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'])
expect(error).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'])
expect(error).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'])
expect(error).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'])
expect(error).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'])
expect(error).toMatch('Error: @vitest/coverage-c8 does not work with --browser. Use @vitest/coverage-istanbul instead')
})
test('boolean coverage flag without dot notation, with more dot notation options', async () => {
const { error } = await runVitest('run', ['--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"')
})
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"')
})
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')
})