@vitest/coverage-v8
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -14,2 +14,3 @@ import { existsSync, promises, writeFileSync } from 'node:fs'; | ||
import { provider } from 'std-env'; | ||
import { stripLiteral } from 'strip-literal'; | ||
import createDebug from 'debug'; | ||
@@ -174,3 +175,3 @@ import { builtinModules } from 'node:module'; | ||
const VITE_EXPORTS_LINE_PATTERN = /Object\.defineProperty\(__vite_ssr_exports__.*\n/g; | ||
const DECORATOR_METADATA_PATTERN = /_ts_metadata\("design:paramtypes"(\s|.)+?]\),/g; | ||
const DECORATOR_METADATA_PATTERN = /_ts_metadata\("design:paramtypes", \[[^\]]*?\]\),*/g; | ||
const DEFAULT_PROJECT = Symbol.for("default-project"); | ||
@@ -323,4 +324,7 @@ const debug = createDebug("vitest:coverage"); | ||
const transformResults = normalizeTransformResults(this.ctx.vitenode.fetchCache); | ||
const includedFiles = await this.testExclude.glob(this.ctx.config.root); | ||
const uncoveredFiles = includedFiles.map((file) => pathToFileURL(resolve(this.ctx.config.root, file))).filter((file) => !testedFiles.includes(file.pathname)); | ||
const allFiles = await this.testExclude.glob(this.ctx.config.root); | ||
let includedFiles = allFiles.map((file) => resolve(this.ctx.config.root, file)); | ||
if (this.ctx.config.changed) | ||
includedFiles = (this.ctx.config.related || []).filter((file) => includedFiles.includes(file)); | ||
const uncoveredFiles = includedFiles.map((file) => pathToFileURL(file)).filter((file) => !testedFiles.includes(file.pathname)); | ||
let merged = { result: [] }; | ||
@@ -334,3 +338,7 @@ let index = 0; | ||
const coverages = await Promise.all(chunk.map(async (filename) => { | ||
const { source } = await this.getSources(filename.href, transformResults); | ||
const transformResult = await this.ctx.vitenode.transformRequest(filename.pathname).catch(() => { | ||
}); | ||
if (transformResult && stripLiteral(transformResult.code).trim() === "") | ||
return null; | ||
const { originalSource } = await this.getSources(filename.href, transformResults); | ||
const coverage = { | ||
@@ -343,3 +351,3 @@ url: filename.href, | ||
startOffset: 0, | ||
endOffset: source.length, | ||
endOffset: originalSource.length, | ||
count: 0 | ||
@@ -354,3 +362,6 @@ }], | ||
})); | ||
merged = mergeProcessCovs([merged, ...coverages]); | ||
merged = mergeProcessCovs([ | ||
merged, | ||
...coverages.filter((cov) => cov != null) | ||
]); | ||
} | ||
@@ -368,4 +379,11 @@ return merged; | ||
}); | ||
if (!map) | ||
return { source: code || sourcesContent }; | ||
if (!map) { | ||
return { | ||
source: code || sourcesContent, | ||
originalSource: sourcesContent | ||
}; | ||
} | ||
const sources = [url]; | ||
if (map.sources && map.sources[0] && !url.endsWith(map.sources[0])) | ||
sources[0] = new URL(map.sources[0], url).href; | ||
return { | ||
@@ -378,3 +396,3 @@ originalSource: sourcesContent, | ||
version: 3, | ||
sources: [url], | ||
sources, | ||
sourcesContent: [sourcesContent] | ||
@@ -381,0 +399,0 @@ }) |
{ | ||
"name": "@vitest/coverage-v8", | ||
"type": "module", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "V8 coverage provider for Vitest", | ||
@@ -40,3 +40,3 @@ "author": "Anthony Fu <anthonyfu117@hotmail.com>", | ||
"peerDependencies": { | ||
"vitest": "1.3.1" | ||
"vitest": "1.4.0" | ||
}, | ||
@@ -49,3 +49,3 @@ "dependencies": { | ||
"istanbul-lib-report": "^3.0.1", | ||
"istanbul-lib-source-maps": "^4.0.1", | ||
"istanbul-lib-source-maps": "^5.0.4", | ||
"istanbul-reports": "^3.1.6", | ||
@@ -56,2 +56,3 @@ "magic-string": "^0.30.5", | ||
"std-env": "^3.5.0", | ||
"strip-literal": "^2.0.0", | ||
"test-exclude": "^6.0.0", | ||
@@ -67,4 +68,4 @@ "v8-to-istanbul": "^9.2.0" | ||
"pathe": "^1.1.1", | ||
"vite-node": "1.3.1", | ||
"vitest": "1.3.1" | ||
"vite-node": "1.4.0", | ||
"vitest": "1.4.0" | ||
}, | ||
@@ -71,0 +72,0 @@ "scripts": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23737
549
15
+ Addedstrip-literal@^2.0.0
+ Added@babel/helper-string-parser@7.24.8(transitive)
+ Added@babel/helper-validator-identifier@7.24.7(transitive)
+ Added@babel/parser@7.25.6(transitive)
+ Added@babel/types@7.25.6(transitive)
+ Added@rollup/rollup-android-arm-eabi@4.22.5(transitive)
+ Added@rollup/rollup-android-arm64@4.22.5(transitive)
+ Added@rollup/rollup-darwin-arm64@4.22.5(transitive)
+ Added@rollup/rollup-darwin-x64@4.22.5(transitive)
+ Added@rollup/rollup-linux-arm-gnueabihf@4.22.5(transitive)
+ Added@rollup/rollup-linux-arm-musleabihf@4.22.5(transitive)
+ Added@rollup/rollup-linux-arm64-gnu@4.22.5(transitive)
+ Added@rollup/rollup-linux-arm64-musl@4.22.5(transitive)
+ Added@rollup/rollup-linux-powerpc64le-gnu@4.22.5(transitive)
+ Added@rollup/rollup-linux-riscv64-gnu@4.22.5(transitive)
+ Added@rollup/rollup-linux-s390x-gnu@4.22.5(transitive)
+ Added@rollup/rollup-linux-x64-gnu@4.22.5(transitive)
+ Added@rollup/rollup-linux-x64-musl@4.22.5(transitive)
+ Added@rollup/rollup-win32-arm64-msvc@4.22.5(transitive)
+ Added@rollup/rollup-win32-ia32-msvc@4.22.5(transitive)
+ Added@rollup/rollup-win32-x64-msvc@4.22.5(transitive)
+ Added@vitest/expect@1.4.0(transitive)
+ Added@vitest/runner@1.4.0(transitive)
+ Added@vitest/snapshot@1.4.0(transitive)
+ Added@vitest/spy@1.4.0(transitive)
+ Added@vitest/utils@1.4.0(transitive)
+ Addedistanbul-lib-source-maps@5.0.6(transitive)
+ Addedrollup@4.22.5(transitive)
+ Addedvite-node@1.4.0(transitive)
+ Addedvitest@1.4.0(transitive)
- Removed@babel/helper-string-parser@7.25.7(transitive)
- Removed@babel/helper-validator-identifier@7.25.7(transitive)
- Removed@babel/parser@7.25.7(transitive)
- Removed@babel/types@7.25.7(transitive)
- Removed@rollup/rollup-android-arm-eabi@4.24.0(transitive)
- Removed@rollup/rollup-android-arm64@4.24.0(transitive)
- Removed@rollup/rollup-darwin-arm64@4.24.0(transitive)
- Removed@rollup/rollup-darwin-x64@4.24.0(transitive)
- Removed@rollup/rollup-linux-arm-gnueabihf@4.24.0(transitive)
- Removed@rollup/rollup-linux-arm-musleabihf@4.24.0(transitive)
- Removed@rollup/rollup-linux-arm64-gnu@4.24.0(transitive)
- Removed@rollup/rollup-linux-arm64-musl@4.24.0(transitive)
- Removed@rollup/rollup-linux-powerpc64le-gnu@4.24.0(transitive)
- Removed@rollup/rollup-linux-riscv64-gnu@4.24.0(transitive)
- Removed@rollup/rollup-linux-s390x-gnu@4.24.0(transitive)
- Removed@rollup/rollup-linux-x64-gnu@4.24.0(transitive)
- Removed@rollup/rollup-linux-x64-musl@4.24.0(transitive)
- Removed@rollup/rollup-win32-arm64-msvc@4.24.0(transitive)
- Removed@rollup/rollup-win32-ia32-msvc@4.24.0(transitive)
- Removed@rollup/rollup-win32-x64-msvc@4.24.0(transitive)
- Removed@vitest/expect@1.3.1(transitive)
- Removed@vitest/runner@1.3.1(transitive)
- Removed@vitest/snapshot@1.3.1(transitive)
- Removed@vitest/spy@1.3.1(transitive)
- Removed@vitest/utils@1.3.1(transitive)
- Removedistanbul-lib-source-maps@4.0.1(transitive)
- Removedrollup@4.24.0(transitive)
- Removedsource-map@0.6.1(transitive)
- Removedvite-node@1.3.1(transitive)
- Removedvitest@1.3.1(transitive)