MCPcopy
hub / github.com/vitest-dev/vitest / readCoverageJson

Function readCoverageJson

test/coverage-test/utils.ts:102–113  ·  view source on GitHub ↗
(name = './coverage/coverage-final.json')

Source from the content-addressed store, hash-verified

100 * Normalizes paths to keep contents consistent between OS's
101 */
102export async function readCoverageJson(name = './coverage/coverage-final.json') {
103 const jsonReport = JSON.parse(readFileSync(name, 'utf8')) as Record<string, FileCoverageData>
104
105 const normalizedReport: typeof jsonReport = {}
106
107 for (const [filename, coverage] of Object.entries(jsonReport)) {
108 coverage.path = normalizeFilename(coverage.path)
109 normalizedReport[normalizeFilename(filename)] = coverage
110 }
111
112 return normalizedReport
113}
114
115/**
116 * Read coverage report from file system as Istanbul's `CoverageMap`

Callers 4

readCoverageMapFunction · 0.85

Calls 3

readFileSyncFunction · 0.85
entriesMethod · 0.80
normalizeFilenameFunction · 0.70

Tested by

no test coverage detected