-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add
NullCoverageProvider
to handled disabled coverage
- Loading branch information
1 parent
f16a9e3
commit 1402584
Showing
5 changed files
with
41 additions
and
19 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
packages/vitest/src/integrations/coverage/NullCoverageProvider.ts
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,20 @@ | ||
import type { ResolvedCoverageOptions } from '../../types' | ||
import type { BaseCoverageReporter } from './base' | ||
|
||
export class NullCoverageProvider implements BaseCoverageReporter { | ||
resolveOptions(): ResolvedCoverageOptions { | ||
return { | ||
provider: null, | ||
enabled: false, | ||
clean: false, | ||
cleanOnRerun: false, | ||
reportsDirectory: 'coverage', | ||
tempDirectory: 'coverage/tmp', | ||
} | ||
} | ||
|
||
initialize() {} | ||
clean() {} | ||
onAfterAllFilesRun() {} | ||
onAfterSuiteRun() {} | ||
} |
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,12 +1,11 @@ | ||
import type { CoverageOptions } from '../../types' | ||
|
||
import type { BaseCoverageReporter } from './base' | ||
import { C8Reporter } from './c8' | ||
import { NullCoverageProvider } from './NullCoverageProvider' | ||
|
||
export function getCoverageProvider(options?: CoverageOptions): BaseCoverageReporter { | ||
if (options?.enabled && options?.provider === 'c8') | ||
return new C8Reporter() | ||
|
||
// TODO: Return NullCoverageProvider | ||
return new C8Reporter() | ||
return new NullCoverageProvider() | ||
} |
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