vitest 0.9.4 → 0.10.2
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/LICENSE.md +7 -0
- package/dist/{chunk-api-setup.49283db8.js → chunk-api-setup.b55307fb.js} +41 -18
- package/dist/{chunk-constants.c8f1d38c.js → chunk-constants.90075174.js} +1 -1
- package/dist/{chunk-defaults.43e746f3.js → chunk-defaults.fd5b939d.js} +1 -1
- package/dist/{chunk-install-pkg.cbf3a38b.js → chunk-install-pkg.73b84ae1.js} +113 -115
- package/dist/chunk-integrations-globals.16d9702f.js +29 -0
- package/dist/chunk-integrations-spy.f036df6f.js +102 -0
- package/dist/{chunk-runtime-chain.701cffd8.js → chunk-runtime-chain.6292a3de.js} +941 -901
- package/dist/{chunk-runtime-mocker.e802beae.js → chunk-runtime-mocker.ca5ecf98.js} +5 -21
- package/dist/{chunk-runtime-rpc.c47f2233.js → chunk-runtime-rpc.8e14ae4f.js} +1 -1
- package/dist/{chunk-utils-global.a3293dce.js → chunk-utils-global.9b434e81.js} +42 -10
- package/dist/{chunk-utils-timers.b26e7c5c.js → chunk-utils-timers.c50fec92.js} +1406 -1057
- package/dist/{chunk-vite-node-externalize.1c19fc5e.js → chunk-vite-node-externalize.4255f25f.js} +661 -548
- package/dist/{chunk-vite-node-utils.b4debb0b.js → chunk-vite-node-utils.c160b239.js} +73 -71
- package/dist/cli.js +12 -12
- package/dist/entry.js +15 -919
- package/dist/index.d.ts +112 -31
- package/dist/index.js +8 -8
- package/dist/node.d.ts +40 -12
- package/dist/node.js +11 -11
- package/dist/spy.js +2 -102
- package/dist/vendor-_commonjsHelpers.addc3445.js +3 -0
- package/dist/vendor-entry.17835032.js +991 -0
- package/dist/vendor-index.405e58ef.js +6291 -0
- package/dist/{vendor-index.bd255bc8.js → vendor-index.40be925a.js} +173 -158
- package/dist/worker.js +9 -6
- package/package.json +9 -10
- package/vitest.mjs +1 -1
- package/dist/chunk-integrations-globals.b4a20711.js +0 -23
- package/dist/vendor-_commonjsHelpers.34b404ce.js +0 -7
- package/dist/vendor-index.13468339.js +0 -5707
package/dist/{chunk-vite-node-externalize.1c19fc5e.js → chunk-vite-node-externalize.4255f25f.js}
RENAMED
|
@@ -2,28 +2,28 @@ import { Buffer } from 'buffer';
|
|
|
2
2
|
import path$a from 'path';
|
|
3
3
|
import childProcess from 'child_process';
|
|
4
4
|
import process$1 from 'process';
|
|
5
|
-
import { s as signalExit, m as mergeStream, g as getStream, c as crossSpawn, o as onetime$1 } from './vendor-index.
|
|
5
|
+
import { s as signalExit, m as mergeStream, g as getStream, c as crossSpawn, o as onetime$1 } from './vendor-index.40be925a.js';
|
|
6
6
|
import url, { fileURLToPath, pathToFileURL } from 'url';
|
|
7
|
-
import require$$0, { constants as constants$5,
|
|
8
|
-
import { j as join,
|
|
7
|
+
import require$$0, { constants as constants$5, cpus, hostname } from 'os';
|
|
8
|
+
import { j as join, f as basename, h as dirname, k as resolve, p as picocolors, s as slash$2, l as isAbsolute, m as relative, o as getTests, q as getFullName, u as hasFailed, v as hasFailedSnapshot, w as getSuites, t as toArray, n as noop$1, x as deepMerge, y as toNamespacedPath, g as getCallLastIndex, e as notNullish, z as ensurePackageInstalled } from './chunk-utils-global.9b434e81.js';
|
|
9
9
|
import { createServer, mergeConfig } from 'vite';
|
|
10
|
-
import fs$8, { promises, existsSync } from 'fs';
|
|
11
|
-
import { d as distDir, a as defaultPort, c as configFiles } from './chunk-constants.
|
|
10
|
+
import fs$8, { promises, existsSync, readFileSync } from 'fs';
|
|
11
|
+
import { d as distDir, a as defaultPort, c as configFiles } from './chunk-constants.90075174.js';
|
|
12
12
|
import readline from 'readline';
|
|
13
13
|
import require$$0$1 from 'util';
|
|
14
14
|
import require$$0$2 from 'stream';
|
|
15
15
|
import require$$2 from 'events';
|
|
16
|
-
import {
|
|
17
|
-
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.
|
|
18
|
-
import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.
|
|
19
|
-
import { performance } from 'perf_hooks';
|
|
20
|
-
import { e as stripAnsi, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as setInterval, o as clearInterval, q as cliTruncate, s as setTimeout$1, b as parseStacktrace, r as interpretSourcePos, d as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE, c as clearTimeout$1 } from './chunk-utils-timers.b26e7c5c.js';
|
|
16
|
+
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
|
|
17
|
+
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.c160b239.js';
|
|
18
|
+
import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.fd5b939d.js';
|
|
21
19
|
import { MessageChannel } from 'worker_threads';
|
|
22
20
|
import { Tinypool } from 'tinypool';
|
|
21
|
+
import { performance } from 'perf_hooks';
|
|
22
|
+
import { e as stripAnsi, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as setInterval, o as clearInterval, q as cliTruncate, c as setTimeout$1, b as parseStacktrace, r as interpretSourcePos, s as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE, d as clearTimeout$1 } from './chunk-utils-timers.c50fec92.js';
|
|
23
23
|
import MagicString from './chunk-magic-string.d5e0e473.js';
|
|
24
|
-
import { p as prompts } from './vendor-index.
|
|
24
|
+
import { p as prompts } from './vendor-index.405e58ef.js';
|
|
25
25
|
|
|
26
|
-
var version = "0.
|
|
26
|
+
var version = "0.10.2";
|
|
27
27
|
|
|
28
28
|
function stripFinalNewline(input) {
|
|
29
29
|
const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
|
|
@@ -784,7 +784,7 @@ const setExitHandler = async (spawned, {cleanup, detached}, timedPromise) => {
|
|
|
784
784
|
return timedPromise;
|
|
785
785
|
}
|
|
786
786
|
|
|
787
|
-
const removeExitHandler = signalExit(() => {
|
|
787
|
+
const removeExitHandler = signalExit.exports(() => {
|
|
788
788
|
spawned.kill();
|
|
789
789
|
});
|
|
790
790
|
|
|
@@ -854,10 +854,10 @@ const getStreamPromise = (stream, {encoding, buffer, maxBuffer}) => {
|
|
|
854
854
|
}
|
|
855
855
|
|
|
856
856
|
if (encoding) {
|
|
857
|
-
return getStream(stream, {encoding, maxBuffer});
|
|
857
|
+
return getStream.exports(stream, {encoding, maxBuffer});
|
|
858
858
|
}
|
|
859
859
|
|
|
860
|
-
return getStream.buffer(stream, {maxBuffer});
|
|
860
|
+
return getStream.exports.buffer(stream, {maxBuffer});
|
|
861
861
|
};
|
|
862
862
|
|
|
863
863
|
// Retrieve result of child process: exit code, signal, error, streams (stdout/stderr/all)
|
|
@@ -951,7 +951,7 @@ const getEnv = ({env: envOption, extendEnv, preferLocal, localDir, execPath}) =>
|
|
|
951
951
|
};
|
|
952
952
|
|
|
953
953
|
const handleArguments = (file, args, options = {}) => {
|
|
954
|
-
const parsed = crossSpawn._parse(file, args, options);
|
|
954
|
+
const parsed = crossSpawn.exports._parse(file, args, options);
|
|
955
955
|
file = parsed.command;
|
|
956
956
|
args = parsed.args;
|
|
957
957
|
options = parsed.options;
|
|
@@ -1675,117 +1675,117 @@ var utils$j = {};
|
|
|
1675
1675
|
|
|
1676
1676
|
(function (exports) {
|
|
1677
1677
|
|
|
1678
|
-
exports.isInteger = num => {
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
};
|
|
1687
|
-
|
|
1688
|
-
/**
|
|
1689
|
-
* Find a node of the given type
|
|
1690
|
-
*/
|
|
1691
|
-
|
|
1692
|
-
exports.find = (node, type) => node.nodes.find(node => node.type === type);
|
|
1693
|
-
|
|
1694
|
-
/**
|
|
1695
|
-
* Find a node of the given type
|
|
1696
|
-
*/
|
|
1697
|
-
|
|
1698
|
-
exports.exceedsLimit = (min, max, step = 1, limit) => {
|
|
1699
|
-
if (limit === false) return false;
|
|
1700
|
-
if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
|
|
1701
|
-
return ((Number(max) - Number(min)) / Number(step)) >= limit;
|
|
1702
|
-
};
|
|
1703
|
-
|
|
1704
|
-
/**
|
|
1705
|
-
* Escape the given node with '\\' before node.value
|
|
1706
|
-
*/
|
|
1678
|
+
exports.isInteger = num => {
|
|
1679
|
+
if (typeof num === 'number') {
|
|
1680
|
+
return Number.isInteger(num);
|
|
1681
|
+
}
|
|
1682
|
+
if (typeof num === 'string' && num.trim() !== '') {
|
|
1683
|
+
return Number.isInteger(Number(num));
|
|
1684
|
+
}
|
|
1685
|
+
return false;
|
|
1686
|
+
};
|
|
1707
1687
|
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1688
|
+
/**
|
|
1689
|
+
* Find a node of the given type
|
|
1690
|
+
*/
|
|
1711
1691
|
|
|
1712
|
-
|
|
1713
|
-
if (node.escaped !== true) {
|
|
1714
|
-
node.value = '\\' + node.value;
|
|
1715
|
-
node.escaped = true;
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
};
|
|
1692
|
+
exports.find = (node, type) => node.nodes.find(node => node.type === type);
|
|
1719
1693
|
|
|
1720
|
-
/**
|
|
1721
|
-
|
|
1722
|
-
|
|
1694
|
+
/**
|
|
1695
|
+
* Find a node of the given type
|
|
1696
|
+
*/
|
|
1723
1697
|
|
|
1724
|
-
exports.
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
}
|
|
1730
|
-
return false;
|
|
1731
|
-
};
|
|
1698
|
+
exports.exceedsLimit = (min, max, step = 1, limit) => {
|
|
1699
|
+
if (limit === false) return false;
|
|
1700
|
+
if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
|
|
1701
|
+
return ((Number(max) - Number(min)) / Number(step)) >= limit;
|
|
1702
|
+
};
|
|
1732
1703
|
|
|
1733
|
-
/**
|
|
1734
|
-
|
|
1735
|
-
|
|
1704
|
+
/**
|
|
1705
|
+
* Escape the given node with '\\' before node.value
|
|
1706
|
+
*/
|
|
1736
1707
|
|
|
1737
|
-
exports.
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
if ((block.commas >> 0 + block.ranges >> 0) === 0) {
|
|
1741
|
-
block.invalid = true;
|
|
1742
|
-
return true;
|
|
1743
|
-
}
|
|
1744
|
-
if (block.open !== true || block.close !== true) {
|
|
1745
|
-
block.invalid = true;
|
|
1746
|
-
return true;
|
|
1747
|
-
}
|
|
1748
|
-
return false;
|
|
1749
|
-
};
|
|
1708
|
+
exports.escapeNode = (block, n = 0, type) => {
|
|
1709
|
+
let node = block.nodes[n];
|
|
1710
|
+
if (!node) return;
|
|
1750
1711
|
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1712
|
+
if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
|
|
1713
|
+
if (node.escaped !== true) {
|
|
1714
|
+
node.value = '\\' + node.value;
|
|
1715
|
+
node.escaped = true;
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
};
|
|
1754
1719
|
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1720
|
+
/**
|
|
1721
|
+
* Returns true if the given brace node should be enclosed in literal braces
|
|
1722
|
+
*/
|
|
1723
|
+
|
|
1724
|
+
exports.encloseBrace = node => {
|
|
1725
|
+
if (node.type !== 'brace') return false;
|
|
1726
|
+
if ((node.commas >> 0 + node.ranges >> 0) === 0) {
|
|
1727
|
+
node.invalid = true;
|
|
1728
|
+
return true;
|
|
1729
|
+
}
|
|
1730
|
+
return false;
|
|
1731
|
+
};
|
|
1761
1732
|
|
|
1762
|
-
/**
|
|
1763
|
-
|
|
1764
|
-
|
|
1733
|
+
/**
|
|
1734
|
+
* Returns true if a brace node is invalid.
|
|
1735
|
+
*/
|
|
1736
|
+
|
|
1737
|
+
exports.isInvalidBrace = block => {
|
|
1738
|
+
if (block.type !== 'brace') return false;
|
|
1739
|
+
if (block.invalid === true || block.dollar) return true;
|
|
1740
|
+
if ((block.commas >> 0 + block.ranges >> 0) === 0) {
|
|
1741
|
+
block.invalid = true;
|
|
1742
|
+
return true;
|
|
1743
|
+
}
|
|
1744
|
+
if (block.open !== true || block.close !== true) {
|
|
1745
|
+
block.invalid = true;
|
|
1746
|
+
return true;
|
|
1747
|
+
}
|
|
1748
|
+
return false;
|
|
1749
|
+
};
|
|
1765
1750
|
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
return acc;
|
|
1770
|
-
}, []);
|
|
1751
|
+
/**
|
|
1752
|
+
* Returns true if a node is an open or close node
|
|
1753
|
+
*/
|
|
1771
1754
|
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1755
|
+
exports.isOpenOrClose = node => {
|
|
1756
|
+
if (node.type === 'open' || node.type === 'close') {
|
|
1757
|
+
return true;
|
|
1758
|
+
}
|
|
1759
|
+
return node.open === true || node.close === true;
|
|
1760
|
+
};
|
|
1775
1761
|
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1762
|
+
/**
|
|
1763
|
+
* Reduce an array of text nodes.
|
|
1764
|
+
*/
|
|
1765
|
+
|
|
1766
|
+
exports.reduce = nodes => nodes.reduce((acc, node) => {
|
|
1767
|
+
if (node.type === 'text') acc.push(node.value);
|
|
1768
|
+
if (node.type === 'range') node.type = 'text';
|
|
1769
|
+
return acc;
|
|
1770
|
+
}, []);
|
|
1771
|
+
|
|
1772
|
+
/**
|
|
1773
|
+
* Flatten an array
|
|
1774
|
+
*/
|
|
1775
|
+
|
|
1776
|
+
exports.flatten = (...args) => {
|
|
1777
|
+
const result = [];
|
|
1778
|
+
const flat = arr => {
|
|
1779
|
+
for (let i = 0; i < arr.length; i++) {
|
|
1780
|
+
let ele = arr[i];
|
|
1781
|
+
Array.isArray(ele) ? flat(ele) : ele !== void 0 && result.push(ele);
|
|
1782
|
+
}
|
|
1783
|
+
return result;
|
|
1784
|
+
};
|
|
1785
|
+
flat(args);
|
|
1786
|
+
return result;
|
|
1787
|
+
};
|
|
1788
|
+
} (utils$j));
|
|
1789
1789
|
|
|
1790
1790
|
const utils$i = utils$j;
|
|
1791
1791
|
|
|
@@ -3091,6 +3091,8 @@ braces$1.create = (input, options = {}) => {
|
|
|
3091
3091
|
|
|
3092
3092
|
var braces_1 = braces$1;
|
|
3093
3093
|
|
|
3094
|
+
var picomatch$2 = {exports: {}};
|
|
3095
|
+
|
|
3094
3096
|
var utils$f = {};
|
|
3095
3097
|
|
|
3096
3098
|
const path$7 = path$a;
|
|
@@ -3273,69 +3275,69 @@ var constants$3 = {
|
|
|
3273
3275
|
|
|
3274
3276
|
(function (exports) {
|
|
3275
3277
|
|
|
3276
|
-
const path = path$a;
|
|
3277
|
-
const win32 = process.platform === 'win32';
|
|
3278
|
-
const {
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
} = constants$3;
|
|
3284
|
-
|
|
3285
|
-
exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
3286
|
-
exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
|
|
3287
|
-
exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
|
|
3288
|
-
exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
|
|
3289
|
-
exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
|
|
3290
|
-
|
|
3291
|
-
exports.removeBackslashes = str => {
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
};
|
|
3278
|
+
const path = path$a;
|
|
3279
|
+
const win32 = process.platform === 'win32';
|
|
3280
|
+
const {
|
|
3281
|
+
REGEX_BACKSLASH,
|
|
3282
|
+
REGEX_REMOVE_BACKSLASH,
|
|
3283
|
+
REGEX_SPECIAL_CHARS,
|
|
3284
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
3285
|
+
} = constants$3;
|
|
3286
|
+
|
|
3287
|
+
exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
3288
|
+
exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
|
|
3289
|
+
exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
|
|
3290
|
+
exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
|
|
3291
|
+
exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
|
|
3292
|
+
|
|
3293
|
+
exports.removeBackslashes = str => {
|
|
3294
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, match => {
|
|
3295
|
+
return match === '\\' ? '' : match;
|
|
3296
|
+
});
|
|
3297
|
+
};
|
|
3296
3298
|
|
|
3297
|
-
exports.supportsLookbehinds = () => {
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
};
|
|
3299
|
+
exports.supportsLookbehinds = () => {
|
|
3300
|
+
const segs = process.version.slice(1).split('.').map(Number);
|
|
3301
|
+
if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
|
|
3302
|
+
return true;
|
|
3303
|
+
}
|
|
3304
|
+
return false;
|
|
3305
|
+
};
|
|
3304
3306
|
|
|
3305
|
-
exports.isWindows = options => {
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
};
|
|
3307
|
+
exports.isWindows = options => {
|
|
3308
|
+
if (options && typeof options.windows === 'boolean') {
|
|
3309
|
+
return options.windows;
|
|
3310
|
+
}
|
|
3311
|
+
return win32 === true || path.sep === '\\';
|
|
3312
|
+
};
|
|
3311
3313
|
|
|
3312
|
-
exports.escapeLast = (input, char, lastIdx) => {
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
};
|
|
3314
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
3315
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
3316
|
+
if (idx === -1) return input;
|
|
3317
|
+
if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
|
|
3318
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
3319
|
+
};
|
|
3318
3320
|
|
|
3319
|
-
exports.removePrefix = (input, state = {}) => {
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
};
|
|
3321
|
+
exports.removePrefix = (input, state = {}) => {
|
|
3322
|
+
let output = input;
|
|
3323
|
+
if (output.startsWith('./')) {
|
|
3324
|
+
output = output.slice(2);
|
|
3325
|
+
state.prefix = './';
|
|
3326
|
+
}
|
|
3327
|
+
return output;
|
|
3328
|
+
};
|
|
3327
3329
|
|
|
3328
|
-
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
3329
|
-
|
|
3330
|
-
|
|
3330
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
3331
|
+
const prepend = options.contains ? '' : '^';
|
|
3332
|
+
const append = options.contains ? '' : '$';
|
|
3331
3333
|
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
};
|
|
3338
|
-
}(utils$f));
|
|
3334
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
3335
|
+
if (state.negated === true) {
|
|
3336
|
+
output = `(?:^(?!${output}).*$)`;
|
|
3337
|
+
}
|
|
3338
|
+
return output;
|
|
3339
|
+
};
|
|
3340
|
+
} (utils$f));
|
|
3339
3341
|
|
|
3340
3342
|
const utils$e = utils$f;
|
|
3341
3343
|
const {
|
|
@@ -4846,9 +4848,9 @@ const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
|
4846
4848
|
* @api public
|
|
4847
4849
|
*/
|
|
4848
4850
|
|
|
4849
|
-
const picomatch$
|
|
4851
|
+
const picomatch$1 = (glob, options, returnState = false) => {
|
|
4850
4852
|
if (Array.isArray(glob)) {
|
|
4851
|
-
const fns = glob.map(input => picomatch$
|
|
4853
|
+
const fns = glob.map(input => picomatch$1(input, options, returnState));
|
|
4852
4854
|
const arrayMatcher = str => {
|
|
4853
4855
|
for (const isMatch of fns) {
|
|
4854
4856
|
const state = isMatch(str);
|
|
@@ -4868,8 +4870,8 @@ const picomatch$2 = (glob, options, returnState = false) => {
|
|
|
4868
4870
|
const opts = options || {};
|
|
4869
4871
|
const posix = utils$c.isWindows(options);
|
|
4870
4872
|
const regex = isState
|
|
4871
|
-
? picomatch$
|
|
4872
|
-
: picomatch$
|
|
4873
|
+
? picomatch$1.compileRe(glob, options)
|
|
4874
|
+
: picomatch$1.makeRe(glob, options, false, true);
|
|
4873
4875
|
|
|
4874
4876
|
const state = regex.state;
|
|
4875
4877
|
delete regex.state;
|
|
@@ -4877,11 +4879,11 @@ const picomatch$2 = (glob, options, returnState = false) => {
|
|
|
4877
4879
|
let isIgnored = () => false;
|
|
4878
4880
|
if (opts.ignore) {
|
|
4879
4881
|
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
4880
|
-
isIgnored = picomatch$
|
|
4882
|
+
isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
|
|
4881
4883
|
}
|
|
4882
4884
|
|
|
4883
4885
|
const matcher = (input, returnObject = false) => {
|
|
4884
|
-
const { isMatch, match, output } = picomatch$
|
|
4886
|
+
const { isMatch, match, output } = picomatch$1.test(input, regex, options, { glob, posix });
|
|
4885
4887
|
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
4886
4888
|
|
|
4887
4889
|
if (typeof opts.onResult === 'function') {
|
|
@@ -4931,7 +4933,7 @@ const picomatch$2 = (glob, options, returnState = false) => {
|
|
|
4931
4933
|
* @api public
|
|
4932
4934
|
*/
|
|
4933
4935
|
|
|
4934
|
-
picomatch$
|
|
4936
|
+
picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
|
|
4935
4937
|
if (typeof input !== 'string') {
|
|
4936
4938
|
throw new TypeError('Expected input to be a string');
|
|
4937
4939
|
}
|
|
@@ -4952,7 +4954,7 @@ picomatch$2.test = (input, regex, options, { glob, posix } = {}) => {
|
|
|
4952
4954
|
|
|
4953
4955
|
if (match === false || opts.capture === true) {
|
|
4954
4956
|
if (opts.matchBase === true || opts.basename === true) {
|
|
4955
|
-
match = picomatch$
|
|
4957
|
+
match = picomatch$1.matchBase(input, regex, options, posix);
|
|
4956
4958
|
} else {
|
|
4957
4959
|
match = regex.exec(output);
|
|
4958
4960
|
}
|
|
@@ -4975,8 +4977,8 @@ picomatch$2.test = (input, regex, options, { glob, posix } = {}) => {
|
|
|
4975
4977
|
* @api public
|
|
4976
4978
|
*/
|
|
4977
4979
|
|
|
4978
|
-
picomatch$
|
|
4979
|
-
const regex = glob instanceof RegExp ? glob : picomatch$
|
|
4980
|
+
picomatch$1.matchBase = (input, glob, options, posix = utils$c.isWindows(options)) => {
|
|
4981
|
+
const regex = glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options);
|
|
4980
4982
|
return regex.test(path$6.basename(input));
|
|
4981
4983
|
};
|
|
4982
4984
|
|
|
@@ -4997,7 +4999,7 @@ picomatch$2.matchBase = (input, glob, options, posix = utils$c.isWindows(options
|
|
|
4997
4999
|
* @api public
|
|
4998
5000
|
*/
|
|
4999
5001
|
|
|
5000
|
-
picomatch$
|
|
5002
|
+
picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
|
|
5001
5003
|
|
|
5002
5004
|
/**
|
|
5003
5005
|
* Parse a glob pattern to create the source string for a regular
|
|
@@ -5013,8 +5015,8 @@ picomatch$2.isMatch = (str, patterns, options) => picomatch$2(patterns, options)
|
|
|
5013
5015
|
* @api public
|
|
5014
5016
|
*/
|
|
5015
5017
|
|
|
5016
|
-
picomatch$
|
|
5017
|
-
if (Array.isArray(pattern)) return pattern.map(p => picomatch$
|
|
5018
|
+
picomatch$1.parse = (pattern, options) => {
|
|
5019
|
+
if (Array.isArray(pattern)) return pattern.map(p => picomatch$1.parse(p, options));
|
|
5018
5020
|
return parse(pattern, { ...options, fastpaths: false });
|
|
5019
5021
|
};
|
|
5020
5022
|
|
|
@@ -5045,7 +5047,7 @@ picomatch$2.parse = (pattern, options) => {
|
|
|
5045
5047
|
* @api public
|
|
5046
5048
|
*/
|
|
5047
5049
|
|
|
5048
|
-
picomatch$
|
|
5050
|
+
picomatch$1.scan = (input, options) => scan(input, options);
|
|
5049
5051
|
|
|
5050
5052
|
/**
|
|
5051
5053
|
* Compile a regular expression from the `state` object returned by the
|
|
@@ -5059,7 +5061,7 @@ picomatch$2.scan = (input, options) => scan(input, options);
|
|
|
5059
5061
|
* @api public
|
|
5060
5062
|
*/
|
|
5061
5063
|
|
|
5062
|
-
picomatch$
|
|
5064
|
+
picomatch$1.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
5063
5065
|
if (returnOutput === true) {
|
|
5064
5066
|
return state.output;
|
|
5065
5067
|
}
|
|
@@ -5073,7 +5075,7 @@ picomatch$2.compileRe = (state, options, returnOutput = false, returnState = fal
|
|
|
5073
5075
|
source = `^(?!${source}).*$`;
|
|
5074
5076
|
}
|
|
5075
5077
|
|
|
5076
|
-
const regex = picomatch$
|
|
5078
|
+
const regex = picomatch$1.toRegex(source, options);
|
|
5077
5079
|
if (returnState === true) {
|
|
5078
5080
|
regex.state = state;
|
|
5079
5081
|
}
|
|
@@ -5100,7 +5102,7 @@ picomatch$2.compileRe = (state, options, returnOutput = false, returnState = fal
|
|
|
5100
5102
|
* @api public
|
|
5101
5103
|
*/
|
|
5102
5104
|
|
|
5103
|
-
picomatch$
|
|
5105
|
+
picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
5104
5106
|
if (!input || typeof input !== 'string') {
|
|
5105
5107
|
throw new TypeError('Expected a non-empty string');
|
|
5106
5108
|
}
|
|
@@ -5115,7 +5117,7 @@ picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = f
|
|
|
5115
5117
|
parsed = parse(input, options);
|
|
5116
5118
|
}
|
|
5117
5119
|
|
|
5118
|
-
return picomatch$
|
|
5120
|
+
return picomatch$1.compileRe(parsed, options, returnOutput, returnState);
|
|
5119
5121
|
};
|
|
5120
5122
|
|
|
5121
5123
|
/**
|
|
@@ -5135,7 +5137,7 @@ picomatch$2.makeRe = (input, options = {}, returnOutput = false, returnState = f
|
|
|
5135
5137
|
* @api public
|
|
5136
5138
|
*/
|
|
5137
5139
|
|
|
5138
|
-
picomatch$
|
|
5140
|
+
picomatch$1.toRegex = (source, options) => {
|
|
5139
5141
|
try {
|
|
5140
5142
|
const opts = options || {};
|
|
5141
5143
|
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
|
@@ -5150,19 +5152,22 @@ picomatch$2.toRegex = (source, options) => {
|
|
|
5150
5152
|
* @return {Object}
|
|
5151
5153
|
*/
|
|
5152
5154
|
|
|
5153
|
-
picomatch$
|
|
5155
|
+
picomatch$1.constants = constants$1;
|
|
5154
5156
|
|
|
5155
5157
|
/**
|
|
5156
5158
|
* Expose "picomatch"
|
|
5157
5159
|
*/
|
|
5158
5160
|
|
|
5159
|
-
var picomatch_1 = picomatch$
|
|
5161
|
+
var picomatch_1 = picomatch$1;
|
|
5162
|
+
|
|
5163
|
+
(function (module) {
|
|
5160
5164
|
|
|
5161
|
-
|
|
5165
|
+
module.exports = picomatch_1;
|
|
5166
|
+
} (picomatch$2));
|
|
5162
5167
|
|
|
5163
5168
|
const util = require$$0$1;
|
|
5164
5169
|
const braces = braces_1;
|
|
5165
|
-
const picomatch = picomatch$
|
|
5170
|
+
const picomatch = picomatch$2.exports;
|
|
5166
5171
|
const utils$b = utils$f;
|
|
5167
5172
|
const isEmptyString = val => val === '' || val === './';
|
|
5168
5173
|
|
|
@@ -6165,23 +6170,23 @@ var settings$3 = {};
|
|
|
6165
6170
|
var fs$5 = {};
|
|
6166
6171
|
|
|
6167
6172
|
(function (exports) {
|
|
6168
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6169
|
-
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
6170
|
-
const fs = fs$8;
|
|
6171
|
-
exports.FILE_SYSTEM_ADAPTER = {
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
};
|
|
6177
|
-
function createFileSystemAdapter(fsMethods) {
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6182
|
-
}
|
|
6183
|
-
exports.createFileSystemAdapter = createFileSystemAdapter;
|
|
6184
|
-
}(fs$5));
|
|
6173
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6174
|
+
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
6175
|
+
const fs = fs$8;
|
|
6176
|
+
exports.FILE_SYSTEM_ADAPTER = {
|
|
6177
|
+
lstat: fs.lstat,
|
|
6178
|
+
stat: fs.stat,
|
|
6179
|
+
lstatSync: fs.lstatSync,
|
|
6180
|
+
statSync: fs.statSync
|
|
6181
|
+
};
|
|
6182
|
+
function createFileSystemAdapter(fsMethods) {
|
|
6183
|
+
if (fsMethods === undefined) {
|
|
6184
|
+
return exports.FILE_SYSTEM_ADAPTER;
|
|
6185
|
+
}
|
|
6186
|
+
return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
|
|
6187
|
+
}
|
|
6188
|
+
exports.createFileSystemAdapter = createFileSystemAdapter;
|
|
6189
|
+
} (fs$5));
|
|
6185
6190
|
|
|
6186
6191
|
Object.defineProperty(settings$3, "__esModule", { value: true });
|
|
6187
6192
|
const fs$4 = fs$5;
|
|
@@ -6526,25 +6531,25 @@ var settings$2 = {};
|
|
|
6526
6531
|
var fs$1 = {};
|
|
6527
6532
|
|
|
6528
6533
|
(function (exports) {
|
|
6529
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6530
|
-
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
6531
|
-
const fs = fs$8;
|
|
6532
|
-
exports.FILE_SYSTEM_ADAPTER = {
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
};
|
|
6540
|
-
function createFileSystemAdapter(fsMethods) {
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
}
|
|
6546
|
-
exports.createFileSystemAdapter = createFileSystemAdapter;
|
|
6547
|
-
}(fs$1));
|
|
6534
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6535
|
+
exports.createFileSystemAdapter = exports.FILE_SYSTEM_ADAPTER = void 0;
|
|
6536
|
+
const fs = fs$8;
|
|
6537
|
+
exports.FILE_SYSTEM_ADAPTER = {
|
|
6538
|
+
lstat: fs.lstat,
|
|
6539
|
+
stat: fs.stat,
|
|
6540
|
+
lstatSync: fs.lstatSync,
|
|
6541
|
+
statSync: fs.statSync,
|
|
6542
|
+
readdir: fs.readdir,
|
|
6543
|
+
readdirSync: fs.readdirSync
|
|
6544
|
+
};
|
|
6545
|
+
function createFileSystemAdapter(fsMethods) {
|
|
6546
|
+
if (fsMethods === undefined) {
|
|
6547
|
+
return exports.FILE_SYSTEM_ADAPTER;
|
|
6548
|
+
}
|
|
6549
|
+
return Object.assign(Object.assign({}, exports.FILE_SYSTEM_ADAPTER), fsMethods);
|
|
6550
|
+
}
|
|
6551
|
+
exports.createFileSystemAdapter = createFileSystemAdapter;
|
|
6552
|
+
} (fs$1));
|
|
6548
6553
|
|
|
6549
6554
|
Object.defineProperty(settings$2, "__esModule", { value: true });
|
|
6550
6555
|
const path$3 = path$a;
|
|
@@ -7797,63 +7802,63 @@ sync$1.default = ProviderSync;
|
|
|
7797
7802
|
var settings = {};
|
|
7798
7803
|
|
|
7799
7804
|
(function (exports) {
|
|
7800
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7801
|
-
exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
|
|
7802
|
-
const fs = fs$8;
|
|
7803
|
-
const os = require$$0;
|
|
7804
|
-
/**
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
const CPU_COUNT = Math.max(os.cpus().length, 1);
|
|
7809
|
-
exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
};
|
|
7817
|
-
class Settings {
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
}
|
|
7855
|
-
exports.default = Settings;
|
|
7856
|
-
}(settings));
|
|
7805
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7806
|
+
exports.DEFAULT_FILE_SYSTEM_ADAPTER = void 0;
|
|
7807
|
+
const fs = fs$8;
|
|
7808
|
+
const os = require$$0;
|
|
7809
|
+
/**
|
|
7810
|
+
* The `os.cpus` method can return zero. We expect the number of cores to be greater than zero.
|
|
7811
|
+
* https://github.com/nodejs/node/blob/7faeddf23a98c53896f8b574a6e66589e8fb1eb8/lib/os.js#L106-L107
|
|
7812
|
+
*/
|
|
7813
|
+
const CPU_COUNT = Math.max(os.cpus().length, 1);
|
|
7814
|
+
exports.DEFAULT_FILE_SYSTEM_ADAPTER = {
|
|
7815
|
+
lstat: fs.lstat,
|
|
7816
|
+
lstatSync: fs.lstatSync,
|
|
7817
|
+
stat: fs.stat,
|
|
7818
|
+
statSync: fs.statSync,
|
|
7819
|
+
readdir: fs.readdir,
|
|
7820
|
+
readdirSync: fs.readdirSync
|
|
7821
|
+
};
|
|
7822
|
+
class Settings {
|
|
7823
|
+
constructor(_options = {}) {
|
|
7824
|
+
this._options = _options;
|
|
7825
|
+
this.absolute = this._getValue(this._options.absolute, false);
|
|
7826
|
+
this.baseNameMatch = this._getValue(this._options.baseNameMatch, false);
|
|
7827
|
+
this.braceExpansion = this._getValue(this._options.braceExpansion, true);
|
|
7828
|
+
this.caseSensitiveMatch = this._getValue(this._options.caseSensitiveMatch, true);
|
|
7829
|
+
this.concurrency = this._getValue(this._options.concurrency, CPU_COUNT);
|
|
7830
|
+
this.cwd = this._getValue(this._options.cwd, process.cwd());
|
|
7831
|
+
this.deep = this._getValue(this._options.deep, Infinity);
|
|
7832
|
+
this.dot = this._getValue(this._options.dot, false);
|
|
7833
|
+
this.extglob = this._getValue(this._options.extglob, true);
|
|
7834
|
+
this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, true);
|
|
7835
|
+
this.fs = this._getFileSystemMethods(this._options.fs);
|
|
7836
|
+
this.globstar = this._getValue(this._options.globstar, true);
|
|
7837
|
+
this.ignore = this._getValue(this._options.ignore, []);
|
|
7838
|
+
this.markDirectories = this._getValue(this._options.markDirectories, false);
|
|
7839
|
+
this.objectMode = this._getValue(this._options.objectMode, false);
|
|
7840
|
+
this.onlyDirectories = this._getValue(this._options.onlyDirectories, false);
|
|
7841
|
+
this.onlyFiles = this._getValue(this._options.onlyFiles, true);
|
|
7842
|
+
this.stats = this._getValue(this._options.stats, false);
|
|
7843
|
+
this.suppressErrors = this._getValue(this._options.suppressErrors, false);
|
|
7844
|
+
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, false);
|
|
7845
|
+
this.unique = this._getValue(this._options.unique, true);
|
|
7846
|
+
if (this.onlyDirectories) {
|
|
7847
|
+
this.onlyFiles = false;
|
|
7848
|
+
}
|
|
7849
|
+
if (this.stats) {
|
|
7850
|
+
this.objectMode = true;
|
|
7851
|
+
}
|
|
7852
|
+
}
|
|
7853
|
+
_getValue(option, value) {
|
|
7854
|
+
return option === undefined ? value : option;
|
|
7855
|
+
}
|
|
7856
|
+
_getFileSystemMethods(methods = {}) {
|
|
7857
|
+
return Object.assign(Object.assign({}, exports.DEFAULT_FILE_SYSTEM_ADAPTER), methods);
|
|
7858
|
+
}
|
|
7859
|
+
}
|
|
7860
|
+
exports.default = Settings;
|
|
7861
|
+
} (settings));
|
|
7857
7862
|
|
|
7858
7863
|
const taskManager = tasks;
|
|
7859
7864
|
const patternManager = patterns;
|
|
@@ -8170,6 +8175,133 @@ function addSnapshotResult(summary, result) {
|
|
|
8170
8175
|
summary.total += result.added + result.matched + result.unmatched + result.updated;
|
|
8171
8176
|
}
|
|
8172
8177
|
|
|
8178
|
+
function createPool(ctx) {
|
|
8179
|
+
if (ctx.config.threads)
|
|
8180
|
+
return createWorkerPool(ctx);
|
|
8181
|
+
else
|
|
8182
|
+
return createFakePool(ctx);
|
|
8183
|
+
}
|
|
8184
|
+
const workerPath = pathToFileURL(resolve(distDir, "./worker.js")).href;
|
|
8185
|
+
function createFakePool(ctx) {
|
|
8186
|
+
const runWithFiles = (name) => {
|
|
8187
|
+
return async (files, invalidates) => {
|
|
8188
|
+
const worker = await import(workerPath);
|
|
8189
|
+
const { workerPort, port } = createChannel(ctx);
|
|
8190
|
+
const data = {
|
|
8191
|
+
port: workerPort,
|
|
8192
|
+
config: ctx.getConfig(),
|
|
8193
|
+
files,
|
|
8194
|
+
invalidates,
|
|
8195
|
+
id: 1
|
|
8196
|
+
};
|
|
8197
|
+
await worker[name](data, { transferList: [workerPort] });
|
|
8198
|
+
port.close();
|
|
8199
|
+
workerPort.close();
|
|
8200
|
+
};
|
|
8201
|
+
};
|
|
8202
|
+
return {
|
|
8203
|
+
runTests: runWithFiles("run"),
|
|
8204
|
+
collectTests: runWithFiles("collect"),
|
|
8205
|
+
close: async () => {
|
|
8206
|
+
}
|
|
8207
|
+
};
|
|
8208
|
+
}
|
|
8209
|
+
function createWorkerPool(ctx) {
|
|
8210
|
+
const threadsCount = ctx.config.watch ? Math.max(cpus().length / 2, 1) : Math.max(cpus().length - 1, 1);
|
|
8211
|
+
const options = {
|
|
8212
|
+
filename: workerPath,
|
|
8213
|
+
useAtomics: typeof process.versions.webcontainer !== "string",
|
|
8214
|
+
maxThreads: ctx.config.maxThreads ?? threadsCount,
|
|
8215
|
+
minThreads: ctx.config.minThreads ?? threadsCount
|
|
8216
|
+
};
|
|
8217
|
+
if (ctx.config.isolate) {
|
|
8218
|
+
options.isolateWorkers = true;
|
|
8219
|
+
options.concurrentTasksPerWorker = 1;
|
|
8220
|
+
}
|
|
8221
|
+
const pool = new Tinypool(options);
|
|
8222
|
+
const runWithFiles = (name) => {
|
|
8223
|
+
return async (files, invalidates) => {
|
|
8224
|
+
let id = 0;
|
|
8225
|
+
await Promise.all(files.map(async (file) => {
|
|
8226
|
+
const { workerPort, port } = createChannel(ctx);
|
|
8227
|
+
const data = {
|
|
8228
|
+
port: workerPort,
|
|
8229
|
+
config: ctx.getConfig(),
|
|
8230
|
+
files: [file],
|
|
8231
|
+
invalidates,
|
|
8232
|
+
id: ++id
|
|
8233
|
+
};
|
|
8234
|
+
await pool.run(data, { transferList: [workerPort], name });
|
|
8235
|
+
port.close();
|
|
8236
|
+
workerPort.close();
|
|
8237
|
+
}));
|
|
8238
|
+
};
|
|
8239
|
+
};
|
|
8240
|
+
return {
|
|
8241
|
+
runTests: runWithFiles("run"),
|
|
8242
|
+
collectTests: runWithFiles("collect"),
|
|
8243
|
+
close: async () => {
|
|
8244
|
+
}
|
|
8245
|
+
};
|
|
8246
|
+
}
|
|
8247
|
+
function createChannel(ctx) {
|
|
8248
|
+
const channel = new MessageChannel();
|
|
8249
|
+
const port = channel.port2;
|
|
8250
|
+
const workerPort = channel.port1;
|
|
8251
|
+
createBirpc({
|
|
8252
|
+
onWorkerExit(code) {
|
|
8253
|
+
process.exit(code || 1);
|
|
8254
|
+
},
|
|
8255
|
+
snapshotSaved(snapshot) {
|
|
8256
|
+
ctx.snapshot.add(snapshot);
|
|
8257
|
+
},
|
|
8258
|
+
resolveSnapshotPath(testPath) {
|
|
8259
|
+
return ctx.snapshot.resolvePath(testPath);
|
|
8260
|
+
},
|
|
8261
|
+
async getSourceMap(id, force) {
|
|
8262
|
+
if (force) {
|
|
8263
|
+
const mod = ctx.server.moduleGraph.getModuleById(id);
|
|
8264
|
+
if (mod)
|
|
8265
|
+
ctx.server.moduleGraph.invalidateModule(mod);
|
|
8266
|
+
}
|
|
8267
|
+
const r = await ctx.vitenode.transformRequest(id);
|
|
8268
|
+
return r == null ? void 0 : r.map;
|
|
8269
|
+
},
|
|
8270
|
+
fetch(id) {
|
|
8271
|
+
return ctx.vitenode.fetchModule(id);
|
|
8272
|
+
},
|
|
8273
|
+
resolveId(id, importer) {
|
|
8274
|
+
return ctx.vitenode.resolveId(id, importer);
|
|
8275
|
+
},
|
|
8276
|
+
onCollected(files) {
|
|
8277
|
+
ctx.state.collectFiles(files);
|
|
8278
|
+
ctx.report("onCollected", files);
|
|
8279
|
+
},
|
|
8280
|
+
onTaskUpdate(packs) {
|
|
8281
|
+
ctx.state.updateTasks(packs);
|
|
8282
|
+
ctx.report("onTaskUpdate", packs);
|
|
8283
|
+
},
|
|
8284
|
+
onUserConsoleLog(log) {
|
|
8285
|
+
ctx.state.updateUserLog(log);
|
|
8286
|
+
ctx.report("onUserConsoleLog", log);
|
|
8287
|
+
},
|
|
8288
|
+
onUnhandledRejection(err) {
|
|
8289
|
+
ctx.state.catchError(err, "Unhandled Rejection");
|
|
8290
|
+
},
|
|
8291
|
+
onFinished(files) {
|
|
8292
|
+
ctx.report("onFinished", files, ctx.state.getUnhandledErrors());
|
|
8293
|
+
}
|
|
8294
|
+
}, {
|
|
8295
|
+
post(v) {
|
|
8296
|
+
port.postMessage(v);
|
|
8297
|
+
},
|
|
8298
|
+
on(fn) {
|
|
8299
|
+
port.on("message", fn);
|
|
8300
|
+
}
|
|
8301
|
+
});
|
|
8302
|
+
return { workerPort, port };
|
|
8303
|
+
}
|
|
8304
|
+
|
|
8173
8305
|
const F_RIGHT = "\u2192";
|
|
8174
8306
|
const F_DOWN = "\u2193";
|
|
8175
8307
|
const F_DOWN_RIGHT = "\u21B3";
|
|
@@ -8181,8 +8313,8 @@ const F_LONG_DASH = "\u23AF";
|
|
|
8181
8313
|
|
|
8182
8314
|
const spinnerMap = /* @__PURE__ */ new WeakMap();
|
|
8183
8315
|
const hookSpinnerMap = /* @__PURE__ */ new WeakMap();
|
|
8184
|
-
const pointer =
|
|
8185
|
-
const skipped =
|
|
8316
|
+
const pointer = picocolors.exports.yellow(F_POINTER);
|
|
8317
|
+
const skipped = picocolors.exports.dim(picocolors.exports.gray(F_DOWN));
|
|
8186
8318
|
function getCols(delta = 0) {
|
|
8187
8319
|
let length = process.stdout.columns;
|
|
8188
8320
|
if (!length || isNaN(length))
|
|
@@ -8212,44 +8344,44 @@ function formatTestPath(root, path) {
|
|
|
8212
8344
|
const dir = dirname(path);
|
|
8213
8345
|
const ext = ((_a = path.match(/(\.(spec|test)\.[cm]?[tj]sx?)$/)) == null ? void 0 : _a[0]) || "";
|
|
8214
8346
|
const base = basename(path, ext);
|
|
8215
|
-
return slash$2(
|
|
8347
|
+
return slash$2(picocolors.exports.dim(`${dir}/`) + picocolors.exports.bold(base)) + picocolors.exports.dim(ext);
|
|
8216
8348
|
}
|
|
8217
8349
|
function renderSnapshotSummary(rootDir, snapshots) {
|
|
8218
8350
|
const summary = [];
|
|
8219
8351
|
if (snapshots.added)
|
|
8220
|
-
summary.push(
|
|
8352
|
+
summary.push(picocolors.exports.bold(picocolors.exports.green(`${snapshots.added} written`)));
|
|
8221
8353
|
if (snapshots.unmatched)
|
|
8222
|
-
summary.push(
|
|
8354
|
+
summary.push(picocolors.exports.bold(picocolors.exports.red(`${snapshots.unmatched} failed`)));
|
|
8223
8355
|
if (snapshots.updated)
|
|
8224
|
-
summary.push(
|
|
8356
|
+
summary.push(picocolors.exports.bold(picocolors.exports.green(`${snapshots.updated} updated `)));
|
|
8225
8357
|
if (snapshots.filesRemoved) {
|
|
8226
8358
|
if (snapshots.didUpdate)
|
|
8227
|
-
summary.push(
|
|
8359
|
+
summary.push(picocolors.exports.bold(picocolors.exports.green(`${snapshots.filesRemoved} files removed `)));
|
|
8228
8360
|
else
|
|
8229
|
-
summary.push(
|
|
8361
|
+
summary.push(picocolors.exports.bold(picocolors.exports.yellow(`${snapshots.filesRemoved} files obsolete `)));
|
|
8230
8362
|
}
|
|
8231
8363
|
if (snapshots.filesRemovedList && snapshots.filesRemovedList.length) {
|
|
8232
8364
|
const [head, ...tail] = snapshots.filesRemovedList;
|
|
8233
|
-
summary.push(`${
|
|
8365
|
+
summary.push(`${picocolors.exports.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, head)}`);
|
|
8234
8366
|
tail.forEach((key) => {
|
|
8235
|
-
summary.push(` ${
|
|
8367
|
+
summary.push(` ${picocolors.exports.gray(F_DOT)} ${formatTestPath(rootDir, key)}`);
|
|
8236
8368
|
});
|
|
8237
8369
|
}
|
|
8238
8370
|
if (snapshots.unchecked) {
|
|
8239
8371
|
if (snapshots.didUpdate)
|
|
8240
|
-
summary.push(
|
|
8372
|
+
summary.push(picocolors.exports.bold(picocolors.exports.green(`${snapshots.unchecked} removed`)));
|
|
8241
8373
|
else
|
|
8242
|
-
summary.push(
|
|
8374
|
+
summary.push(picocolors.exports.bold(picocolors.exports.yellow(`${snapshots.unchecked} obsolete`)));
|
|
8243
8375
|
snapshots.uncheckedKeysByFile.forEach((uncheckedFile) => {
|
|
8244
|
-
summary.push(`${
|
|
8245
|
-
uncheckedFile.keys.forEach((key) => summary.push(` ${
|
|
8376
|
+
summary.push(`${picocolors.exports.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, uncheckedFile.filePath)}`);
|
|
8377
|
+
uncheckedFile.keys.forEach((key) => summary.push(` ${picocolors.exports.gray(F_DOT)} ${key}`));
|
|
8246
8378
|
});
|
|
8247
8379
|
}
|
|
8248
8380
|
return summary;
|
|
8249
8381
|
}
|
|
8250
8382
|
function getStateString(tasks, name = "tests") {
|
|
8251
8383
|
if (tasks.length === 0)
|
|
8252
|
-
return
|
|
8384
|
+
return picocolors.exports.dim(`no ${name}`);
|
|
8253
8385
|
const passed = tasks.filter((i) => {
|
|
8254
8386
|
var _a;
|
|
8255
8387
|
return ((_a = i.result) == null ? void 0 : _a.state) === "pass";
|
|
@@ -8261,17 +8393,17 @@ function getStateString(tasks, name = "tests") {
|
|
|
8261
8393
|
const skipped2 = tasks.filter((i) => i.mode === "skip");
|
|
8262
8394
|
const todo = tasks.filter((i) => i.mode === "todo");
|
|
8263
8395
|
return [
|
|
8264
|
-
failed.length ?
|
|
8265
|
-
passed.length ?
|
|
8266
|
-
skipped2.length ?
|
|
8267
|
-
todo.length ?
|
|
8268
|
-
].filter(Boolean).join(
|
|
8396
|
+
failed.length ? picocolors.exports.bold(picocolors.exports.red(`${failed.length} failed`)) : null,
|
|
8397
|
+
passed.length ? picocolors.exports.bold(picocolors.exports.green(`${passed.length} passed`)) : null,
|
|
8398
|
+
skipped2.length ? picocolors.exports.yellow(`${skipped2.length} skipped`) : null,
|
|
8399
|
+
todo.length ? picocolors.exports.gray(`${todo.length} todo`) : null
|
|
8400
|
+
].filter(Boolean).join(picocolors.exports.dim(" | ")) + picocolors.exports.gray(` (${tasks.length})`);
|
|
8269
8401
|
}
|
|
8270
8402
|
function getStateSymbol(task) {
|
|
8271
8403
|
if (task.mode === "skip" || task.mode === "todo")
|
|
8272
8404
|
return skipped;
|
|
8273
8405
|
if (!task.result)
|
|
8274
|
-
return
|
|
8406
|
+
return picocolors.exports.gray("\xB7");
|
|
8275
8407
|
if (task.result.state === "run") {
|
|
8276
8408
|
if (task.type === "suite")
|
|
8277
8409
|
return pointer;
|
|
@@ -8280,12 +8412,12 @@ function getStateSymbol(task) {
|
|
|
8280
8412
|
spinner = elegantSpinner();
|
|
8281
8413
|
spinnerMap.set(task, spinner);
|
|
8282
8414
|
}
|
|
8283
|
-
return
|
|
8415
|
+
return picocolors.exports.yellow(spinner());
|
|
8284
8416
|
}
|
|
8285
8417
|
if (task.result.state === "pass")
|
|
8286
|
-
return
|
|
8418
|
+
return picocolors.exports.green(F_CHECK);
|
|
8287
8419
|
if (task.result.state === "fail") {
|
|
8288
|
-
return task.type === "suite" ? pointer :
|
|
8420
|
+
return task.type === "suite" ? pointer : picocolors.exports.red(F_CROSS);
|
|
8289
8421
|
}
|
|
8290
8422
|
return " ";
|
|
8291
8423
|
}
|
|
@@ -8303,7 +8435,7 @@ function getHookStateSymbol(task, hookName) {
|
|
|
8303
8435
|
spinner = elegantSpinner();
|
|
8304
8436
|
spinnerMap2.set(hookName, spinner);
|
|
8305
8437
|
}
|
|
8306
|
-
return
|
|
8438
|
+
return picocolors.exports.yellow(spinner());
|
|
8307
8439
|
}
|
|
8308
8440
|
}
|
|
8309
8441
|
const spinnerFrames = process.platform === "win32" ? ["-", "\\", "|", "/"] : ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
@@ -8316,13 +8448,14 @@ function elegantSpinner() {
|
|
|
8316
8448
|
}
|
|
8317
8449
|
|
|
8318
8450
|
const BADGE_PADDING = " ";
|
|
8319
|
-
const HELP_HINT = `${
|
|
8320
|
-
const HELP_UPDATE_SNAP =
|
|
8321
|
-
const HELP_QUITE = `${
|
|
8451
|
+
const HELP_HINT = `${picocolors.exports.dim("press ")}${picocolors.exports.bold("h")}${picocolors.exports.dim(" to show help")}`;
|
|
8452
|
+
const HELP_UPDATE_SNAP = picocolors.exports.dim("press ") + picocolors.exports.bold(picocolors.exports.yellow("u")) + picocolors.exports.dim(" to update snapshot");
|
|
8453
|
+
const HELP_QUITE = `${picocolors.exports.dim("press ")}${picocolors.exports.bold("q")}${picocolors.exports.dim(" to quit")}`;
|
|
8322
8454
|
const WAIT_FOR_CHANGE_PASS = `
|
|
8323
|
-
${
|
|
8455
|
+
${picocolors.exports.bold(picocolors.exports.inverse(picocolors.exports.green(" PASS ")))}${picocolors.exports.green(" Waiting for file changes...")}`;
|
|
8324
8456
|
const WAIT_FOR_CHANGE_FAIL = `
|
|
8325
|
-
${
|
|
8457
|
+
${picocolors.exports.bold(picocolors.exports.inverse(picocolors.exports.red(" FAIL ")))}${picocolors.exports.red(" Tests failed. Watching for file changes...")}`;
|
|
8458
|
+
const DURATION_LONG$1 = 300;
|
|
8326
8459
|
class BaseReporter {
|
|
8327
8460
|
constructor() {
|
|
8328
8461
|
this.start = 0;
|
|
@@ -8335,22 +8468,34 @@ class BaseReporter {
|
|
|
8335
8468
|
var _a, _b;
|
|
8336
8469
|
this.ctx = ctx;
|
|
8337
8470
|
this.ctx.log();
|
|
8338
|
-
const versionTest = this.ctx.config.watch ?
|
|
8339
|
-
const mode = this.ctx.config.watch ?
|
|
8340
|
-
this.ctx.log(`${
|
|
8471
|
+
const versionTest = this.ctx.config.watch ? picocolors.exports.blue(`v${version}`) : picocolors.exports.cyan(`v${version}`);
|
|
8472
|
+
const mode = this.ctx.config.watch ? picocolors.exports.blue(" DEV ") : picocolors.exports.cyan(" RUN ");
|
|
8473
|
+
this.ctx.log(`${picocolors.exports.inverse(picocolors.exports.bold(mode))} ${versionTest} ${picocolors.exports.gray(this.ctx.config.root)}`);
|
|
8341
8474
|
if (this.ctx.config.ui)
|
|
8342
|
-
this.ctx.log(
|
|
8475
|
+
this.ctx.log(picocolors.exports.dim(picocolors.exports.green(` UI started at http://${((_a = this.ctx.config.api) == null ? void 0 : _a.host) || "localhost"}:${picocolors.exports.bold(`${this.ctx.server.config.server.port}`)}`)));
|
|
8343
8476
|
else if (this.ctx.config.api)
|
|
8344
|
-
this.ctx.log(
|
|
8477
|
+
this.ctx.log(picocolors.exports.dim(picocolors.exports.green(` API started at http://${((_b = this.ctx.config.api) == null ? void 0 : _b.host) || "localhost"}:${picocolors.exports.bold(`${this.ctx.config.api.port}`)}`)));
|
|
8345
8478
|
this.ctx.log();
|
|
8346
8479
|
this.start = performance.now();
|
|
8347
8480
|
}
|
|
8348
8481
|
relative(path) {
|
|
8349
8482
|
return relative(this.ctx.config.root, path);
|
|
8350
8483
|
}
|
|
8351
|
-
async onFinished(files = this.ctx.state.getFiles()) {
|
|
8484
|
+
async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
8352
8485
|
this.end = performance.now();
|
|
8353
8486
|
await this.reportSummary(files);
|
|
8487
|
+
if (errors.length) {
|
|
8488
|
+
process.exitCode = 1;
|
|
8489
|
+
const errorMessage = picocolors.exports.red(picocolors.exports.bold(`
|
|
8490
|
+
Vitest catched ${errors.length} unhandled error${errors.length > 1 ? "s" : ""} during the test run. This might cause false positive tests.
|
|
8491
|
+
Please, resolve all the errors to make sure your tests are not affected.`));
|
|
8492
|
+
this.ctx.log(picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(" Unhandled Errors ")))));
|
|
8493
|
+
this.ctx.log(errorMessage);
|
|
8494
|
+
await Promise.all(errors.map(async (err) => {
|
|
8495
|
+
await this.ctx.printError(err, true, err.type || "Unhandled Error");
|
|
8496
|
+
}));
|
|
8497
|
+
this.ctx.log(picocolors.exports.red(divider()));
|
|
8498
|
+
}
|
|
8354
8499
|
}
|
|
8355
8500
|
onTaskUpdate(packs) {
|
|
8356
8501
|
var _a, _b, _c;
|
|
@@ -8365,25 +8510,30 @@ class BaseReporter {
|
|
|
8365
8510
|
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "fail";
|
|
8366
8511
|
});
|
|
8367
8512
|
const skipped = tests.filter((t) => t.mode === "skip" || t.mode === "todo");
|
|
8368
|
-
let state =
|
|
8513
|
+
let state = picocolors.exports.dim(`${tests.length} test${tests.length > 1 ? "s" : ""}`);
|
|
8369
8514
|
if (failed.length)
|
|
8370
|
-
state += ` ${
|
|
8515
|
+
state += ` ${picocolors.exports.dim("|")} ${picocolors.exports.red(`${failed.length} failed`)}`;
|
|
8371
8516
|
if (skipped.length)
|
|
8372
|
-
state += ` ${
|
|
8373
|
-
let suffix =
|
|
8374
|
-
if (task.result.duration)
|
|
8375
|
-
|
|
8517
|
+
state += ` ${picocolors.exports.dim("|")} ${picocolors.exports.yellow(`${skipped.length} skipped`)}`;
|
|
8518
|
+
let suffix = picocolors.exports.dim(" (") + state + picocolors.exports.dim(")");
|
|
8519
|
+
if (task.result.duration) {
|
|
8520
|
+
const color = task.result.duration > DURATION_LONG$1 ? picocolors.exports.yellow : picocolors.exports.gray;
|
|
8521
|
+
suffix += color(` ${Math.round(task.result.duration)}${picocolors.exports.dim("ms")}`);
|
|
8522
|
+
}
|
|
8523
|
+
if (this.ctx.config.logHeapUsage && task.result.heap != null)
|
|
8524
|
+
suffix += picocolors.exports.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
|
8376
8525
|
this.ctx.log(` ${getStateSymbol(task)} ${task.name} ${suffix}`);
|
|
8377
8526
|
for (const test of failed) {
|
|
8378
|
-
this.ctx.log(
|
|
8379
|
-
this.ctx.log(
|
|
8527
|
+
this.ctx.log(picocolors.exports.red(` ${pointer} ${getFullName(test)}`));
|
|
8528
|
+
this.ctx.log(picocolors.exports.red(` ${F_RIGHT} ${(_c = test.result.error) == null ? void 0 : _c.message}`));
|
|
8380
8529
|
}
|
|
8381
8530
|
}
|
|
8382
8531
|
}
|
|
8383
8532
|
}
|
|
8384
8533
|
async onWatcherStart() {
|
|
8385
8534
|
const files = this.ctx.state.getFiles();
|
|
8386
|
-
const
|
|
8535
|
+
const errors = this.ctx.state.getUnhandledErrors();
|
|
8536
|
+
const failed = errors.length > 0 || hasFailed(files);
|
|
8387
8537
|
const failedSnap = hasFailedSnapshot(files);
|
|
8388
8538
|
if (failed)
|
|
8389
8539
|
this.ctx.log(WAIT_FOR_CHANGE_FAIL);
|
|
@@ -8394,13 +8544,13 @@ class BaseReporter {
|
|
|
8394
8544
|
hints.unshift(HELP_UPDATE_SNAP);
|
|
8395
8545
|
else
|
|
8396
8546
|
hints.push(HELP_QUITE);
|
|
8397
|
-
this.ctx.log(BADGE_PADDING + hints.join(
|
|
8547
|
+
this.ctx.log(BADGE_PADDING + hints.join(picocolors.exports.dim(", ")));
|
|
8398
8548
|
}
|
|
8399
8549
|
async onWatcherRerun(files, trigger) {
|
|
8400
8550
|
this.watchFilters = files;
|
|
8401
8551
|
this.ctx.clearScreen();
|
|
8402
8552
|
this.ctx.log(`
|
|
8403
|
-
${
|
|
8553
|
+
${picocolors.exports.inverse(picocolors.exports.bold(picocolors.exports.blue(" RERUN ")))}${trigger ? picocolors.exports.dim(` ${this.relative(trigger)}
|
|
8404
8554
|
`) : ""}`);
|
|
8405
8555
|
this.start = performance.now();
|
|
8406
8556
|
}
|
|
@@ -8408,12 +8558,12 @@ ${c.inverse(c.bold(c.blue(" RERUN ")))}${trigger ? c.dim(` ${this.relative(trigg
|
|
|
8408
8558
|
if (this.ctx.config.silent)
|
|
8409
8559
|
return;
|
|
8410
8560
|
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
|
|
8411
|
-
this.ctx.log(
|
|
8561
|
+
this.ctx.log(picocolors.exports.gray(log.type + picocolors.exports.dim(` | ${task ? getFullName(task) : "unknown test"}`)));
|
|
8412
8562
|
process[log.type].write(`${log.content}
|
|
8413
8563
|
`);
|
|
8414
8564
|
}
|
|
8415
8565
|
onServerRestart() {
|
|
8416
|
-
this.ctx.log(
|
|
8566
|
+
this.ctx.log(picocolors.exports.cyan("Restarted due to config changes..."));
|
|
8417
8567
|
}
|
|
8418
8568
|
async reportSummary(files) {
|
|
8419
8569
|
const suites = getSuites(files);
|
|
@@ -8428,15 +8578,15 @@ ${c.inverse(c.bold(c.blue(" RERUN ")))}${trigger ? c.dim(` ${this.relative(trigg
|
|
|
8428
8578
|
});
|
|
8429
8579
|
const failedTotal = failedSuites.length + failedTests.length;
|
|
8430
8580
|
let current = 1;
|
|
8431
|
-
const errorDivider = () => this.ctx.error(`${
|
|
8581
|
+
const errorDivider = () => this.ctx.error(`${picocolors.exports.red(picocolors.exports.dim(divider(`[${current++}/${failedTotal}]`, void 0, 1)))}
|
|
8432
8582
|
`);
|
|
8433
8583
|
if (failedSuites.length) {
|
|
8434
|
-
this.ctx.error(
|
|
8584
|
+
this.ctx.error(picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(` Failed Suites ${failedSuites.length} `)))));
|
|
8435
8585
|
this.ctx.error();
|
|
8436
8586
|
await this.printTaskErrors(failedSuites, errorDivider);
|
|
8437
8587
|
}
|
|
8438
8588
|
if (failedTests.length) {
|
|
8439
|
-
this.ctx.error(
|
|
8589
|
+
this.ctx.error(picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(` Failed Tests ${failedTests.length} `)))));
|
|
8440
8590
|
this.ctx.error();
|
|
8441
8591
|
await this.printTaskErrors(failedTests, errorDivider);
|
|
8442
8592
|
}
|
|
@@ -8445,7 +8595,7 @@ ${c.inverse(c.bold(c.blue(" RERUN ")))}${trigger ? c.dim(` ${this.relative(trigg
|
|
|
8445
8595
|
var _a;
|
|
8446
8596
|
return acc + Math.max(0, ((_a = test.result) == null ? void 0 : _a.duration) || 0) + Math.max(0, test.collectDuration || 0);
|
|
8447
8597
|
}, 0);
|
|
8448
|
-
const padTitle = (str) =>
|
|
8598
|
+
const padTitle = (str) => picocolors.exports.dim(`${str.padStart(10)} `);
|
|
8449
8599
|
const time = (time2) => {
|
|
8450
8600
|
if (time2 > 1e3)
|
|
8451
8601
|
return `${(time2 / 1e3).toFixed(2)}s`;
|
|
@@ -8462,7 +8612,7 @@ ${c.inverse(c.bold(c.blue(" RERUN ")))}${trigger ? c.dim(` ${this.relative(trigg
|
|
|
8462
8612
|
if (this.watchFilters)
|
|
8463
8613
|
this.ctx.log(padTitle("Time"), time(threadTime));
|
|
8464
8614
|
else
|
|
8465
|
-
this.ctx.log(padTitle("Time"), time(executionTime) +
|
|
8615
|
+
this.ctx.log(padTitle("Time"), time(executionTime) + picocolors.exports.gray(` (in thread ${time(threadTime)}, ${(executionTime / threadTime * 100).toFixed(2)}%)`));
|
|
8466
8616
|
this.ctx.log();
|
|
8467
8617
|
}
|
|
8468
8618
|
async printTaskErrors(tasks, errorDivider) {
|
|
@@ -8484,8 +8634,8 @@ ${c.inverse(c.bold(c.blue(" RERUN ")))}${trigger ? c.dim(` ${this.relative(trigg
|
|
|
8484
8634
|
const filepath = (task == null ? void 0 : task.filepath) || "";
|
|
8485
8635
|
let name = getFullName(task);
|
|
8486
8636
|
if (filepath)
|
|
8487
|
-
name = `${name} ${
|
|
8488
|
-
this.ctx.error(`${
|
|
8637
|
+
name = `${name} ${picocolors.exports.dim(`[ ${this.relative(filepath)} ]`)}`;
|
|
8638
|
+
this.ctx.error(`${picocolors.exports.red(picocolors.exports.bold(picocolors.exports.inverse(" FAIL ")))} ${name}`);
|
|
8489
8639
|
}
|
|
8490
8640
|
await this.ctx.printError(error);
|
|
8491
8641
|
errorDivider();
|
|
@@ -8494,9 +8644,7 @@ ${c.inverse(c.bold(c.blue(" RERUN ")))}${trigger ? c.dim(` ${this.relative(trigg
|
|
|
8494
8644
|
registerUnhandledRejection() {
|
|
8495
8645
|
process.on("unhandledRejection", async (err) => {
|
|
8496
8646
|
process.exitCode = 1;
|
|
8497
|
-
this.ctx.
|
|
8498
|
-
${c.red(divider(c.bold(c.inverse(" Unhandled Rejection "))))}`);
|
|
8499
|
-
await this.ctx.printError(err);
|
|
8647
|
+
await this.ctx.printError(err, true, "Unhandled Rejection");
|
|
8500
8648
|
this.ctx.error("\n\n");
|
|
8501
8649
|
process.exit(1);
|
|
8502
8650
|
});
|
|
@@ -8658,8 +8806,8 @@ ansiEscapes.iTerm = {
|
|
|
8658
8806
|
}
|
|
8659
8807
|
};
|
|
8660
8808
|
|
|
8661
|
-
const restoreCursor = onetime$1(() => {
|
|
8662
|
-
signalExit(() => {
|
|
8809
|
+
const restoreCursor = onetime$1.exports(() => {
|
|
8810
|
+
signalExit.exports(() => {
|
|
8663
8811
|
process$1.stderr.write('\u001B[?25h');
|
|
8664
8812
|
}, {alwaysLast: true});
|
|
8665
8813
|
});
|
|
@@ -8998,34 +9146,36 @@ function formatFilepath(path) {
|
|
|
8998
9146
|
if (firstDot < 0)
|
|
8999
9147
|
firstDot = basename.length;
|
|
9000
9148
|
firstDot += lastSlash;
|
|
9001
|
-
return
|
|
9149
|
+
return picocolors.exports.dim(path.slice(0, lastSlash)) + path.slice(lastSlash, firstDot) + picocolors.exports.dim(path.slice(firstDot));
|
|
9002
9150
|
}
|
|
9003
9151
|
function renderHookState(task, hookName, level = 0) {
|
|
9004
9152
|
var _a, _b;
|
|
9005
9153
|
const state = (_b = (_a = task.result) == null ? void 0 : _a.hooks) == null ? void 0 : _b[hookName];
|
|
9006
9154
|
if (state && state === "run")
|
|
9007
|
-
return `${" ".repeat(level)} ${getHookStateSymbol(task, hookName)} ${
|
|
9155
|
+
return `${" ".repeat(level)} ${getHookStateSymbol(task, hookName)} ${picocolors.exports.dim(`[ ${hookName} ]`)}`;
|
|
9008
9156
|
return "";
|
|
9009
9157
|
}
|
|
9010
9158
|
function renderTree(tasks, options, level = 0) {
|
|
9011
|
-
var _a, _b, _c, _d;
|
|
9159
|
+
var _a, _b, _c, _d, _e;
|
|
9012
9160
|
let output = [];
|
|
9013
9161
|
for (const task of tasks) {
|
|
9014
9162
|
let suffix = "";
|
|
9015
9163
|
const prefix = ` ${getStateSymbol(task)} `;
|
|
9016
9164
|
if (task.type === "suite")
|
|
9017
|
-
suffix +=
|
|
9165
|
+
suffix += picocolors.exports.dim(` (${getTests(task).length})`);
|
|
9018
9166
|
if (task.mode === "skip" || task.mode === "todo")
|
|
9019
|
-
suffix += ` ${
|
|
9167
|
+
suffix += ` ${picocolors.exports.dim(picocolors.exports.gray("[skipped]"))}`;
|
|
9020
9168
|
if (((_a = task.result) == null ? void 0 : _a.duration) != null) {
|
|
9021
9169
|
if (task.result.duration > DURATION_LONG)
|
|
9022
|
-
suffix +=
|
|
9170
|
+
suffix += picocolors.exports.yellow(` ${Math.round(task.result.duration)}${picocolors.exports.dim("ms")}`);
|
|
9023
9171
|
}
|
|
9172
|
+
if (options.showHeap && ((_b = task.result) == null ? void 0 : _b.heap) != null)
|
|
9173
|
+
suffix += picocolors.exports.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
|
9024
9174
|
let name = task.name;
|
|
9025
9175
|
if (level === 0)
|
|
9026
9176
|
name = formatFilepath(name);
|
|
9027
9177
|
output.push(" ".repeat(level) + prefix + name + suffix);
|
|
9028
|
-
if (((
|
|
9178
|
+
if (((_c = task.result) == null ? void 0 : _c.state) !== "pass" && outputMap.get(task) != null) {
|
|
9029
9179
|
let data = outputMap.get(task);
|
|
9030
9180
|
if (typeof data === "string") {
|
|
9031
9181
|
data = stripAnsi(data.trim().split("\n").filter(Boolean).pop());
|
|
@@ -9034,13 +9184,13 @@ function renderTree(tasks, options, level = 0) {
|
|
|
9034
9184
|
}
|
|
9035
9185
|
if (data != null) {
|
|
9036
9186
|
const out = `${" ".repeat(level)}${F_RIGHT} ${data}`;
|
|
9037
|
-
output.push(` ${
|
|
9187
|
+
output.push(` ${picocolors.exports.gray(cliTruncate(out, getCols(-3)))}`);
|
|
9038
9188
|
}
|
|
9039
9189
|
}
|
|
9040
9190
|
output = output.concat(renderHookState(task, "beforeAll", level + 1));
|
|
9041
9191
|
output = output.concat(renderHookState(task, "beforeEach", level + 1));
|
|
9042
9192
|
if (task.type === "suite" && task.tasks.length > 0) {
|
|
9043
|
-
if (((
|
|
9193
|
+
if (((_d = task.result) == null ? void 0 : _d.state) === "fail" || ((_e = task.result) == null ? void 0 : _e.state) === "run" || options.renderSucceed)
|
|
9044
9194
|
output = output.concat(renderTree(task.tasks, options, level + 1));
|
|
9045
9195
|
}
|
|
9046
9196
|
output = output.concat(renderHookState(task, "afterAll", level + 1));
|
|
@@ -9091,7 +9241,7 @@ class DefaultReporter extends BaseReporter {
|
|
|
9091
9241
|
async onTestRemoved(trigger) {
|
|
9092
9242
|
await this.stopListRender();
|
|
9093
9243
|
this.ctx.clearScreen();
|
|
9094
|
-
this.ctx.log(
|
|
9244
|
+
this.ctx.log(picocolors.exports.yellow("Test removed...") + (trigger ? picocolors.exports.dim(` [ ${this.relative(trigger)} ]
|
|
9095
9245
|
`) : ""));
|
|
9096
9246
|
const files = this.ctx.state.getFiles(this.watchFilters);
|
|
9097
9247
|
createListRenderer(files, this.rendererOptions).stop();
|
|
@@ -9102,6 +9252,7 @@ class DefaultReporter extends BaseReporter {
|
|
|
9102
9252
|
onCollected() {
|
|
9103
9253
|
if (this.isTTY) {
|
|
9104
9254
|
this.rendererOptions.outputStream = this.ctx.outputStream;
|
|
9255
|
+
this.rendererOptions.showHeap = this.ctx.config.logHeapUsage;
|
|
9105
9256
|
const files = this.ctx.state.getFiles(this.watchFilters);
|
|
9106
9257
|
if (!this.renderer)
|
|
9107
9258
|
this.renderer = createListRenderer(files, this.rendererOptions).start();
|
|
@@ -9109,10 +9260,10 @@ class DefaultReporter extends BaseReporter {
|
|
|
9109
9260
|
this.renderer.update(files);
|
|
9110
9261
|
}
|
|
9111
9262
|
}
|
|
9112
|
-
async onFinished(files = this.ctx.state.getFiles()) {
|
|
9263
|
+
async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
9113
9264
|
await this.stopListRender();
|
|
9114
9265
|
this.ctx.log();
|
|
9115
|
-
await super.onFinished(files);
|
|
9266
|
+
await super.onFinished(files, errors);
|
|
9116
9267
|
}
|
|
9117
9268
|
async onWatcherStart() {
|
|
9118
9269
|
await this.stopListRender();
|
|
@@ -9134,10 +9285,10 @@ class DefaultReporter extends BaseReporter {
|
|
|
9134
9285
|
}
|
|
9135
9286
|
}
|
|
9136
9287
|
|
|
9137
|
-
const check =
|
|
9138
|
-
const cross =
|
|
9139
|
-
const pending =
|
|
9140
|
-
const skip =
|
|
9288
|
+
const check = picocolors.exports.green("\xB7");
|
|
9289
|
+
const cross = picocolors.exports.red("x");
|
|
9290
|
+
const pending = picocolors.exports.yellow("*");
|
|
9291
|
+
const skip = picocolors.exports.dim(picocolors.exports.gray("-"));
|
|
9141
9292
|
function render(tasks) {
|
|
9142
9293
|
const all = getTests(tasks);
|
|
9143
9294
|
return all.map((i) => {
|
|
@@ -9199,10 +9350,10 @@ class DotReporter extends BaseReporter {
|
|
|
9199
9350
|
this.renderer.update(files);
|
|
9200
9351
|
}
|
|
9201
9352
|
}
|
|
9202
|
-
async onFinished(files = this.ctx.state.getFiles()) {
|
|
9353
|
+
async onFinished(files = this.ctx.state.getFiles(), errors = this.ctx.state.getUnhandledErrors()) {
|
|
9203
9354
|
await this.stopListRender();
|
|
9204
9355
|
this.ctx.log();
|
|
9205
|
-
await super.onFinished(files);
|
|
9356
|
+
await super.onFinished(files, errors);
|
|
9206
9357
|
}
|
|
9207
9358
|
async onWatcherStart() {
|
|
9208
9359
|
await this.stopListRender();
|
|
@@ -9289,7 +9440,7 @@ class JsonReporter {
|
|
|
9289
9440
|
return Math.max(prev, (((_a2 = next.result) == null ? void 0 : _a2.startTime) ?? 0) + (((_b2 = next.result) == null ? void 0 : _b2.duration) ?? 0));
|
|
9290
9441
|
}, startTime);
|
|
9291
9442
|
const assertionResults = tests2.map((t) => {
|
|
9292
|
-
var _a2, _b2, _c;
|
|
9443
|
+
var _a2, _b2, _c, _d;
|
|
9293
9444
|
const ancestorTitles = [];
|
|
9294
9445
|
let iter = t.suite;
|
|
9295
9446
|
while (iter) {
|
|
@@ -9300,10 +9451,10 @@ class JsonReporter {
|
|
|
9300
9451
|
return {
|
|
9301
9452
|
ancestorTitles,
|
|
9302
9453
|
fullName: ancestorTitles.length > 0 ? `${ancestorTitles.join(" ")} ${t.name}` : t.name,
|
|
9303
|
-
status: t.result
|
|
9454
|
+
status: StatusMap[((_a2 = t.result) == null ? void 0 : _a2.state) || t.mode] || "skipped",
|
|
9304
9455
|
title: t.name,
|
|
9305
|
-
duration: (
|
|
9306
|
-
failureMessages: ((
|
|
9456
|
+
duration: (_b2 = t.result) == null ? void 0 : _b2.duration,
|
|
9457
|
+
failureMessages: ((_d = (_c = t.result) == null ? void 0 : _c.error) == null ? void 0 : _d.message) == null ? [] : [t.result.error.message]
|
|
9307
9458
|
};
|
|
9308
9459
|
});
|
|
9309
9460
|
if (tests2.some((t) => {
|
|
@@ -9370,9 +9521,12 @@ class VerboseReporter extends DefaultReporter {
|
|
|
9370
9521
|
for (const pack of packs) {
|
|
9371
9522
|
const task = this.ctx.state.idMap.get(pack[0]);
|
|
9372
9523
|
if (task && task.type === "test" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
|
|
9373
|
-
|
|
9524
|
+
let title = ` ${getStateSymbol(task)} ${getFullName(task)}`;
|
|
9525
|
+
if (this.ctx.config.logHeapUsage && task.result.heap != null)
|
|
9526
|
+
title += picocolors.exports.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
|
9527
|
+
this.ctx.log(title);
|
|
9374
9528
|
if (task.result.state === "fail")
|
|
9375
|
-
this.ctx.log(
|
|
9529
|
+
this.ctx.log(picocolors.exports.red(` ${F_RIGHT} ${(_c = task.result.error) == null ? void 0 : _c.message}`));
|
|
9376
9530
|
}
|
|
9377
9531
|
}
|
|
9378
9532
|
}
|
|
@@ -9684,128 +9838,31 @@ const ReportersMap = {
|
|
|
9684
9838
|
"junit": JUnitReporter
|
|
9685
9839
|
};
|
|
9686
9840
|
|
|
9687
|
-
function
|
|
9688
|
-
|
|
9689
|
-
|
|
9690
|
-
|
|
9691
|
-
|
|
9692
|
-
}
|
|
9693
|
-
|
|
9694
|
-
|
|
9695
|
-
|
|
9696
|
-
|
|
9697
|
-
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9701
|
-
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
|
|
9706
|
-
|
|
9707
|
-
port.close();
|
|
9708
|
-
workerPort.close();
|
|
9709
|
-
};
|
|
9710
|
-
};
|
|
9711
|
-
return {
|
|
9712
|
-
runTests: runWithFiles("run"),
|
|
9713
|
-
collectTests: runWithFiles("collect"),
|
|
9714
|
-
close: async () => {
|
|
9715
|
-
}
|
|
9716
|
-
};
|
|
9717
|
-
}
|
|
9718
|
-
function createWorkerPool(ctx) {
|
|
9719
|
-
const threadsCount = ctx.config.watch ? Math.max(cpus().length / 2, 1) : Math.max(cpus().length - 1, 1);
|
|
9720
|
-
const options = {
|
|
9721
|
-
filename: workerPath,
|
|
9722
|
-
useAtomics: typeof process.versions.webcontainer !== "string",
|
|
9723
|
-
maxThreads: ctx.config.maxThreads ?? threadsCount,
|
|
9724
|
-
minThreads: ctx.config.minThreads ?? threadsCount
|
|
9725
|
-
};
|
|
9726
|
-
if (ctx.config.isolate) {
|
|
9727
|
-
options.isolateWorkers = true;
|
|
9728
|
-
options.concurrentTasksPerWorker = 1;
|
|
9729
|
-
}
|
|
9730
|
-
const pool = new Tinypool(options);
|
|
9731
|
-
const runWithFiles = (name) => {
|
|
9732
|
-
return async (files, invalidates) => {
|
|
9733
|
-
let id = 0;
|
|
9734
|
-
await Promise.all(files.map(async (file) => {
|
|
9735
|
-
const { workerPort, port } = createChannel(ctx);
|
|
9736
|
-
const data = {
|
|
9737
|
-
port: workerPort,
|
|
9738
|
-
config: ctx.getConfig(),
|
|
9739
|
-
files: [file],
|
|
9740
|
-
invalidates,
|
|
9741
|
-
id: ++id
|
|
9742
|
-
};
|
|
9743
|
-
await pool.run(data, { transferList: [workerPort], name });
|
|
9744
|
-
port.close();
|
|
9745
|
-
workerPort.close();
|
|
9746
|
-
}));
|
|
9747
|
-
};
|
|
9748
|
-
};
|
|
9749
|
-
return {
|
|
9750
|
-
runTests: runWithFiles("run"),
|
|
9751
|
-
collectTests: runWithFiles("collect"),
|
|
9752
|
-
close: async () => {
|
|
9753
|
-
}
|
|
9754
|
-
};
|
|
9755
|
-
}
|
|
9756
|
-
function createChannel(ctx) {
|
|
9757
|
-
const channel = new MessageChannel();
|
|
9758
|
-
const port = channel.port2;
|
|
9759
|
-
const workerPort = channel.port1;
|
|
9760
|
-
createBirpc({
|
|
9761
|
-
onWorkerExit(code) {
|
|
9762
|
-
process.exit(code || 1);
|
|
9763
|
-
},
|
|
9764
|
-
snapshotSaved(snapshot) {
|
|
9765
|
-
ctx.snapshot.add(snapshot);
|
|
9766
|
-
},
|
|
9767
|
-
resolveSnapshotPath(testPath) {
|
|
9768
|
-
return ctx.snapshot.resolvePath(testPath);
|
|
9769
|
-
},
|
|
9770
|
-
async getSourceMap(id, force) {
|
|
9771
|
-
if (force) {
|
|
9772
|
-
const mod = ctx.server.moduleGraph.getModuleById(id);
|
|
9773
|
-
if (mod)
|
|
9774
|
-
ctx.server.moduleGraph.invalidateModule(mod);
|
|
9841
|
+
async function loadCustomReporterModule(path, fetchModule) {
|
|
9842
|
+
let customReporterModule;
|
|
9843
|
+
try {
|
|
9844
|
+
customReporterModule = await fetchModule(path);
|
|
9845
|
+
} catch (customReporterModuleError) {
|
|
9846
|
+
throw new Error(`Failed to load custom Reporter from ${path}`, { cause: customReporterModuleError });
|
|
9847
|
+
}
|
|
9848
|
+
if (customReporterModule.default === null || customReporterModule.default === void 0)
|
|
9849
|
+
throw new Error(`Custom reporter loaded from ${path} was not the default export`);
|
|
9850
|
+
return customReporterModule.default;
|
|
9851
|
+
}
|
|
9852
|
+
function createReporters(reporterReferences, fetchModule) {
|
|
9853
|
+
const promisedReporters = reporterReferences.map(async (referenceOrInstance) => {
|
|
9854
|
+
if (typeof referenceOrInstance === "string") {
|
|
9855
|
+
if (referenceOrInstance in ReportersMap) {
|
|
9856
|
+
const BuiltinReporter = ReportersMap[referenceOrInstance];
|
|
9857
|
+
return new BuiltinReporter();
|
|
9858
|
+
} else {
|
|
9859
|
+
const CustomReporter = await loadCustomReporterModule(referenceOrInstance, fetchModule);
|
|
9860
|
+
return new CustomReporter();
|
|
9775
9861
|
}
|
|
9776
|
-
const r = await ctx.vitenode.transformRequest(id);
|
|
9777
|
-
return r == null ? void 0 : r.map;
|
|
9778
|
-
},
|
|
9779
|
-
fetch(id) {
|
|
9780
|
-
return ctx.vitenode.fetchModule(id);
|
|
9781
|
-
},
|
|
9782
|
-
resolveId(id, importer) {
|
|
9783
|
-
return ctx.vitenode.resolveId(id, importer);
|
|
9784
|
-
},
|
|
9785
|
-
onCollected(files) {
|
|
9786
|
-
ctx.state.collectFiles(files);
|
|
9787
|
-
ctx.report("onCollected", files);
|
|
9788
|
-
},
|
|
9789
|
-
onTaskUpdate(packs) {
|
|
9790
|
-
ctx.state.updateTasks(packs);
|
|
9791
|
-
ctx.report("onTaskUpdate", packs);
|
|
9792
|
-
},
|
|
9793
|
-
onUserConsoleLog(log) {
|
|
9794
|
-
ctx.state.updateUserLog(log);
|
|
9795
|
-
ctx.report("onUserConsoleLog", log);
|
|
9796
|
-
},
|
|
9797
|
-
onFinished(files) {
|
|
9798
|
-
ctx.report("onFinished", files);
|
|
9799
|
-
}
|
|
9800
|
-
}, {
|
|
9801
|
-
post(v) {
|
|
9802
|
-
port.postMessage(v);
|
|
9803
|
-
},
|
|
9804
|
-
on(fn) {
|
|
9805
|
-
port.on("message", fn);
|
|
9806
9862
|
}
|
|
9863
|
+
return referenceOrInstance;
|
|
9807
9864
|
});
|
|
9808
|
-
return
|
|
9865
|
+
return Promise.all(promisedReporters);
|
|
9809
9866
|
}
|
|
9810
9867
|
|
|
9811
9868
|
class StateManager {
|
|
@@ -9813,6 +9870,17 @@ class StateManager {
|
|
|
9813
9870
|
this.filesMap = /* @__PURE__ */ new Map();
|
|
9814
9871
|
this.idMap = /* @__PURE__ */ new Map();
|
|
9815
9872
|
this.taskFileMap = /* @__PURE__ */ new WeakMap();
|
|
9873
|
+
this.errorsSet = /* @__PURE__ */ new Set();
|
|
9874
|
+
}
|
|
9875
|
+
catchError(err, type) {
|
|
9876
|
+
err.type = type;
|
|
9877
|
+
this.errorsSet.add(err);
|
|
9878
|
+
}
|
|
9879
|
+
clearErrors() {
|
|
9880
|
+
this.errorsSet.clear();
|
|
9881
|
+
}
|
|
9882
|
+
getUnhandledErrors() {
|
|
9883
|
+
return Array.from(this.errorsSet.values());
|
|
9816
9884
|
}
|
|
9817
9885
|
getFiles(keys) {
|
|
9818
9886
|
if (keys)
|
|
@@ -9917,7 +9985,7 @@ function resolveConfig(options, viteConfig) {
|
|
|
9917
9985
|
var _a, _b;
|
|
9918
9986
|
if (options.dom) {
|
|
9919
9987
|
if (((_a = viteConfig.test) == null ? void 0 : _a.environment) != null && viteConfig.test.environment !== "happy-dom") {
|
|
9920
|
-
console.warn(
|
|
9988
|
+
console.warn(picocolors.exports.yellow(`${picocolors.exports.inverse(picocolors.exports.yellow(" Vitest "))} Your config.test.environment ("${viteConfig.test.environment}") conflicts with --dom flag ("happy-dom"), ignoring "${viteConfig.test.environment}"`));
|
|
9921
9989
|
}
|
|
9922
9990
|
options.environment = "happy-dom";
|
|
9923
9991
|
}
|
|
@@ -9965,7 +10033,8 @@ function fileFromParsedStack(stack) {
|
|
|
9965
10033
|
return join(stack.file, "../", stack.sourcePos.source);
|
|
9966
10034
|
return stack.file;
|
|
9967
10035
|
}
|
|
9968
|
-
async function printError(error, ctx) {
|
|
10036
|
+
async function printError(error, ctx, options = {}) {
|
|
10037
|
+
const { showCodeFrame = true, fullStack = false, type } = options;
|
|
9969
10038
|
let e = error;
|
|
9970
10039
|
if (typeof error === "string") {
|
|
9971
10040
|
e = {
|
|
@@ -9973,20 +10042,56 @@ async function printError(error, ctx) {
|
|
|
9973
10042
|
stack: error
|
|
9974
10043
|
};
|
|
9975
10044
|
}
|
|
9976
|
-
const stacks = parseStacktrace(e);
|
|
10045
|
+
const stacks = parseStacktrace(e, fullStack);
|
|
9977
10046
|
await interpretSourcePos(stacks, ctx);
|
|
9978
10047
|
const nearest = stacks.find((stack) => ctx.server.moduleGraph.getModuleById(stack.file) && existsSync(stack.file));
|
|
10048
|
+
const errorProperties = getErrorProperties(e);
|
|
10049
|
+
if (type)
|
|
10050
|
+
printErrorType(type, ctx);
|
|
9979
10051
|
printErrorMessage(e, ctx.console);
|
|
9980
|
-
|
|
9981
|
-
if (s === nearest && nearest) {
|
|
9982
|
-
const sourceCode =
|
|
9983
|
-
ctx.log(
|
|
10052
|
+
printStack(ctx, stacks, nearest, errorProperties, (s, pos) => {
|
|
10053
|
+
if (showCodeFrame && s === nearest && nearest) {
|
|
10054
|
+
const sourceCode = readFileSync(fileFromParsedStack(nearest), "utf-8");
|
|
10055
|
+
ctx.log(picocolors.exports.yellow(generateCodeFrame(sourceCode, 4, pos)));
|
|
9984
10056
|
}
|
|
9985
10057
|
});
|
|
10058
|
+
if (e.cause) {
|
|
10059
|
+
e.cause.name = `Caused by: ${e.cause.name}`;
|
|
10060
|
+
await printError(e.cause, ctx, { fullStack, showCodeFrame: false });
|
|
10061
|
+
}
|
|
9986
10062
|
handleImportOutsideModuleError(e.stack || e.stackStr || "", ctx);
|
|
9987
10063
|
if (e.showDiff)
|
|
9988
10064
|
displayDiff(stringify$5(e.actual), stringify$5(e.expected), ctx.console, ctx.config.outputTruncateLength);
|
|
9989
10065
|
}
|
|
10066
|
+
function printErrorType(type, ctx) {
|
|
10067
|
+
ctx.error(`
|
|
10068
|
+
${picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(` ${type} `))))}`);
|
|
10069
|
+
}
|
|
10070
|
+
function getErrorProperties(e) {
|
|
10071
|
+
const errorObject = /* @__PURE__ */ Object.create(null);
|
|
10072
|
+
if (e.name === "AssertionError")
|
|
10073
|
+
return errorObject;
|
|
10074
|
+
const skip = [
|
|
10075
|
+
"message",
|
|
10076
|
+
"name",
|
|
10077
|
+
"nameStr",
|
|
10078
|
+
"stack",
|
|
10079
|
+
"cause",
|
|
10080
|
+
"stacks",
|
|
10081
|
+
"stackStr",
|
|
10082
|
+
"type",
|
|
10083
|
+
"showDiff",
|
|
10084
|
+
"actual",
|
|
10085
|
+
"expected",
|
|
10086
|
+
"constructor",
|
|
10087
|
+
"toString"
|
|
10088
|
+
];
|
|
10089
|
+
for (const key of Object.getOwnPropertyNames(e)) {
|
|
10090
|
+
if (!skip.includes(key))
|
|
10091
|
+
errorObject[key] = e[key];
|
|
10092
|
+
}
|
|
10093
|
+
return errorObject;
|
|
10094
|
+
}
|
|
9990
10095
|
const esmErrors = [
|
|
9991
10096
|
"Cannot use import statement outside a module",
|
|
9992
10097
|
"Unexpected token 'export'"
|
|
@@ -10000,15 +10105,15 @@ function handleImportOutsideModuleError(stack, ctx) {
|
|
|
10000
10105
|
name = name.split("/").slice(0, 2).join("/");
|
|
10001
10106
|
else
|
|
10002
10107
|
name = name.split("/")[0];
|
|
10003
|
-
ctx.console.error(
|
|
10108
|
+
ctx.console.error(picocolors.exports.yellow(`Module ${path} seems to be an ES Module but shipped in a CommonJS package. You might want to create an issue to the package ${picocolors.exports.bold(`"${name}"`)} asking them to ship the file in .mjs extension or add "type": "module" in their package.json.
|
|
10004
10109
|
|
|
10005
10110
|
As a temporary workaround you can try to inline the package by updating your config:
|
|
10006
10111
|
|
|
10007
|
-
` +
|
|
10112
|
+
` + picocolors.exports.gray(picocolors.exports.dim("// vitest.config.js")) + "\n" + picocolors.exports.green(`export default {
|
|
10008
10113
|
test: {
|
|
10009
10114
|
deps: {
|
|
10010
10115
|
inline: [
|
|
10011
|
-
${
|
|
10116
|
+
${picocolors.exports.yellow(picocolors.exports.bold(`"${name}"`))}
|
|
10012
10117
|
]
|
|
10013
10118
|
}
|
|
10014
10119
|
}
|
|
@@ -10016,26 +10121,32 @@ As a temporary workaround you can try to inline the package by updating your con
|
|
|
10016
10121
|
`)));
|
|
10017
10122
|
}
|
|
10018
10123
|
function displayDiff(actual, expected, console, outputTruncateLength) {
|
|
10019
|
-
console.error(
|
|
10124
|
+
console.error(picocolors.exports.gray(unifiedDiff(actual, expected, { outputTruncateLength })) + "\n");
|
|
10020
10125
|
}
|
|
10021
10126
|
function printErrorMessage(error, console) {
|
|
10022
10127
|
const errorName = error.name || error.nameStr || "Unknown Error";
|
|
10023
|
-
console.error(
|
|
10128
|
+
console.error(picocolors.exports.red(`${picocolors.exports.bold(errorName)}: ${error.message}`));
|
|
10024
10129
|
}
|
|
10025
|
-
|
|
10130
|
+
function printStack(ctx, stack, highlight, errorProperties, onStack) {
|
|
10026
10131
|
if (!stack.length)
|
|
10027
10132
|
return;
|
|
10028
10133
|
for (const frame of stack) {
|
|
10029
10134
|
const pos = frame.sourcePos || frame;
|
|
10030
|
-
const color = frame === highlight ?
|
|
10135
|
+
const color = frame === highlight ? picocolors.exports.yellow : picocolors.exports.gray;
|
|
10031
10136
|
const file = fileFromParsedStack(frame);
|
|
10032
10137
|
const path = relative(ctx.config.root, file);
|
|
10033
|
-
ctx.log(color(` ${
|
|
10034
|
-
|
|
10138
|
+
ctx.log(color(` ${picocolors.exports.dim(F_POINTER)} ${[frame.method, picocolors.exports.dim(`${path}:${pos.line}:${pos.column}`)].filter(Boolean).join(" ")}`));
|
|
10139
|
+
onStack == null ? void 0 : onStack(frame, pos);
|
|
10035
10140
|
if (frame.file in ctx.state.filesMap)
|
|
10036
10141
|
break;
|
|
10037
10142
|
}
|
|
10038
10143
|
ctx.log();
|
|
10144
|
+
const hasProperties = Object.keys(errorProperties).length > 0;
|
|
10145
|
+
if (hasProperties) {
|
|
10146
|
+
ctx.log(picocolors.exports.red(picocolors.exports.dim(divider())));
|
|
10147
|
+
const propertiesString = stringify$5(errorProperties, 10, { printBasicPrototype: false });
|
|
10148
|
+
ctx.log(picocolors.exports.red(picocolors.exports.bold("Serialized Error:")), picocolors.exports.gray(propertiesString));
|
|
10149
|
+
}
|
|
10039
10150
|
}
|
|
10040
10151
|
function generateCodeFrame(source, indent = 0, start = 0, end, range = 2) {
|
|
10041
10152
|
start = posToNumber(source, start);
|
|
@@ -10045,7 +10156,7 @@ function generateCodeFrame(source, indent = 0, start = 0, end, range = 2) {
|
|
|
10045
10156
|
let res = [];
|
|
10046
10157
|
const columns = process.stdout.columns || 80;
|
|
10047
10158
|
function lineNo(no = "") {
|
|
10048
|
-
return
|
|
10159
|
+
return picocolors.exports.gray(`${String(no).padStart(3, " ")}| `);
|
|
10049
10160
|
}
|
|
10050
10161
|
for (let i = 0; i < lines.length; i++) {
|
|
10051
10162
|
count += lines[i].length + 1;
|
|
@@ -10060,11 +10171,11 @@ function generateCodeFrame(source, indent = 0, start = 0, end, range = 2) {
|
|
|
10060
10171
|
if (j === i) {
|
|
10061
10172
|
const pad = start - (count - lineLength);
|
|
10062
10173
|
const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
|
10063
|
-
res.push(lineNo() + " ".repeat(pad) +
|
|
10174
|
+
res.push(lineNo() + " ".repeat(pad) + picocolors.exports.red("^".repeat(length)));
|
|
10064
10175
|
} else if (j > i) {
|
|
10065
10176
|
if (end > count) {
|
|
10066
10177
|
const length = Math.max(1, Math.min(end - count, lineLength));
|
|
10067
|
-
res.push(lineNo() +
|
|
10178
|
+
res.push(lineNo() + picocolors.exports.red("^".repeat(length)));
|
|
10068
10179
|
}
|
|
10069
10180
|
count += lineLength + 1;
|
|
10070
10181
|
}
|
|
@@ -10168,6 +10279,7 @@ class Vitest {
|
|
|
10168
10279
|
this.changedTests = /* @__PURE__ */ new Set();
|
|
10169
10280
|
this.isFirstRun = true;
|
|
10170
10281
|
this.restartsCount = 0;
|
|
10282
|
+
this.runner = void 0;
|
|
10171
10283
|
this._onRestartListeners = [];
|
|
10172
10284
|
this.unregisterWatcher = noop$1;
|
|
10173
10285
|
this.console = globalThis.console;
|
|
@@ -10184,18 +10296,21 @@ class Vitest {
|
|
|
10184
10296
|
this.config = resolved;
|
|
10185
10297
|
this.state = new StateManager();
|
|
10186
10298
|
this.snapshot = new SnapshotManager(__spreadValues$1({}, resolved.snapshotOptions));
|
|
10187
|
-
this.reporters = resolved.reporters.map((i) => {
|
|
10188
|
-
if (typeof i === "string") {
|
|
10189
|
-
const Reporter = ReportersMap[i];
|
|
10190
|
-
if (!Reporter)
|
|
10191
|
-
throw new Error(`Unknown reporter: ${i}`);
|
|
10192
|
-
return new Reporter();
|
|
10193
|
-
}
|
|
10194
|
-
return i;
|
|
10195
|
-
});
|
|
10196
10299
|
if (this.config.watch)
|
|
10197
10300
|
this.registerWatcher();
|
|
10198
10301
|
this.vitenode = new ViteNodeServer(server, this.config);
|
|
10302
|
+
const node = this.vitenode;
|
|
10303
|
+
this.runner = new ViteNodeRunner({
|
|
10304
|
+
root: server.config.root,
|
|
10305
|
+
base: server.config.base,
|
|
10306
|
+
fetchModule(id) {
|
|
10307
|
+
return node.fetchModule(id);
|
|
10308
|
+
},
|
|
10309
|
+
resolveId(id, importer) {
|
|
10310
|
+
return node.resolveId(id, importer);
|
|
10311
|
+
}
|
|
10312
|
+
});
|
|
10313
|
+
this.reporters = await createReporters(resolved.reporters, this.runner.executeFile.bind(this.runner));
|
|
10199
10314
|
this.runningPromise = void 0;
|
|
10200
10315
|
this._onRestartListeners.forEach((fn) => fn());
|
|
10201
10316
|
if (resolved.coverage.enabled)
|
|
@@ -10219,17 +10334,17 @@ class Vitest {
|
|
|
10219
10334
|
const files = await this.filterTestsBySource(await this.globTestFiles(filters));
|
|
10220
10335
|
if (!files.length) {
|
|
10221
10336
|
const exitCode = this.config.passWithNoTests ? 0 : 1;
|
|
10222
|
-
const comma =
|
|
10337
|
+
const comma = picocolors.exports.dim(", ");
|
|
10223
10338
|
if (filters == null ? void 0 : filters.length)
|
|
10224
|
-
this.console.error(
|
|
10339
|
+
this.console.error(picocolors.exports.dim("filter: ") + picocolors.exports.yellow(filters.join(comma)));
|
|
10225
10340
|
if (this.config.include)
|
|
10226
|
-
this.console.error(
|
|
10341
|
+
this.console.error(picocolors.exports.dim("include: ") + picocolors.exports.yellow(this.config.include.join(comma)));
|
|
10227
10342
|
if (this.config.watchIgnore)
|
|
10228
|
-
this.console.error(
|
|
10343
|
+
this.console.error(picocolors.exports.dim("ignore: ") + picocolors.exports.yellow(this.config.watchIgnore.join(comma)));
|
|
10229
10344
|
if (this.config.passWithNoTests)
|
|
10230
10345
|
this.log("No test files found, exiting with code 0\n");
|
|
10231
10346
|
else
|
|
10232
|
-
this.error(
|
|
10347
|
+
this.error(picocolors.exports.red("\nNo test files found, exiting with code 1"));
|
|
10233
10348
|
process.exit(exitCode);
|
|
10234
10349
|
}
|
|
10235
10350
|
await this.runFiles(files);
|
|
@@ -10264,7 +10379,7 @@ class Vitest {
|
|
|
10264
10379
|
changedSince: this.config.changed
|
|
10265
10380
|
});
|
|
10266
10381
|
if (!related2) {
|
|
10267
|
-
this.error(
|
|
10382
|
+
this.error(picocolors.exports.red("Could not find Git root. Have you initialized git with `git init`?\n"));
|
|
10268
10383
|
process.exit(1);
|
|
10269
10384
|
}
|
|
10270
10385
|
this.config.related = Array.from(new Set(related2));
|
|
@@ -10293,10 +10408,15 @@ class Vitest {
|
|
|
10293
10408
|
const invalidates = Array.from(this.invalidates);
|
|
10294
10409
|
this.invalidates.clear();
|
|
10295
10410
|
this.snapshot.clear();
|
|
10296
|
-
|
|
10411
|
+
this.state.clearErrors();
|
|
10412
|
+
try {
|
|
10413
|
+
await this.pool.runTests(files, invalidates);
|
|
10414
|
+
} catch (err) {
|
|
10415
|
+
this.state.catchError(err, "Unhandled Error");
|
|
10416
|
+
}
|
|
10297
10417
|
if (hasFailed(this.state.getFiles()))
|
|
10298
10418
|
process.exitCode = 1;
|
|
10299
|
-
await this.report("onFinished", this.state.getFiles());
|
|
10419
|
+
await this.report("onFinished", this.state.getFiles(), this.state.getUnhandledErrors());
|
|
10300
10420
|
})().finally(() => {
|
|
10301
10421
|
this.runningPromise = void 0;
|
|
10302
10422
|
});
|
|
@@ -10496,8 +10616,12 @@ class Vitest {
|
|
|
10496
10616
|
isInSourceTestFile(code) {
|
|
10497
10617
|
return code.includes("import.meta.vitest");
|
|
10498
10618
|
}
|
|
10499
|
-
printError(err) {
|
|
10500
|
-
return printError(err, this
|
|
10619
|
+
printError(err, fullStack = false, type) {
|
|
10620
|
+
return printError(err, this, {
|
|
10621
|
+
fullStack,
|
|
10622
|
+
type,
|
|
10623
|
+
showCodeFrame: true
|
|
10624
|
+
});
|
|
10501
10625
|
}
|
|
10502
10626
|
onServerRestarted(fn) {
|
|
10503
10627
|
this._onRestartListeners.push(fn);
|
|
@@ -10529,18 +10653,8 @@ const EnvReplacerPlugin = () => {
|
|
|
10529
10653
|
|
|
10530
10654
|
async function loadGlobalSetupFiles(ctx) {
|
|
10531
10655
|
var _a;
|
|
10532
|
-
const node = ctx.vitenode;
|
|
10533
10656
|
const server = ctx.server;
|
|
10534
|
-
const runner =
|
|
10535
|
-
root: server.config.root,
|
|
10536
|
-
base: server.config.base,
|
|
10537
|
-
fetchModule(id) {
|
|
10538
|
-
return node.fetchModule(id);
|
|
10539
|
-
},
|
|
10540
|
-
resolveId(id, importer) {
|
|
10541
|
-
return node.resolveId(id, importer);
|
|
10542
|
-
}
|
|
10543
|
-
});
|
|
10657
|
+
const runner = ctx.runner;
|
|
10544
10658
|
const globalSetupFiles = toArray((_a = server.config.test) == null ? void 0 : _a.globalSetup);
|
|
10545
10659
|
return Promise.all(globalSetupFiles.map((file) => loadGlobalSetupFile(file, runner)));
|
|
10546
10660
|
}
|
|
@@ -10586,7 +10700,7 @@ const GlobalSetupPlugin = (ctx) => {
|
|
|
10586
10700
|
}
|
|
10587
10701
|
} catch (e) {
|
|
10588
10702
|
ctx.error(`
|
|
10589
|
-
${
|
|
10703
|
+
${picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(" Error during global setup "))))}`);
|
|
10590
10704
|
await ctx.printError(e);
|
|
10591
10705
|
process.exit(1);
|
|
10592
10706
|
}
|
|
@@ -10821,7 +10935,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
10821
10935
|
await ctx.setServer(options, server);
|
|
10822
10936
|
haveStarted = true;
|
|
10823
10937
|
if (options.api && options.watch)
|
|
10824
|
-
(await import('./chunk-api-setup.
|
|
10938
|
+
(await import('./chunk-api-setup.b55307fb.js')).setup(ctx);
|
|
10825
10939
|
if (!options.watch)
|
|
10826
10940
|
await server.watcher.close();
|
|
10827
10941
|
}
|
|
@@ -10861,8 +10975,8 @@ const keys = [
|
|
|
10861
10975
|
];
|
|
10862
10976
|
function printShortcutsHelp() {
|
|
10863
10977
|
process.stdout.write(`
|
|
10864
|
-
${
|
|
10865
|
-
${keys.map((i) =>
|
|
10978
|
+
${picocolors.exports.bold(" Watch Usage")}
|
|
10979
|
+
${keys.map((i) => picocolors.exports.dim(" press ") + picocolors.exports.reset(picocolors.exports.bold(i[0])) + picocolors.exports.dim(` to ${i[1]}`)).join("\n")}
|
|
10866
10980
|
`);
|
|
10867
10981
|
}
|
|
10868
10982
|
function registerConsoleShortcuts(ctx) {
|
|
@@ -10962,10 +11076,9 @@ async function startVitest(cliFilters, options, viteOverrides) {
|
|
|
10962
11076
|
await ctx.start(cliFilters);
|
|
10963
11077
|
} catch (e) {
|
|
10964
11078
|
process.exitCode = 1;
|
|
10965
|
-
ctx.
|
|
10966
|
-
${c.red(divider(c.bold(c.inverse(" Unhandled Error "))))}`);
|
|
10967
|
-
await ctx.printError(e);
|
|
11079
|
+
await ctx.printError(e, true, "Unhandled Error");
|
|
10968
11080
|
ctx.error("\n\n");
|
|
11081
|
+
return false;
|
|
10969
11082
|
}
|
|
10970
11083
|
if (!ctx.config.watch) {
|
|
10971
11084
|
await ctx.exit();
|