Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: coverage.100 crash when using as an cli argument #4346

Merged
merged 6 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/vitest/src/node/cli-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ export async function startVitest(
if (typeof options.coverage === 'boolean')
options.coverage = { enabled: options.coverage }

// running "vitest --coverage.all" or "vitest --coverage.100"
// @ts-expect-error Element implicitly has an any type for options.coverage["100"]
if (typeof options.coverage === 'object' && !('enabled' in options.coverage) && (options.coverage['100'] === true
|| Object.keys(options.coverage).length > 1))
options.coverage.enabled = true

marcelobotega marked this conversation as resolved.
Show resolved Hide resolved
// running "vitest --browser", assumes browser name is set in the config
if (typeof options.browser === 'boolean')
options.browser = { enabled: options.browser } as any
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cli
.option('--hideSkippedTests', 'Hide logs for skipped tests')
.option('--reporter <name>', 'Specify reporters')
.option('--outputFile <filename/-s>', 'Write test results to a file when supporter reporter is also specified, use cac\'s dot notation for individual outputs of multiple reporters')
.option('--coverage', 'Enable coverage report')
.option('--coverage', 'Enable coverage report', { default: { 100: false } })
.option('--run', 'Disable watch mode')
.option('--mode <name>', 'Override Vite mode (default: test)')
.option('--globals', 'Inject apis globally')
Expand Down
Loading