vitest 0.0.78 → 0.0.79
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/cli.js +1321 -1301
- package/dist/entry.js +46 -34
- package/dist/index.d.ts +3 -2
- package/dist/rpc-7de86f29.js +10 -0
- package/dist/worker.js +9 -0
- package/package.json +1 -1
package/dist/entry.js
CHANGED
|
@@ -5,6 +5,7 @@ import chai, { expect, util } from 'chai';
|
|
|
5
5
|
import SinonChai from 'sinon-chai';
|
|
6
6
|
import Subset from 'chai-subset';
|
|
7
7
|
import path, { basename } from 'path';
|
|
8
|
+
import { r as rpc, s as send } from './rpc-7de86f29.js';
|
|
8
9
|
import { g as getNames, t as toArray, i as interpretOnlyMode, p as partitionSuiteChildren, c as hasTests, h as hasFailed } from './utils-9dcc4050.js';
|
|
9
10
|
import fs from 'fs';
|
|
10
11
|
import { d as c$1, m as generateDiff } from './error-c9295525.js';
|
|
@@ -296,15 +297,6 @@ const environments = {
|
|
|
296
297
|
"happy-dom": happy
|
|
297
298
|
};
|
|
298
299
|
|
|
299
|
-
const rpc = async (method, ...args) => {
|
|
300
|
-
var _a;
|
|
301
|
-
return (_a = process.__vitest_worker__) == null ? void 0 : _a.rpc(method, ...args);
|
|
302
|
-
};
|
|
303
|
-
const send = async (method, ...args) => {
|
|
304
|
-
var _a;
|
|
305
|
-
return (_a = process.__vitest_worker__) == null ? void 0 : _a.send(method, ...args);
|
|
306
|
-
};
|
|
307
|
-
|
|
308
300
|
var naturalCompare$2 = {exports: {}};
|
|
309
301
|
|
|
310
302
|
/*
|
|
@@ -752,7 +744,7 @@ const asymmetricMatcher =
|
|
|
752
744
|
: 0x1357a5;
|
|
753
745
|
const SPACE$2 = ' ';
|
|
754
746
|
|
|
755
|
-
const serialize$
|
|
747
|
+
const serialize$8 = (val, config, indentation, depth, refs, printer) => {
|
|
756
748
|
const stringedValue = val.toString();
|
|
757
749
|
|
|
758
750
|
if (
|
|
@@ -828,13 +820,13 @@ const serialize$7 = (val, config, indentation, depth, refs, printer) => {
|
|
|
828
820
|
return val.toAsymmetricMatcher();
|
|
829
821
|
};
|
|
830
822
|
|
|
831
|
-
AsymmetricMatcher$2.serialize = serialize$
|
|
823
|
+
AsymmetricMatcher$2.serialize = serialize$8;
|
|
832
824
|
|
|
833
825
|
const test$6 = val => val && val.$$typeof === asymmetricMatcher;
|
|
834
826
|
|
|
835
827
|
AsymmetricMatcher$2.test = test$6;
|
|
836
828
|
const plugin$6 = {
|
|
837
|
-
serialize: serialize$
|
|
829
|
+
serialize: serialize$8,
|
|
838
830
|
test: test$6
|
|
839
831
|
};
|
|
840
832
|
var _default$7 = plugin$6;
|
|
@@ -935,12 +927,12 @@ const test$5 = val =>
|
|
|
935
927
|
|
|
936
928
|
ConvertAnsi.test = test$5;
|
|
937
929
|
|
|
938
|
-
const serialize$
|
|
930
|
+
const serialize$7 = (val, config, indentation, depth, refs, printer) =>
|
|
939
931
|
printer(toHumanReadableAnsi(val), config, indentation, depth, refs);
|
|
940
932
|
|
|
941
|
-
ConvertAnsi.serialize = serialize$
|
|
933
|
+
ConvertAnsi.serialize = serialize$7;
|
|
942
934
|
const plugin$5 = {
|
|
943
|
-
serialize: serialize$
|
|
935
|
+
serialize: serialize$7,
|
|
944
936
|
test: test$5
|
|
945
937
|
};
|
|
946
938
|
var _default$6 = plugin$5;
|
|
@@ -981,7 +973,7 @@ DOMCollection$2.test = test$4;
|
|
|
981
973
|
const isNamedNodeMap = collection =>
|
|
982
974
|
collection.constructor.name === 'NamedNodeMap';
|
|
983
975
|
|
|
984
|
-
const serialize$
|
|
976
|
+
const serialize$6 = (collection, config, indentation, depth, refs, printer) => {
|
|
985
977
|
const name = collection.constructor.name;
|
|
986
978
|
|
|
987
979
|
if (++depth > config.maxDepth) {
|
|
@@ -1019,9 +1011,9 @@ const serialize$5 = (collection, config, indentation, depth, refs, printer) => {
|
|
|
1019
1011
|
);
|
|
1020
1012
|
};
|
|
1021
1013
|
|
|
1022
|
-
DOMCollection$2.serialize = serialize$
|
|
1014
|
+
DOMCollection$2.serialize = serialize$6;
|
|
1023
1015
|
const plugin$4 = {
|
|
1024
|
-
serialize: serialize$
|
|
1016
|
+
serialize: serialize$6,
|
|
1025
1017
|
test: test$4
|
|
1026
1018
|
};
|
|
1027
1019
|
var _default$5 = plugin$4;
|
|
@@ -1269,7 +1261,7 @@ function nodeIsFragment(node) {
|
|
|
1269
1261
|
return node.nodeType === FRAGMENT_NODE;
|
|
1270
1262
|
}
|
|
1271
1263
|
|
|
1272
|
-
const serialize$
|
|
1264
|
+
const serialize$5 = (node, config, indentation, depth, refs, printer) => {
|
|
1273
1265
|
if (nodeIsText(node)) {
|
|
1274
1266
|
return (0, _markup$2.printText)(node.data, config);
|
|
1275
1267
|
}
|
|
@@ -1319,9 +1311,9 @@ const serialize$4 = (node, config, indentation, depth, refs, printer) => {
|
|
|
1319
1311
|
);
|
|
1320
1312
|
};
|
|
1321
1313
|
|
|
1322
|
-
DOMElement$2.serialize = serialize$
|
|
1314
|
+
DOMElement$2.serialize = serialize$5;
|
|
1323
1315
|
const plugin$3 = {
|
|
1324
|
-
serialize: serialize$
|
|
1316
|
+
serialize: serialize$5,
|
|
1325
1317
|
test: test$3
|
|
1326
1318
|
};
|
|
1327
1319
|
var _default$4 = plugin$3;
|
|
@@ -1504,7 +1496,7 @@ const printImmutableValues = (
|
|
|
1504
1496
|
) +
|
|
1505
1497
|
']';
|
|
1506
1498
|
|
|
1507
|
-
const serialize$
|
|
1499
|
+
const serialize$4 = (val, config, indentation, depth, refs, printer) => {
|
|
1508
1500
|
if (val[IS_MAP_SENTINEL]) {
|
|
1509
1501
|
return printImmutableEntries(
|
|
1510
1502
|
val,
|
|
@@ -1561,7 +1553,7 @@ const serialize$3 = (val, config, indentation, depth, refs, printer) => {
|
|
|
1561
1553
|
}; // Explicitly comparing sentinel properties to true avoids false positive
|
|
1562
1554
|
// when mock identity-obj-proxy returns the key as the value for any key.
|
|
1563
1555
|
|
|
1564
|
-
Immutable$2.serialize = serialize$
|
|
1556
|
+
Immutable$2.serialize = serialize$4;
|
|
1565
1557
|
|
|
1566
1558
|
const test$2 = val =>
|
|
1567
1559
|
val &&
|
|
@@ -1569,7 +1561,7 @@ const test$2 = val =>
|
|
|
1569
1561
|
|
|
1570
1562
|
Immutable$2.test = test$2;
|
|
1571
1563
|
const plugin$2 = {
|
|
1572
|
-
serialize: serialize$
|
|
1564
|
+
serialize: serialize$4,
|
|
1573
1565
|
test: test$2
|
|
1574
1566
|
};
|
|
1575
1567
|
var _default$3 = plugin$2;
|
|
@@ -1952,7 +1944,7 @@ const getPropKeys$1 = element => {
|
|
|
1952
1944
|
.sort();
|
|
1953
1945
|
};
|
|
1954
1946
|
|
|
1955
|
-
const serialize$
|
|
1947
|
+
const serialize$3 = (element, config, indentation, depth, refs, printer) =>
|
|
1956
1948
|
++depth > config.maxDepth
|
|
1957
1949
|
? (0, _markup$1.printElementAsLeaf)(getType(element), config)
|
|
1958
1950
|
: (0, _markup$1.printElement)(
|
|
@@ -1978,13 +1970,13 @@ const serialize$2 = (element, config, indentation, depth, refs, printer) =>
|
|
|
1978
1970
|
indentation
|
|
1979
1971
|
);
|
|
1980
1972
|
|
|
1981
|
-
ReactElement$2.serialize = serialize$
|
|
1973
|
+
ReactElement$2.serialize = serialize$3;
|
|
1982
1974
|
|
|
1983
1975
|
const test$1 = val => val != null && ReactIs.isElement(val);
|
|
1984
1976
|
|
|
1985
1977
|
ReactElement$2.test = test$1;
|
|
1986
1978
|
const plugin$1 = {
|
|
1987
|
-
serialize: serialize$
|
|
1979
|
+
serialize: serialize$3,
|
|
1988
1980
|
test: test$1
|
|
1989
1981
|
};
|
|
1990
1982
|
var _default$2 = plugin$1;
|
|
@@ -2028,7 +2020,7 @@ const getPropKeys = object => {
|
|
|
2028
2020
|
: [];
|
|
2029
2021
|
};
|
|
2030
2022
|
|
|
2031
|
-
const serialize$
|
|
2023
|
+
const serialize$2 = (object, config, indentation, depth, refs, printer) =>
|
|
2032
2024
|
++depth > config.maxDepth
|
|
2033
2025
|
? (0, _markup.printElementAsLeaf)(object.type, config)
|
|
2034
2026
|
: (0, _markup.printElement)(
|
|
@@ -2058,13 +2050,13 @@ const serialize$1 = (object, config, indentation, depth, refs, printer) =>
|
|
|
2058
2050
|
indentation
|
|
2059
2051
|
);
|
|
2060
2052
|
|
|
2061
|
-
ReactTestComponent$2.serialize = serialize$
|
|
2053
|
+
ReactTestComponent$2.serialize = serialize$2;
|
|
2062
2054
|
|
|
2063
2055
|
const test = val => val && val.$$typeof === testSymbol;
|
|
2064
2056
|
|
|
2065
2057
|
ReactTestComponent$2.test = test;
|
|
2066
2058
|
const plugin = {
|
|
2067
|
-
serialize: serialize$
|
|
2059
|
+
serialize: serialize$2,
|
|
2068
2060
|
test
|
|
2069
2061
|
};
|
|
2070
2062
|
var _default$1 = plugin;
|
|
@@ -2730,7 +2722,7 @@ ${string}
|
|
|
2730
2722
|
const removeExtraLineBreaks = (string) => string.length > 2 && string.startsWith("\n") && string.endsWith("\n") ? string.slice(1, -1) : string;
|
|
2731
2723
|
const escapeRegex = true;
|
|
2732
2724
|
const printFunctionName = false;
|
|
2733
|
-
function serialize(val, indent = 2, formatOverrides = {}) {
|
|
2725
|
+
function serialize$1(val, indent = 2, formatOverrides = {}) {
|
|
2734
2726
|
return normalizeNewlines(format_1(val, __spreadValues$1({
|
|
2735
2727
|
escapeRegex,
|
|
2736
2728
|
indent,
|
|
@@ -2844,7 +2836,7 @@ class SnapshotState {
|
|
|
2844
2836
|
key = testNameToKey(testName, count);
|
|
2845
2837
|
if (!(isInline && this._snapshotData[key] !== void 0))
|
|
2846
2838
|
this._uncheckedKeys.delete(key);
|
|
2847
|
-
const receivedSerialized = addExtraLineBreaks(serialize(received, void 0, this._snapshotFormat));
|
|
2839
|
+
const receivedSerialized = addExtraLineBreaks(serialize$1(received, void 0, this._snapshotFormat));
|
|
2848
2840
|
const expected = isInline ? inlineSnapshot : this._snapshotData[key];
|
|
2849
2841
|
const pass = (expected == null ? void 0 : expected.trim()) === (receivedSerialized == null ? void 0 : receivedSerialized.trim());
|
|
2850
2842
|
const hasSnapshot = expected !== void 0;
|
|
@@ -3669,6 +3661,23 @@ async function runSetupFiles(config) {
|
|
|
3669
3661
|
}));
|
|
3670
3662
|
}
|
|
3671
3663
|
|
|
3664
|
+
function serialize(err) {
|
|
3665
|
+
if (typeof err !== "object")
|
|
3666
|
+
return err;
|
|
3667
|
+
Object.keys(err).forEach((key) => {
|
|
3668
|
+
const val = err[key];
|
|
3669
|
+
if (typeof val === "function")
|
|
3670
|
+
err[key] = `Function<${val.name}>`;
|
|
3671
|
+
if (typeof val !== "object")
|
|
3672
|
+
return;
|
|
3673
|
+
if ("then" in val)
|
|
3674
|
+
err[key] = "Promise";
|
|
3675
|
+
if (typeof Element !== "undefined" && val instanceof Element)
|
|
3676
|
+
err[key] = val.tagName;
|
|
3677
|
+
serialize(err[key]);
|
|
3678
|
+
});
|
|
3679
|
+
return err;
|
|
3680
|
+
}
|
|
3672
3681
|
function processError(err) {
|
|
3673
3682
|
if (!err)
|
|
3674
3683
|
return err;
|
|
@@ -3676,7 +3685,7 @@ function processError(err) {
|
|
|
3676
3685
|
err.stackStr = String(err.stack);
|
|
3677
3686
|
if (err.name)
|
|
3678
3687
|
err.nameStr = String(err.name);
|
|
3679
|
-
return err;
|
|
3688
|
+
return serialize(err);
|
|
3680
3689
|
}
|
|
3681
3690
|
|
|
3682
3691
|
async function collectTests(paths, config) {
|
|
@@ -3696,9 +3705,12 @@ async function collectTests(paths, config) {
|
|
|
3696
3705
|
try {
|
|
3697
3706
|
await runSetupFiles(config);
|
|
3698
3707
|
await import(filepath);
|
|
3699
|
-
|
|
3708
|
+
const defaultTasks = await defaultSuite.collect(file);
|
|
3709
|
+
for (const c of [...defaultTasks.tasks, ...context.tasks]) {
|
|
3700
3710
|
if (c.type === "test") {
|
|
3701
3711
|
file.tasks.push(c);
|
|
3712
|
+
} else if (c.type === "suite") {
|
|
3713
|
+
file.tasks.push(c);
|
|
3702
3714
|
} else {
|
|
3703
3715
|
const suite = await c.collect(file);
|
|
3704
3716
|
if (suite.name || suite.tasks.length)
|
package/dist/index.d.ts
CHANGED
|
@@ -148,7 +148,7 @@ interface VitestContext {
|
|
|
148
148
|
server: ViteDevServer;
|
|
149
149
|
state: StateManager;
|
|
150
150
|
snapshot: SnapshotManager;
|
|
151
|
-
|
|
151
|
+
reporters: Reporter[];
|
|
152
152
|
console: Console;
|
|
153
153
|
}
|
|
154
154
|
interface UserConsoleLog {
|
|
@@ -359,7 +359,7 @@ interface UserOptions {
|
|
|
359
359
|
/**
|
|
360
360
|
* Custom reporter for output
|
|
361
361
|
*/
|
|
362
|
-
|
|
362
|
+
reporters?: Reporter | Reporter[];
|
|
363
363
|
/**
|
|
364
364
|
* Enable multi-threading
|
|
365
365
|
*
|
|
@@ -448,6 +448,7 @@ interface WorkerContext {
|
|
|
448
448
|
interface RpcMap {
|
|
449
449
|
fetch: [[id: string], TransformResult | null | undefined];
|
|
450
450
|
log: [[UserConsoleLog], void];
|
|
451
|
+
processExit: [[code?: number], void];
|
|
451
452
|
onCollected: [[files: File[]], void];
|
|
452
453
|
onFinished: [[], void];
|
|
453
454
|
onTaskUpdate: [[pack: TaskResultPack], void];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const rpc = async (method, ...args) => {
|
|
2
|
+
var _a;
|
|
3
|
+
return (_a = process.__vitest_worker__) == null ? void 0 : _a.rpc(method, ...args);
|
|
4
|
+
};
|
|
5
|
+
const send = async (method, ...args) => {
|
|
6
|
+
var _a;
|
|
7
|
+
return (_a = process.__vitest_worker__) == null ? void 0 : _a.send(method, ...args);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { rpc as r, send as s };
|
package/dist/worker.js
CHANGED
|
@@ -5,6 +5,7 @@ import { builtinModules, createRequire } from 'module';
|
|
|
5
5
|
import { pathToFileURL, fileURLToPath } from 'url';
|
|
6
6
|
import vm from 'vm';
|
|
7
7
|
import { s as slash } from './utils-9dcc4050.js';
|
|
8
|
+
import { s as send } from './rpc-7de86f29.js';
|
|
8
9
|
|
|
9
10
|
const defaultInline = [
|
|
10
11
|
"vitest/dist",
|
|
@@ -208,6 +209,14 @@ const moduleCache = new Map();
|
|
|
208
209
|
async function init(ctx) {
|
|
209
210
|
if (_run)
|
|
210
211
|
return _run;
|
|
212
|
+
const processExit = process.exit;
|
|
213
|
+
process.on("beforeExit", (code) => {
|
|
214
|
+
send("processExit", code);
|
|
215
|
+
});
|
|
216
|
+
process.exit = (code = process.exitCode || 0) => {
|
|
217
|
+
send("processExit", code);
|
|
218
|
+
return processExit(code);
|
|
219
|
+
};
|
|
211
220
|
const { config } = ctx;
|
|
212
221
|
_run = (await executeInViteNode({
|
|
213
222
|
root: config.root,
|