@vitest/coverage-istanbul 5.0.0-beta.6 → 5.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base-BO8X8tRz.js +40 -0
- package/dist/browser.d.ts +5 -0
- package/dist/browser.js +23 -0
- package/dist/commands-KXFl3PvR.js +118 -0
- package/dist/index.js +18 -30
- package/dist/provider.js +81 -195
- package/package.json +12 -8
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { C as COVERAGE_STORE_KEY } from './constants-BCJfMgEg.js';
|
|
2
|
+
|
|
3
|
+
const BaseCoverageProviderModule = {
|
|
4
|
+
takeCoverage() {
|
|
5
|
+
// @ts-expect-error -- untyped global
|
|
6
|
+
return globalThis[COVERAGE_STORE_KEY];
|
|
7
|
+
},
|
|
8
|
+
// Reset coverage map to prevent duplicate results if this is called twice in row
|
|
9
|
+
startCoverage() {
|
|
10
|
+
// @ts-expect-error -- untyped global
|
|
11
|
+
const coverageMap = globalThis[COVERAGE_STORE_KEY];
|
|
12
|
+
// When isolated, there are no previous results
|
|
13
|
+
if (!coverageMap) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
for (const filename in coverageMap) {
|
|
17
|
+
const branches = coverageMap[filename].b;
|
|
18
|
+
for (const key in branches) {
|
|
19
|
+
branches[key] = branches[key].map(() => 0);
|
|
20
|
+
}
|
|
21
|
+
for (const metric of ["f", "s"]) {
|
|
22
|
+
const entry = coverageMap[filename][metric];
|
|
23
|
+
for (const key in entry) {
|
|
24
|
+
entry[key] = 0;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
async getProvider() {
|
|
30
|
+
// to not bundle the provider
|
|
31
|
+
const providerPath = "./provider.js";
|
|
32
|
+
const { IstanbulCoverageProvider } = await import(
|
|
33
|
+
/* @vite-ignore */
|
|
34
|
+
providerPath
|
|
35
|
+
);
|
|
36
|
+
return new IstanbulCoverageProvider();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { BaseCoverageProviderModule as B };
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { B as BaseCoverageProviderModule } from './base-BO8X8tRz.js';
|
|
2
|
+
import './constants-BCJfMgEg.js';
|
|
3
|
+
|
|
4
|
+
function triggerCommand(command, args = []) {
|
|
5
|
+
return globalThis.__vitest_browser_runner__?.commands?.triggerCommand?.(command, args);
|
|
6
|
+
}
|
|
7
|
+
const mod = {
|
|
8
|
+
takeCoverage() {
|
|
9
|
+
const coverage = BaseCoverageProviderModule.takeCoverage();
|
|
10
|
+
if (!coverage) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
return triggerCommand("__vitest_writeCoverageFile", [coverage]);
|
|
14
|
+
},
|
|
15
|
+
startCoverage() {
|
|
16
|
+
BaseCoverageProviderModule.startCoverage();
|
|
17
|
+
},
|
|
18
|
+
getProvider() {
|
|
19
|
+
return BaseCoverageProviderModule.getProvider();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { mod as default };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { writeFile } from 'node:fs/promises';
|
|
4
|
+
|
|
5
|
+
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
6
|
+
function normalizeWindowsPath(input = "") {
|
|
7
|
+
if (!input) {
|
|
8
|
+
return input;
|
|
9
|
+
}
|
|
10
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
11
|
+
}
|
|
12
|
+
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
13
|
+
function cwd() {
|
|
14
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
15
|
+
return process.cwd().replace(/\\/g, "/");
|
|
16
|
+
}
|
|
17
|
+
return "/";
|
|
18
|
+
}
|
|
19
|
+
const resolve = function(...arguments_) {
|
|
20
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
21
|
+
let resolvedPath = "";
|
|
22
|
+
let resolvedAbsolute = false;
|
|
23
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
24
|
+
const path = index >= 0 ? arguments_[index] : cwd();
|
|
25
|
+
if (!path || path.length === 0) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
29
|
+
resolvedAbsolute = isAbsolute(path);
|
|
30
|
+
}
|
|
31
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
32
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
33
|
+
return `/${resolvedPath}`;
|
|
34
|
+
}
|
|
35
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
36
|
+
};
|
|
37
|
+
function normalizeString(path, allowAboveRoot) {
|
|
38
|
+
let res = "";
|
|
39
|
+
let lastSegmentLength = 0;
|
|
40
|
+
let lastSlash = -1;
|
|
41
|
+
let dots = 0;
|
|
42
|
+
let char = null;
|
|
43
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
44
|
+
if (index < path.length) {
|
|
45
|
+
char = path[index];
|
|
46
|
+
} else if (char === "/") {
|
|
47
|
+
break;
|
|
48
|
+
} else {
|
|
49
|
+
char = "/";
|
|
50
|
+
}
|
|
51
|
+
if (char === "/") {
|
|
52
|
+
if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {
|
|
53
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
54
|
+
if (res.length > 2) {
|
|
55
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
56
|
+
if (lastSlashIndex === -1) {
|
|
57
|
+
res = "";
|
|
58
|
+
lastSegmentLength = 0;
|
|
59
|
+
} else {
|
|
60
|
+
res = res.slice(0, lastSlashIndex);
|
|
61
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
62
|
+
}
|
|
63
|
+
lastSlash = index;
|
|
64
|
+
dots = 0;
|
|
65
|
+
continue;
|
|
66
|
+
} else if (res.length > 0) {
|
|
67
|
+
res = "";
|
|
68
|
+
lastSegmentLength = 0;
|
|
69
|
+
lastSlash = index;
|
|
70
|
+
dots = 0;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (allowAboveRoot) {
|
|
75
|
+
res += res.length > 0 ? "/.." : "..";
|
|
76
|
+
lastSegmentLength = 2;
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
if (res.length > 0) {
|
|
80
|
+
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
81
|
+
} else {
|
|
82
|
+
res = path.slice(lastSlash + 1, index);
|
|
83
|
+
}
|
|
84
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
85
|
+
}
|
|
86
|
+
lastSlash = index;
|
|
87
|
+
dots = 0;
|
|
88
|
+
} else if (char === "." && dots !== -1) {
|
|
89
|
+
++dots;
|
|
90
|
+
} else {
|
|
91
|
+
dots = -1;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return res;
|
|
95
|
+
}
|
|
96
|
+
const isAbsolute = function(p) {
|
|
97
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const commands = { writeCoverageFile(context, coverage) {
|
|
101
|
+
const provider = context.project.vitest.coverageProvider;
|
|
102
|
+
return writeCoverageFile(provider.coverageFilesDirectory, coverage);
|
|
103
|
+
} };
|
|
104
|
+
async function writeCoverageFile(coverageFilesDirectory, coverage) {
|
|
105
|
+
// Write results on file system directly and transfer only the filename over RPC
|
|
106
|
+
const filename = resolve(coverageFilesDirectory, `coverage-${randomUUID()}.json`);
|
|
107
|
+
try {
|
|
108
|
+
await writeFile(filename, JSON.stringify(coverage), "utf-8");
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (!existsSync(coverageFilesDirectory)) {
|
|
111
|
+
throw new Error(`Something removed the coverage directory "${coverageFilesDirectory}" Vitest created earlier. Make sure you are not running multiple Vitests with the same "coverage.reportsDirectory" at the same time.`, { cause: error });
|
|
112
|
+
}
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
return filename;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { commands as c, writeCoverageFile as w };
|
package/dist/index.js
CHANGED
|
@@ -1,38 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { B as BaseCoverageProviderModule } from './base-BO8X8tRz.js';
|
|
3
|
+
import { w as writeCoverageFile } from './commands-KXFl3PvR.js';
|
|
4
|
+
import './constants-BCJfMgEg.js';
|
|
5
|
+
import 'node:crypto';
|
|
6
|
+
import 'node:fs';
|
|
7
|
+
import 'node:fs/promises';
|
|
2
8
|
|
|
3
9
|
const mod = {
|
|
4
|
-
takeCoverage() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
},
|
|
8
|
-
startCoverage() {
|
|
9
|
-
// @ts-expect-error -- untyped global
|
|
10
|
-
const coverageMap = globalThis[COVERAGE_STORE_KEY];
|
|
11
|
-
// When isolated, there are no previous results
|
|
12
|
-
if (!coverageMap) {
|
|
10
|
+
takeCoverage(options) {
|
|
11
|
+
const coverage = BaseCoverageProviderModule.takeCoverage();
|
|
12
|
+
if (!coverage) {
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const entry = coverageMap[filename][metric];
|
|
22
|
-
for (const key in entry) {
|
|
23
|
-
entry[key] = 0;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
15
|
+
const coverageFilesDirectory = options?.coverageFilesDirectory;
|
|
16
|
+
assert(coverageFilesDirectory, "coverageFilesDirectory is required");
|
|
17
|
+
return writeCoverageFile(coverageFilesDirectory, coverage);
|
|
18
|
+
},
|
|
19
|
+
startCoverage() {
|
|
20
|
+
BaseCoverageProviderModule.startCoverage();
|
|
27
21
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const providerPath = "./provider.js";
|
|
31
|
-
const { IstanbulCoverageProvider } = await import(
|
|
32
|
-
/* @vite-ignore */
|
|
33
|
-
providerPath
|
|
34
|
-
);
|
|
35
|
-
return new IstanbulCoverageProvider();
|
|
22
|
+
getProvider() {
|
|
23
|
+
return BaseCoverageProviderModule.getProvider();
|
|
36
24
|
}
|
|
37
25
|
};
|
|
38
26
|
|
package/dist/provider.js
CHANGED
|
@@ -9,15 +9,17 @@ import require$$0$2 from 'fs';
|
|
|
9
9
|
import require$$0$1 from 'crypto';
|
|
10
10
|
import libReport from 'istanbul-lib-report';
|
|
11
11
|
import require$$0$5 from 'path';
|
|
12
|
-
import require$$
|
|
13
|
-
import require$$1$
|
|
14
|
-
import require$$0$4 from 'os';
|
|
12
|
+
import require$$0$4 from 'tty';
|
|
13
|
+
import require$$1$2 from 'util';
|
|
15
14
|
import reports from 'istanbul-reports';
|
|
16
15
|
import { parseModule } from 'magicast';
|
|
17
16
|
import { createDebug } from 'obug';
|
|
18
17
|
import c from 'tinyrainbow';
|
|
19
18
|
import { BaseCoverageProvider, isCSSRequest } from 'vitest/node';
|
|
19
|
+
import { c as commands } from './commands-KXFl3PvR.js';
|
|
20
20
|
import { C as COVERAGE_STORE_KEY } from './constants-BCJfMgEg.js';
|
|
21
|
+
import 'node:crypto';
|
|
22
|
+
import 'node:fs/promises';
|
|
21
23
|
|
|
22
24
|
function getDefaultExportFromCjs(x) {
|
|
23
25
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
@@ -30,7 +32,7 @@ function getAugmentedNamespace(n) {
|
|
|
30
32
|
var isInstance = false;
|
|
31
33
|
try {
|
|
32
34
|
isInstance = this instanceof a;
|
|
33
|
-
} catch {}
|
|
35
|
+
} catch (e) {}
|
|
34
36
|
if (isInstance) {
|
|
35
37
|
return Reflect.construct(f, arguments, this.constructor);
|
|
36
38
|
}
|
|
@@ -1519,7 +1521,7 @@ var srcExports = requireSrc$1();
|
|
|
1519
1521
|
|
|
1520
1522
|
var src = {exports: {}};
|
|
1521
1523
|
|
|
1522
|
-
var browser = {exports: {}};
|
|
1524
|
+
var browser$1 = {exports: {}};
|
|
1523
1525
|
|
|
1524
1526
|
/**
|
|
1525
1527
|
* Helpers.
|
|
@@ -1994,22 +1996,22 @@ function requireCommon () {
|
|
|
1994
1996
|
|
|
1995
1997
|
/* eslint-env browser */
|
|
1996
1998
|
|
|
1997
|
-
var hasRequiredBrowser;
|
|
1999
|
+
var hasRequiredBrowser$1;
|
|
1998
2000
|
|
|
1999
|
-
function requireBrowser () {
|
|
2000
|
-
if (hasRequiredBrowser) return browser.exports;
|
|
2001
|
-
hasRequiredBrowser = 1;
|
|
2002
|
-
(function (module, exports
|
|
2001
|
+
function requireBrowser$1 () {
|
|
2002
|
+
if (hasRequiredBrowser$1) return browser$1.exports;
|
|
2003
|
+
hasRequiredBrowser$1 = 1;
|
|
2004
|
+
(function (module, exports) {
|
|
2003
2005
|
/**
|
|
2004
2006
|
* This is the web browser implementation of `debug()`.
|
|
2005
2007
|
*/
|
|
2006
2008
|
|
|
2007
|
-
exports
|
|
2008
|
-
exports
|
|
2009
|
-
exports
|
|
2010
|
-
exports
|
|
2011
|
-
exports
|
|
2012
|
-
exports
|
|
2009
|
+
exports.formatArgs = formatArgs;
|
|
2010
|
+
exports.save = save;
|
|
2011
|
+
exports.load = load;
|
|
2012
|
+
exports.useColors = useColors;
|
|
2013
|
+
exports.storage = localstorage();
|
|
2014
|
+
exports.destroy = (() => {
|
|
2013
2015
|
let warned = false;
|
|
2014
2016
|
|
|
2015
2017
|
return () => {
|
|
@@ -2024,7 +2026,7 @@ function requireBrowser () {
|
|
|
2024
2026
|
* Colors.
|
|
2025
2027
|
*/
|
|
2026
2028
|
|
|
2027
|
-
exports
|
|
2029
|
+
exports.colors = [
|
|
2028
2030
|
'#0000CC',
|
|
2029
2031
|
'#0000FF',
|
|
2030
2032
|
'#0033CC',
|
|
@@ -2189,7 +2191,7 @@ function requireBrowser () {
|
|
|
2189
2191
|
*
|
|
2190
2192
|
* @api public
|
|
2191
2193
|
*/
|
|
2192
|
-
exports
|
|
2194
|
+
exports.log = console.debug || console.log || (() => {});
|
|
2193
2195
|
|
|
2194
2196
|
/**
|
|
2195
2197
|
* Save `namespaces`.
|
|
@@ -2200,9 +2202,9 @@ function requireBrowser () {
|
|
|
2200
2202
|
function save(namespaces) {
|
|
2201
2203
|
try {
|
|
2202
2204
|
if (namespaces) {
|
|
2203
|
-
exports
|
|
2205
|
+
exports.storage.setItem('debug', namespaces);
|
|
2204
2206
|
} else {
|
|
2205
|
-
exports
|
|
2207
|
+
exports.storage.removeItem('debug');
|
|
2206
2208
|
}
|
|
2207
2209
|
} catch (error) {
|
|
2208
2210
|
// Swallow
|
|
@@ -2219,7 +2221,7 @@ function requireBrowser () {
|
|
|
2219
2221
|
function load() {
|
|
2220
2222
|
let r;
|
|
2221
2223
|
try {
|
|
2222
|
-
r = exports
|
|
2224
|
+
r = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG') ;
|
|
2223
2225
|
} catch (error) {
|
|
2224
2226
|
// Swallow
|
|
2225
2227
|
// XXX (@Qix-) should we be logging these?
|
|
@@ -2255,7 +2257,7 @@ function requireBrowser () {
|
|
|
2255
2257
|
}
|
|
2256
2258
|
}
|
|
2257
2259
|
|
|
2258
|
-
module.exports = requireCommon()(exports
|
|
2260
|
+
module.exports = requireCommon()(exports);
|
|
2259
2261
|
|
|
2260
2262
|
const {formatters} = module.exports;
|
|
2261
2263
|
|
|
@@ -2270,169 +2272,43 @@ function requireBrowser () {
|
|
|
2270
2272
|
return '[UnexpectedJSONParseError]: ' + error.message;
|
|
2271
2273
|
}
|
|
2272
2274
|
};
|
|
2273
|
-
} (browser, browser.exports));
|
|
2274
|
-
return browser.exports;
|
|
2275
|
+
} (browser$1, browser$1.exports));
|
|
2276
|
+
return browser$1.exports;
|
|
2275
2277
|
}
|
|
2276
2278
|
|
|
2277
2279
|
var node = {exports: {}};
|
|
2278
2280
|
|
|
2279
|
-
|
|
2280
|
-
var hasRequiredHasFlag;
|
|
2281
|
-
|
|
2282
|
-
function requireHasFlag () {
|
|
2283
|
-
if (hasRequiredHasFlag) return hasFlag;
|
|
2284
|
-
hasRequiredHasFlag = 1;
|
|
2285
|
-
|
|
2286
|
-
hasFlag = (flag, argv = process.argv) => {
|
|
2287
|
-
const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
|
|
2288
|
-
const position = argv.indexOf(prefix + flag);
|
|
2289
|
-
const terminatorPosition = argv.indexOf('--');
|
|
2290
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
2291
|
-
};
|
|
2292
|
-
return hasFlag;
|
|
2293
|
-
}
|
|
2294
|
-
|
|
2295
|
-
var supportsColor_1;
|
|
2296
|
-
var hasRequiredSupportsColor;
|
|
2297
|
-
|
|
2298
|
-
function requireSupportsColor () {
|
|
2299
|
-
if (hasRequiredSupportsColor) return supportsColor_1;
|
|
2300
|
-
hasRequiredSupportsColor = 1;
|
|
2301
|
-
const os = require$$0$4;
|
|
2302
|
-
const tty = require$$1$2;
|
|
2303
|
-
const hasFlag = requireHasFlag();
|
|
2304
|
-
|
|
2305
|
-
const {env} = process;
|
|
2306
|
-
|
|
2307
|
-
let forceColor;
|
|
2308
|
-
if (hasFlag('no-color') ||
|
|
2309
|
-
hasFlag('no-colors') ||
|
|
2310
|
-
hasFlag('color=false') ||
|
|
2311
|
-
hasFlag('color=never')) {
|
|
2312
|
-
forceColor = 0;
|
|
2313
|
-
} else if (hasFlag('color') ||
|
|
2314
|
-
hasFlag('colors') ||
|
|
2315
|
-
hasFlag('color=true') ||
|
|
2316
|
-
hasFlag('color=always')) {
|
|
2317
|
-
forceColor = 1;
|
|
2318
|
-
}
|
|
2319
|
-
|
|
2320
|
-
if ('FORCE_COLOR' in env) {
|
|
2321
|
-
if (env.FORCE_COLOR === 'true') {
|
|
2322
|
-
forceColor = 1;
|
|
2323
|
-
} else if (env.FORCE_COLOR === 'false') {
|
|
2324
|
-
forceColor = 0;
|
|
2325
|
-
} else {
|
|
2326
|
-
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
2327
|
-
}
|
|
2328
|
-
}
|
|
2329
|
-
|
|
2330
|
-
function translateLevel(level) {
|
|
2331
|
-
if (level === 0) {
|
|
2332
|
-
return false;
|
|
2333
|
-
}
|
|
2334
|
-
|
|
2335
|
-
return {
|
|
2336
|
-
level,
|
|
2337
|
-
hasBasic: true,
|
|
2338
|
-
has256: level >= 2,
|
|
2339
|
-
has16m: level >= 3
|
|
2340
|
-
};
|
|
2341
|
-
}
|
|
2342
|
-
|
|
2343
|
-
function supportsColor(haveStream, streamIsTTY) {
|
|
2344
|
-
if (forceColor === 0) {
|
|
2345
|
-
return 0;
|
|
2346
|
-
}
|
|
2347
|
-
|
|
2348
|
-
if (hasFlag('color=16m') ||
|
|
2349
|
-
hasFlag('color=full') ||
|
|
2350
|
-
hasFlag('color=truecolor')) {
|
|
2351
|
-
return 3;
|
|
2352
|
-
}
|
|
2353
|
-
|
|
2354
|
-
if (hasFlag('color=256')) {
|
|
2355
|
-
return 2;
|
|
2356
|
-
}
|
|
2357
|
-
|
|
2358
|
-
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
2359
|
-
return 0;
|
|
2360
|
-
}
|
|
2361
|
-
|
|
2362
|
-
const min = forceColor || 0;
|
|
2363
|
-
|
|
2364
|
-
if (env.TERM === 'dumb') {
|
|
2365
|
-
return min;
|
|
2366
|
-
}
|
|
2367
|
-
|
|
2368
|
-
if (process.platform === 'win32') {
|
|
2369
|
-
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
|
2370
|
-
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
|
2371
|
-
const osRelease = os.release().split('.');
|
|
2372
|
-
if (
|
|
2373
|
-
Number(osRelease[0]) >= 10 &&
|
|
2374
|
-
Number(osRelease[2]) >= 10586
|
|
2375
|
-
) {
|
|
2376
|
-
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
2377
|
-
}
|
|
2378
|
-
|
|
2379
|
-
return 1;
|
|
2380
|
-
}
|
|
2381
|
-
|
|
2382
|
-
if ('CI' in env) {
|
|
2383
|
-
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
2384
|
-
return 1;
|
|
2385
|
-
}
|
|
2386
|
-
|
|
2387
|
-
return min;
|
|
2388
|
-
}
|
|
2389
|
-
|
|
2390
|
-
if ('TEAMCITY_VERSION' in env) {
|
|
2391
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
2392
|
-
}
|
|
2393
|
-
|
|
2394
|
-
if (env.COLORTERM === 'truecolor') {
|
|
2395
|
-
return 3;
|
|
2396
|
-
}
|
|
2397
|
-
|
|
2398
|
-
if ('TERM_PROGRAM' in env) {
|
|
2399
|
-
const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
2281
|
+
/* eslint-env browser */
|
|
2400
2282
|
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
return version >= 3 ? 3 : 2;
|
|
2404
|
-
case 'Apple_Terminal':
|
|
2405
|
-
return 2;
|
|
2406
|
-
// No default
|
|
2407
|
-
}
|
|
2408
|
-
}
|
|
2283
|
+
var browser;
|
|
2284
|
+
var hasRequiredBrowser;
|
|
2409
2285
|
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2286
|
+
function requireBrowser () {
|
|
2287
|
+
if (hasRequiredBrowser) return browser;
|
|
2288
|
+
hasRequiredBrowser = 1;
|
|
2413
2289
|
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
}
|
|
2290
|
+
function getChromeVersion() {
|
|
2291
|
+
const matches = /(Chrome|Chromium)\/(?<chromeVersion>\d+)\./.exec(navigator.userAgent);
|
|
2417
2292
|
|
|
2418
|
-
if (
|
|
2419
|
-
return
|
|
2293
|
+
if (!matches) {
|
|
2294
|
+
return;
|
|
2420
2295
|
}
|
|
2421
2296
|
|
|
2422
|
-
return
|
|
2297
|
+
return Number.parseInt(matches.groups.chromeVersion, 10);
|
|
2423
2298
|
}
|
|
2424
2299
|
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2300
|
+
const colorSupport = getChromeVersion() >= 69 ? {
|
|
2301
|
+
level: 1,
|
|
2302
|
+
hasBasic: true,
|
|
2303
|
+
has256: false,
|
|
2304
|
+
has16m: false
|
|
2305
|
+
} : false;
|
|
2429
2306
|
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
2307
|
+
browser = {
|
|
2308
|
+
stdout: colorSupport,
|
|
2309
|
+
stderr: colorSupport
|
|
2434
2310
|
};
|
|
2435
|
-
return
|
|
2311
|
+
return browser;
|
|
2436
2312
|
}
|
|
2437
2313
|
|
|
2438
2314
|
/**
|
|
@@ -2444,21 +2320,21 @@ var hasRequiredNode;
|
|
|
2444
2320
|
function requireNode () {
|
|
2445
2321
|
if (hasRequiredNode) return node.exports;
|
|
2446
2322
|
hasRequiredNode = 1;
|
|
2447
|
-
(function (module, exports
|
|
2448
|
-
const tty = require$$
|
|
2449
|
-
const util = require$$1$
|
|
2323
|
+
(function (module, exports) {
|
|
2324
|
+
const tty = require$$0$4;
|
|
2325
|
+
const util = require$$1$2;
|
|
2450
2326
|
|
|
2451
2327
|
/**
|
|
2452
2328
|
* This is the Node.js implementation of `debug()`.
|
|
2453
2329
|
*/
|
|
2454
2330
|
|
|
2455
|
-
exports
|
|
2456
|
-
exports
|
|
2457
|
-
exports
|
|
2458
|
-
exports
|
|
2459
|
-
exports
|
|
2460
|
-
exports
|
|
2461
|
-
exports
|
|
2331
|
+
exports.init = init;
|
|
2332
|
+
exports.log = log;
|
|
2333
|
+
exports.formatArgs = formatArgs;
|
|
2334
|
+
exports.save = save;
|
|
2335
|
+
exports.load = load;
|
|
2336
|
+
exports.useColors = useColors;
|
|
2337
|
+
exports.destroy = util.deprecate(
|
|
2462
2338
|
() => {},
|
|
2463
2339
|
'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
|
|
2464
2340
|
);
|
|
@@ -2467,15 +2343,15 @@ function requireNode () {
|
|
|
2467
2343
|
* Colors.
|
|
2468
2344
|
*/
|
|
2469
2345
|
|
|
2470
|
-
exports
|
|
2346
|
+
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
2471
2347
|
|
|
2472
2348
|
try {
|
|
2473
2349
|
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
|
2474
2350
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2475
|
-
const supportsColor =
|
|
2351
|
+
const supportsColor = requireBrowser();
|
|
2476
2352
|
|
|
2477
2353
|
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
2478
|
-
exports
|
|
2354
|
+
exports.colors = [
|
|
2479
2355
|
20,
|
|
2480
2356
|
21,
|
|
2481
2357
|
26,
|
|
@@ -2564,7 +2440,7 @@ function requireNode () {
|
|
|
2564
2440
|
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
|
2565
2441
|
*/
|
|
2566
2442
|
|
|
2567
|
-
exports
|
|
2443
|
+
exports.inspectOpts = Object.keys(process.env).filter(key => {
|
|
2568
2444
|
return /^debug_/i.test(key);
|
|
2569
2445
|
}).reduce((obj, key) => {
|
|
2570
2446
|
// Camel-case
|
|
@@ -2596,8 +2472,8 @@ function requireNode () {
|
|
|
2596
2472
|
*/
|
|
2597
2473
|
|
|
2598
2474
|
function useColors() {
|
|
2599
|
-
return 'colors' in exports
|
|
2600
|
-
Boolean(exports
|
|
2475
|
+
return 'colors' in exports.inspectOpts ?
|
|
2476
|
+
Boolean(exports.inspectOpts.colors) :
|
|
2601
2477
|
tty.isatty(process.stderr.fd);
|
|
2602
2478
|
}
|
|
2603
2479
|
|
|
@@ -2623,7 +2499,7 @@ function requireNode () {
|
|
|
2623
2499
|
}
|
|
2624
2500
|
|
|
2625
2501
|
function getDate() {
|
|
2626
|
-
if (exports
|
|
2502
|
+
if (exports.inspectOpts.hideDate) {
|
|
2627
2503
|
return '';
|
|
2628
2504
|
}
|
|
2629
2505
|
return new Date().toISOString() + ' ';
|
|
@@ -2634,7 +2510,7 @@ function requireNode () {
|
|
|
2634
2510
|
*/
|
|
2635
2511
|
|
|
2636
2512
|
function log(...args) {
|
|
2637
|
-
return process.stderr.write(util.formatWithOptions(exports
|
|
2513
|
+
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
|
|
2638
2514
|
}
|
|
2639
2515
|
|
|
2640
2516
|
/**
|
|
@@ -2674,13 +2550,13 @@ function requireNode () {
|
|
|
2674
2550
|
function init(debug) {
|
|
2675
2551
|
debug.inspectOpts = {};
|
|
2676
2552
|
|
|
2677
|
-
const keys = Object.keys(exports
|
|
2553
|
+
const keys = Object.keys(exports.inspectOpts);
|
|
2678
2554
|
for (let i = 0; i < keys.length; i++) {
|
|
2679
|
-
debug.inspectOpts[keys[i]] = exports
|
|
2555
|
+
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
2680
2556
|
}
|
|
2681
2557
|
}
|
|
2682
2558
|
|
|
2683
|
-
module.exports = requireCommon()(exports
|
|
2559
|
+
module.exports = requireCommon()(exports);
|
|
2684
2560
|
|
|
2685
2561
|
const {formatters} = module.exports;
|
|
2686
2562
|
|
|
@@ -2719,7 +2595,7 @@ function requireSrc () {
|
|
|
2719
2595
|
if (hasRequiredSrc) return src.exports;
|
|
2720
2596
|
hasRequiredSrc = 1;
|
|
2721
2597
|
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
|
|
2722
|
-
src.exports = requireBrowser();
|
|
2598
|
+
src.exports = requireBrowser$1();
|
|
2723
2599
|
} else {
|
|
2724
2600
|
src.exports = requireNode();
|
|
2725
2601
|
}
|
|
@@ -3543,7 +3419,7 @@ function requireIstanbulLibSourceMaps () {
|
|
|
3543
3419
|
var istanbulLibSourceMapsExports = requireIstanbulLibSourceMaps();
|
|
3544
3420
|
var libSourceMaps = /*@__PURE__*/getDefaultExportFromCjs(istanbulLibSourceMapsExports);
|
|
3545
3421
|
|
|
3546
|
-
var version = "5.0.0-
|
|
3422
|
+
var version = "5.0.0-rc.1";
|
|
3547
3423
|
|
|
3548
3424
|
const debug = createDebug("vitest:coverage");
|
|
3549
3425
|
class IstanbulCoverageProvider extends BaseCoverageProvider {
|
|
@@ -3553,6 +3429,13 @@ class IstanbulCoverageProvider extends BaseCoverageProvider {
|
|
|
3553
3429
|
transformedModuleIds = new Set();
|
|
3554
3430
|
initialize(ctx) {
|
|
3555
3431
|
this._initialize(ctx);
|
|
3432
|
+
for (const project of ctx.projects) {
|
|
3433
|
+
if (project.isBrowserEnabled() && project.browser) {
|
|
3434
|
+
for (const [name, command] of Object.entries(commands)) {
|
|
3435
|
+
project.browser.registerCommand(`__vitest_${name}`, command);
|
|
3436
|
+
}
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
3556
3439
|
if (this.options.instrumenter) {
|
|
3557
3440
|
this.instrumenter = this.options.instrumenter({
|
|
3558
3441
|
coverageVariable: COVERAGE_STORE_KEY,
|
|
@@ -3571,7 +3454,10 @@ class IstanbulCoverageProvider extends BaseCoverageProvider {
|
|
|
3571
3454
|
coverageGlobalScopeFunc: false,
|
|
3572
3455
|
ignoreClassMethods: this.options.ignoreClassMethods,
|
|
3573
3456
|
parserPlugins: [...defaults.instrumenter.parserPlugins, ["importAttributes", { deprecatedAssertSyntax: true }]],
|
|
3574
|
-
generatorOpts: {
|
|
3457
|
+
generatorOpts: {
|
|
3458
|
+
// @ts-expect-error missing type
|
|
3459
|
+
importAttributesKeyword: "with" },
|
|
3460
|
+
// Custom option from the patched istanbul-lib-instrument: https://github.com/istanbuljs/istanbuljs/pull/835
|
|
3575
3461
|
ignoreLines: true
|
|
3576
3462
|
});
|
|
3577
3463
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/coverage-istanbul",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.0-
|
|
4
|
+
"version": "5.0.0-rc.1",
|
|
5
5
|
"description": "Istanbul coverage provider for Vitest",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -28,6 +28,10 @@
|
|
|
28
28
|
"types": "./dist/index.d.ts",
|
|
29
29
|
"default": "./dist/index.js"
|
|
30
30
|
},
|
|
31
|
+
"./browser": {
|
|
32
|
+
"types": "./dist/browser.d.ts",
|
|
33
|
+
"default": "./dist/browser.js"
|
|
34
|
+
},
|
|
31
35
|
"./*": "./*"
|
|
32
36
|
},
|
|
33
37
|
"main": "./dist/index.js",
|
|
@@ -37,19 +41,19 @@
|
|
|
37
41
|
"dist"
|
|
38
42
|
],
|
|
39
43
|
"peerDependencies": {
|
|
40
|
-
"vitest": "5.0.0-
|
|
44
|
+
"vitest": "5.0.0-rc.1"
|
|
41
45
|
},
|
|
42
46
|
"dependencies": {
|
|
43
|
-
"@babel/core": "^7.29.
|
|
44
|
-
"@istanbuljs/schema": "^0.1.
|
|
47
|
+
"@babel/core": "^7.29.7",
|
|
48
|
+
"@istanbuljs/schema": "^0.1.6",
|
|
45
49
|
"@jridgewell/gen-mapping": "^0.3.13",
|
|
46
50
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
47
51
|
"istanbul-lib-coverage": "^3.2.2",
|
|
48
52
|
"istanbul-lib-report": "^3.0.1",
|
|
49
53
|
"istanbul-reports": "^3.2.0",
|
|
50
|
-
"magicast": "^0.5.
|
|
51
|
-
"obug": "^2.1.
|
|
52
|
-
"tinyrainbow": "^3.1.
|
|
54
|
+
"magicast": "^0.5.4",
|
|
55
|
+
"obug": "^2.1.4",
|
|
56
|
+
"tinyrainbow": "^3.1.1"
|
|
53
57
|
},
|
|
54
58
|
"devDependencies": {
|
|
55
59
|
"@types/istanbul-lib-coverage": "^2.0.6",
|
|
@@ -60,7 +64,7 @@
|
|
|
60
64
|
"istanbul-lib-instrument": "^6.0.3",
|
|
61
65
|
"istanbul-lib-source-maps": "^5.0.6",
|
|
62
66
|
"pathe": "^2.0.3",
|
|
63
|
-
"vitest": "5.0.0-
|
|
67
|
+
"vitest": "5.0.0-rc.1"
|
|
64
68
|
},
|
|
65
69
|
"scripts": {
|
|
66
70
|
"build": "premove dist && rollup -c",
|