-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: config errors not visible (#2995)
- Loading branch information
1 parent
c44e5af
commit f01c783
Showing
7 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { expect, test } from 'vitest' | ||
|
||
test('it works', () => { | ||
expect(true).toBe(true) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "@vitest/test-config", | ||
"private": true, | ||
"scripts": { | ||
"test": "vitest run test/**" | ||
}, | ||
"devDependencies": { | ||
"execa": "^7.0.0", | ||
"strip-ansi": "^7.0.1", | ||
"vite": "latest", | ||
"vitest": "workspace:*" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { expect, test } from 'vitest' | ||
|
||
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>') | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { execa } from 'execa' | ||
import stripAnsi from 'strip-ansi' | ||
|
||
export async function runVitest(mode: 'run' | 'watch', cliArguments: string[]) { | ||
const subprocess = execa('vitest', [mode, 'fixtures/test/', ...cliArguments]) | ||
let error = '' | ||
|
||
subprocess.stderr?.on('data', (data) => { | ||
error += stripAnsi(data.toString()) | ||
}) | ||
|
||
await new Promise(resolve => subprocess.on('exit', resolve)) | ||
|
||
return { error } | ||
} |