-
-
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.
feat(coverage): support
--changed
option
- Loading branch information
1 parent
dfe16e1
commit ddf24af
Showing
10 changed files
with
345 additions
and
25 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { expect, test } from 'vitest' | ||
import libCoverage from 'istanbul-lib-coverage' | ||
|
||
import { readCoverageJson } from './utils' | ||
|
||
test('report contains only the changed files', async () => { | ||
const coverageJson = await readCoverageJson('./coverage/coverage-final.json') | ||
const coverageMap = libCoverage.createCoverageMap(coverageJson as any) | ||
|
||
expect(coverageMap.files()).toMatchInlineSnapshot(` | ||
[ | ||
"<process-cwd>/src/file-to-change.ts", | ||
"<process-cwd>/src/new-uncovered-file.ts", | ||
] | ||
`) | ||
|
||
const uncoveredFile = coverageMap.fileCoverageFor('<process-cwd>/src/new-uncovered-file.ts').toSummary() | ||
expect(uncoveredFile.lines.pct).toBe(0) | ||
|
||
const changedFile = coverageMap.fileCoverageFor('<process-cwd>/src/file-to-change.ts').toSummary() | ||
expect(changedFile.lines.pct).toBeGreaterThanOrEqual(50) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { test } from 'vitest' | ||
import { run } from '../src/file-to-change' | ||
|
||
test('test case for changed file', () => { | ||
run() | ||
}) |
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,7 @@ | ||
export function run() { | ||
return 'This file will be modified by test cases' | ||
} | ||
|
||
export function uncoveredFunction() { | ||
return 1 + 2 | ||
} |
Oops, something went wrong.