vitest 0.0.78 → 0.0.82
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 +25 -1884
- package/dist/{constants-2435fa16.js → constants-adef7ffb.js} +5 -6
- package/dist/entry.js +84 -79
- package/dist/{error-c9295525.js → error-dd23da12.js} +2 -2
- package/dist/{global-38c2f902.js → global-cae0ce06.js} +3 -3
- package/dist/{index-6feda5ef.js → index-16a06164.js} +8 -7
- package/dist/index-9a2ee1fc.js +1880 -0
- package/dist/index.d.ts +25 -50
- package/dist/index.js +2 -2
- package/dist/{middleware-37267df8.js → middleware-650c5fa0.js} +1 -1
- package/dist/node.js +19 -0
- package/dist/rpc-7de86f29.js +10 -0
- package/dist/worker.js +10 -1
- package/global.d.ts +2 -3
- package/package.json +10 -6
|
@@ -2,8 +2,8 @@ import { resolve } from 'path';
|
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
|
|
4
4
|
const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
|
|
6
|
+
const defaultExclude = ["**/node_modules/**", "**/dist/**"];
|
|
7
7
|
const defaultPort = 51204;
|
|
8
8
|
const API_PATH = "/__vitest_api__";
|
|
9
9
|
const configFiles = [
|
|
@@ -22,14 +22,13 @@ const globalApis = [
|
|
|
22
22
|
"chai",
|
|
23
23
|
"expect",
|
|
24
24
|
"assert",
|
|
25
|
-
"sinon",
|
|
26
25
|
"spy",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
26
|
+
"spyOn",
|
|
27
|
+
"vitest",
|
|
29
28
|
"beforeAll",
|
|
30
29
|
"afterAll",
|
|
31
30
|
"beforeEach",
|
|
32
31
|
"afterEach"
|
|
33
32
|
];
|
|
34
33
|
|
|
35
|
-
export { API_PATH as A,
|
|
34
|
+
export { API_PATH as A, defaultExclude as a, defaultPort as b, distDir as c, defaultInclude as d, configFiles as e, globalApis as g };
|
package/dist/entry.js
CHANGED
|
@@ -2,12 +2,12 @@ import { Console } from 'console';
|
|
|
2
2
|
import { Writable } from 'stream';
|
|
3
3
|
import { importModule } from 'local-pkg';
|
|
4
4
|
import chai, { expect, util } from 'chai';
|
|
5
|
-
import SinonChai from 'sinon-chai';
|
|
6
5
|
import Subset from 'chai-subset';
|
|
7
6
|
import path, { basename } from 'path';
|
|
7
|
+
import { r as rpc, s as send } from './rpc-7de86f29.js';
|
|
8
8
|
import { g as getNames, t as toArray, i as interpretOnlyMode, p as partitionSuiteChildren, c as hasTests, h as hasFailed } from './utils-9dcc4050.js';
|
|
9
9
|
import fs from 'fs';
|
|
10
|
-
import {
|
|
10
|
+
import { c as c$1, m as generateDiff } from './error-dd23da12.js';
|
|
11
11
|
import { performance } from 'perf_hooks';
|
|
12
12
|
import { b as setHooks, c as createSuiteHooks, e as clearContext, f as defaultSuite, h as context, j as getHooks, k as getFn } from './suite-95be5909.js';
|
|
13
13
|
import { n as nanoid } from './index-9e71c815.js';
|
|
@@ -296,15 +296,6 @@ const environments = {
|
|
|
296
296
|
"happy-dom": happy
|
|
297
297
|
};
|
|
298
298
|
|
|
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
299
|
var naturalCompare$2 = {exports: {}};
|
|
309
300
|
|
|
310
301
|
/*
|
|
@@ -752,7 +743,7 @@ const asymmetricMatcher =
|
|
|
752
743
|
: 0x1357a5;
|
|
753
744
|
const SPACE$2 = ' ';
|
|
754
745
|
|
|
755
|
-
const serialize$
|
|
746
|
+
const serialize$8 = (val, config, indentation, depth, refs, printer) => {
|
|
756
747
|
const stringedValue = val.toString();
|
|
757
748
|
|
|
758
749
|
if (
|
|
@@ -828,13 +819,13 @@ const serialize$7 = (val, config, indentation, depth, refs, printer) => {
|
|
|
828
819
|
return val.toAsymmetricMatcher();
|
|
829
820
|
};
|
|
830
821
|
|
|
831
|
-
AsymmetricMatcher$2.serialize = serialize$
|
|
822
|
+
AsymmetricMatcher$2.serialize = serialize$8;
|
|
832
823
|
|
|
833
824
|
const test$6 = val => val && val.$$typeof === asymmetricMatcher;
|
|
834
825
|
|
|
835
826
|
AsymmetricMatcher$2.test = test$6;
|
|
836
827
|
const plugin$6 = {
|
|
837
|
-
serialize: serialize$
|
|
828
|
+
serialize: serialize$8,
|
|
838
829
|
test: test$6
|
|
839
830
|
};
|
|
840
831
|
var _default$7 = plugin$6;
|
|
@@ -935,12 +926,12 @@ const test$5 = val =>
|
|
|
935
926
|
|
|
936
927
|
ConvertAnsi.test = test$5;
|
|
937
928
|
|
|
938
|
-
const serialize$
|
|
929
|
+
const serialize$7 = (val, config, indentation, depth, refs, printer) =>
|
|
939
930
|
printer(toHumanReadableAnsi(val), config, indentation, depth, refs);
|
|
940
931
|
|
|
941
|
-
ConvertAnsi.serialize = serialize$
|
|
932
|
+
ConvertAnsi.serialize = serialize$7;
|
|
942
933
|
const plugin$5 = {
|
|
943
|
-
serialize: serialize$
|
|
934
|
+
serialize: serialize$7,
|
|
944
935
|
test: test$5
|
|
945
936
|
};
|
|
946
937
|
var _default$6 = plugin$5;
|
|
@@ -981,7 +972,7 @@ DOMCollection$2.test = test$4;
|
|
|
981
972
|
const isNamedNodeMap = collection =>
|
|
982
973
|
collection.constructor.name === 'NamedNodeMap';
|
|
983
974
|
|
|
984
|
-
const serialize$
|
|
975
|
+
const serialize$6 = (collection, config, indentation, depth, refs, printer) => {
|
|
985
976
|
const name = collection.constructor.name;
|
|
986
977
|
|
|
987
978
|
if (++depth > config.maxDepth) {
|
|
@@ -1019,9 +1010,9 @@ const serialize$5 = (collection, config, indentation, depth, refs, printer) => {
|
|
|
1019
1010
|
);
|
|
1020
1011
|
};
|
|
1021
1012
|
|
|
1022
|
-
DOMCollection$2.serialize = serialize$
|
|
1013
|
+
DOMCollection$2.serialize = serialize$6;
|
|
1023
1014
|
const plugin$4 = {
|
|
1024
|
-
serialize: serialize$
|
|
1015
|
+
serialize: serialize$6,
|
|
1025
1016
|
test: test$4
|
|
1026
1017
|
};
|
|
1027
1018
|
var _default$5 = plugin$4;
|
|
@@ -1269,7 +1260,7 @@ function nodeIsFragment(node) {
|
|
|
1269
1260
|
return node.nodeType === FRAGMENT_NODE;
|
|
1270
1261
|
}
|
|
1271
1262
|
|
|
1272
|
-
const serialize$
|
|
1263
|
+
const serialize$5 = (node, config, indentation, depth, refs, printer) => {
|
|
1273
1264
|
if (nodeIsText(node)) {
|
|
1274
1265
|
return (0, _markup$2.printText)(node.data, config);
|
|
1275
1266
|
}
|
|
@@ -1319,9 +1310,9 @@ const serialize$4 = (node, config, indentation, depth, refs, printer) => {
|
|
|
1319
1310
|
);
|
|
1320
1311
|
};
|
|
1321
1312
|
|
|
1322
|
-
DOMElement$2.serialize = serialize$
|
|
1313
|
+
DOMElement$2.serialize = serialize$5;
|
|
1323
1314
|
const plugin$3 = {
|
|
1324
|
-
serialize: serialize$
|
|
1315
|
+
serialize: serialize$5,
|
|
1325
1316
|
test: test$3
|
|
1326
1317
|
};
|
|
1327
1318
|
var _default$4 = plugin$3;
|
|
@@ -1504,7 +1495,7 @@ const printImmutableValues = (
|
|
|
1504
1495
|
) +
|
|
1505
1496
|
']';
|
|
1506
1497
|
|
|
1507
|
-
const serialize$
|
|
1498
|
+
const serialize$4 = (val, config, indentation, depth, refs, printer) => {
|
|
1508
1499
|
if (val[IS_MAP_SENTINEL]) {
|
|
1509
1500
|
return printImmutableEntries(
|
|
1510
1501
|
val,
|
|
@@ -1561,7 +1552,7 @@ const serialize$3 = (val, config, indentation, depth, refs, printer) => {
|
|
|
1561
1552
|
}; // Explicitly comparing sentinel properties to true avoids false positive
|
|
1562
1553
|
// when mock identity-obj-proxy returns the key as the value for any key.
|
|
1563
1554
|
|
|
1564
|
-
Immutable$2.serialize = serialize$
|
|
1555
|
+
Immutable$2.serialize = serialize$4;
|
|
1565
1556
|
|
|
1566
1557
|
const test$2 = val =>
|
|
1567
1558
|
val &&
|
|
@@ -1569,7 +1560,7 @@ const test$2 = val =>
|
|
|
1569
1560
|
|
|
1570
1561
|
Immutable$2.test = test$2;
|
|
1571
1562
|
const plugin$2 = {
|
|
1572
|
-
serialize: serialize$
|
|
1563
|
+
serialize: serialize$4,
|
|
1573
1564
|
test: test$2
|
|
1574
1565
|
};
|
|
1575
1566
|
var _default$3 = plugin$2;
|
|
@@ -1952,7 +1943,7 @@ const getPropKeys$1 = element => {
|
|
|
1952
1943
|
.sort();
|
|
1953
1944
|
};
|
|
1954
1945
|
|
|
1955
|
-
const serialize$
|
|
1946
|
+
const serialize$3 = (element, config, indentation, depth, refs, printer) =>
|
|
1956
1947
|
++depth > config.maxDepth
|
|
1957
1948
|
? (0, _markup$1.printElementAsLeaf)(getType(element), config)
|
|
1958
1949
|
: (0, _markup$1.printElement)(
|
|
@@ -1978,13 +1969,13 @@ const serialize$2 = (element, config, indentation, depth, refs, printer) =>
|
|
|
1978
1969
|
indentation
|
|
1979
1970
|
);
|
|
1980
1971
|
|
|
1981
|
-
ReactElement$2.serialize = serialize$
|
|
1972
|
+
ReactElement$2.serialize = serialize$3;
|
|
1982
1973
|
|
|
1983
1974
|
const test$1 = val => val != null && ReactIs.isElement(val);
|
|
1984
1975
|
|
|
1985
1976
|
ReactElement$2.test = test$1;
|
|
1986
1977
|
const plugin$1 = {
|
|
1987
|
-
serialize: serialize$
|
|
1978
|
+
serialize: serialize$3,
|
|
1988
1979
|
test: test$1
|
|
1989
1980
|
};
|
|
1990
1981
|
var _default$2 = plugin$1;
|
|
@@ -2028,7 +2019,7 @@ const getPropKeys = object => {
|
|
|
2028
2019
|
: [];
|
|
2029
2020
|
};
|
|
2030
2021
|
|
|
2031
|
-
const serialize$
|
|
2022
|
+
const serialize$2 = (object, config, indentation, depth, refs, printer) =>
|
|
2032
2023
|
++depth > config.maxDepth
|
|
2033
2024
|
? (0, _markup.printElementAsLeaf)(object.type, config)
|
|
2034
2025
|
: (0, _markup.printElement)(
|
|
@@ -2058,13 +2049,13 @@ const serialize$1 = (object, config, indentation, depth, refs, printer) =>
|
|
|
2058
2049
|
indentation
|
|
2059
2050
|
);
|
|
2060
2051
|
|
|
2061
|
-
ReactTestComponent$2.serialize = serialize$
|
|
2052
|
+
ReactTestComponent$2.serialize = serialize$2;
|
|
2062
2053
|
|
|
2063
2054
|
const test = val => val && val.$$typeof === testSymbol;
|
|
2064
2055
|
|
|
2065
2056
|
ReactTestComponent$2.test = test;
|
|
2066
2057
|
const plugin = {
|
|
2067
|
-
serialize: serialize$
|
|
2058
|
+
serialize: serialize$2,
|
|
2068
2059
|
test
|
|
2069
2060
|
};
|
|
2070
2061
|
var _default$1 = plugin;
|
|
@@ -2730,7 +2721,7 @@ ${string}
|
|
|
2730
2721
|
const removeExtraLineBreaks = (string) => string.length > 2 && string.startsWith("\n") && string.endsWith("\n") ? string.slice(1, -1) : string;
|
|
2731
2722
|
const escapeRegex = true;
|
|
2732
2723
|
const printFunctionName = false;
|
|
2733
|
-
function serialize(val, indent = 2, formatOverrides = {}) {
|
|
2724
|
+
function serialize$1(val, indent = 2, formatOverrides = {}) {
|
|
2734
2725
|
return normalizeNewlines(format_1(val, __spreadValues$1({
|
|
2735
2726
|
escapeRegex,
|
|
2736
2727
|
indent,
|
|
@@ -2844,7 +2835,7 @@ class SnapshotState {
|
|
|
2844
2835
|
key = testNameToKey(testName, count);
|
|
2845
2836
|
if (!(isInline && this._snapshotData[key] !== void 0))
|
|
2846
2837
|
this._uncheckedKeys.delete(key);
|
|
2847
|
-
const receivedSerialized = addExtraLineBreaks(serialize(received, void 0, this._snapshotFormat));
|
|
2838
|
+
const receivedSerialized = addExtraLineBreaks(serialize$1(received, void 0, this._snapshotFormat));
|
|
2848
2839
|
const expected = isInline ? inlineSnapshot : this._snapshotData[key];
|
|
2849
2840
|
const pass = (expected == null ? void 0 : expected.trim()) === (receivedSerialized == null ? void 0 : receivedSerialized.trim());
|
|
2850
2841
|
const hasSnapshot = expected !== void 0;
|
|
@@ -3509,30 +3500,29 @@ function JestChaiExpect() {
|
|
|
3509
3500
|
return this.closeTo(number, numDigits);
|
|
3510
3501
|
});
|
|
3511
3502
|
function isSpy(putativeSpy) {
|
|
3512
|
-
return typeof putativeSpy === "function" &&
|
|
3513
|
-
}
|
|
3514
|
-
function isCall(putativeCall) {
|
|
3515
|
-
return putativeCall && isSpy(putativeCall.proxy);
|
|
3503
|
+
return typeof putativeSpy === "function" && "__isSpy" in putativeSpy && putativeSpy.__isSpy;
|
|
3516
3504
|
}
|
|
3517
3505
|
const assertIsMock = (assertion) => {
|
|
3518
|
-
if (!isSpy(assertion._obj)
|
|
3506
|
+
if (!isSpy(assertion._obj))
|
|
3519
3507
|
throw new TypeError(`${utils.inspect(assertion._obj)} is not a spy or a call to a spy!`);
|
|
3520
3508
|
};
|
|
3509
|
+
const getSpy = (assertion) => {
|
|
3510
|
+
assertIsMock(assertion);
|
|
3511
|
+
return assertion._obj;
|
|
3512
|
+
};
|
|
3521
3513
|
def(["toHaveBeenCalledTimes", "toBeCalledTimes"], function(number) {
|
|
3522
|
-
|
|
3523
|
-
return this.callCount(number);
|
|
3514
|
+
return this.assert(getSpy(this).callCount === number, "expected spy to be called #{exp} times", "expected spy to not be called #{exp} times", number);
|
|
3524
3515
|
});
|
|
3525
3516
|
def("toHaveBeenCalledOnce", function() {
|
|
3526
|
-
|
|
3527
|
-
return this.callCount(1);
|
|
3517
|
+
return this.assert(getSpy(this).callCount === 1, "expected spy to be called once", "expected spy to not be called once", 1);
|
|
3528
3518
|
});
|
|
3529
3519
|
def(["toHaveBeenCalled", "toBeCalled"], function() {
|
|
3530
|
-
|
|
3531
|
-
return this.called;
|
|
3520
|
+
return this.assert(getSpy(this).called, "expected spy to be called at least once", "expected spy to not be called at all", true);
|
|
3532
3521
|
});
|
|
3533
3522
|
def(["toHaveBeenCalledWith", "toBeCalledWith"], function(...args) {
|
|
3534
|
-
|
|
3535
|
-
|
|
3523
|
+
const spy = getSpy(this);
|
|
3524
|
+
const pass = spy.calls.some((callArg) => equals(callArg, args));
|
|
3525
|
+
return this.assert(pass, "expected spy to be called with arguments: #{exp}", "expected spy to not be called with arguments: #{exp}", args);
|
|
3536
3526
|
});
|
|
3537
3527
|
const ordinalOf = (i) => {
|
|
3538
3528
|
const j = i % 10;
|
|
@@ -3546,16 +3536,14 @@ function JestChaiExpect() {
|
|
|
3546
3536
|
return `${i}th`;
|
|
3547
3537
|
};
|
|
3548
3538
|
def(["toHaveBeenNthCalledWith", "nthCalledWith"], function(times, ...args) {
|
|
3549
|
-
|
|
3550
|
-
const
|
|
3551
|
-
|
|
3552
|
-
this.assert(nthCall.calledWith(...args), `expected ${ordinalOf(times)} spy call to have been called with #{exp}`, `expected ${ordinalOf(times)} spy call not to have been called with #{exp}`, args, nthCall.args);
|
|
3539
|
+
const spy = getSpy(this);
|
|
3540
|
+
const nthCall = spy.calls[times - 1];
|
|
3541
|
+
this.assert(equals(nthCall, args), `expected ${ordinalOf(times)} spy call to have been called with #{exp}`, `expected ${ordinalOf(times)} spy call to not have been called with #{exp}`, args, nthCall);
|
|
3553
3542
|
});
|
|
3554
3543
|
def(["toHaveBeenLastCalledWith", "lastCalledWith"], function(...args) {
|
|
3555
|
-
|
|
3556
|
-
const
|
|
3557
|
-
|
|
3558
|
-
this.assert(lastCall.calledWith(...args), "expected last spy call to have been called with #{exp}", "expected last spy call not to have been called with #{exp}", args, lastCall.args);
|
|
3544
|
+
const spy = getSpy(this);
|
|
3545
|
+
const lastCall = spy.calls.at(-1);
|
|
3546
|
+
this.assert(equals(lastCall, args), "expected last spy call to have been called with #{exp}", "expected last spy call to not have been called with #{exp}", args, lastCall);
|
|
3559
3547
|
});
|
|
3560
3548
|
def(["toThrow", "toThrowError"], function(expected) {
|
|
3561
3549
|
const negate = utils.flag(this, "negate");
|
|
@@ -3565,37 +3553,35 @@ function JestChaiExpect() {
|
|
|
3565
3553
|
this.to.throw(expected);
|
|
3566
3554
|
});
|
|
3567
3555
|
def(["toHaveReturned", "toReturn"], function() {
|
|
3568
|
-
|
|
3569
|
-
const
|
|
3570
|
-
|
|
3571
|
-
this.assert(calledAndNotThrew, "expected spy to be successfully called at least once", "expected spy not to be successfully called", calledAndNotThrew, !calledAndNotThrew);
|
|
3556
|
+
const spy = getSpy(this);
|
|
3557
|
+
const calledAndNotThrew = spy.called && !spy.results.some(([type]) => type === "error");
|
|
3558
|
+
this.assert(calledAndNotThrew, "expected spy to be successfully called at least once", "expected spy to not be successfully called", calledAndNotThrew, !calledAndNotThrew);
|
|
3572
3559
|
});
|
|
3573
3560
|
def(["toHaveReturnedTimes", "toReturnTimes"], function(times) {
|
|
3574
|
-
|
|
3575
|
-
const
|
|
3576
|
-
|
|
3577
|
-
this.assert(successfullReturns === times, `expected spy to be successfully called ${times} times`, `expected spy not to be successfully called ${times} times`, `expected number of returns: ${times}`, `recieved number of returns: ${successfullReturns}`);
|
|
3561
|
+
const spy = getSpy(this);
|
|
3562
|
+
const successfullReturns = spy.results.reduce((success, [type]) => type === "error" ? success : ++success, 0);
|
|
3563
|
+
this.assert(successfullReturns === times, `expected spy to be successfully called ${times} times`, `expected spy to not be successfully called ${times} times`, `expected number of returns: ${times}`, `received number of returns: ${successfullReturns}`);
|
|
3578
3564
|
});
|
|
3579
3565
|
def(["toHaveReturnedWith", "toReturnWith"], function(value) {
|
|
3580
|
-
|
|
3581
|
-
|
|
3566
|
+
const spy = getSpy(this);
|
|
3567
|
+
const pass = spy.results.some(([type, result]) => type === "ok" && equals(value, result));
|
|
3568
|
+
this.assert(pass, "expected spy to be successfully called with #{exp}", "expected spy to not be successfully called with #{exp}", value);
|
|
3582
3569
|
});
|
|
3583
3570
|
def(["toHaveLastReturnedWith", "lastReturnedWith"], function(value) {
|
|
3584
|
-
|
|
3585
|
-
const
|
|
3586
|
-
const
|
|
3587
|
-
this.assert(
|
|
3571
|
+
const spy = getSpy(this);
|
|
3572
|
+
const lastResult = spy.returns.at(-1);
|
|
3573
|
+
const pass = equals(lastResult, value);
|
|
3574
|
+
this.assert(pass, "expected last spy call to return #{exp}", "expected last spy call to not return #{exp}", value, lastResult);
|
|
3588
3575
|
});
|
|
3589
3576
|
def(["toHaveNthReturnedWith", "nthReturnedWith"], function(nthCall, value) {
|
|
3590
|
-
|
|
3591
|
-
const spy = utils.flag(this, "object");
|
|
3577
|
+
const spy = getSpy(this);
|
|
3592
3578
|
const isNot = utils.flag(this, "negate");
|
|
3593
|
-
const
|
|
3579
|
+
const [callType, callResult] = spy.results[nthCall - 1];
|
|
3594
3580
|
const ordinalCall = `${ordinalOf(nthCall)} call`;
|
|
3595
|
-
if (!isNot &&
|
|
3581
|
+
if (!isNot && callType === "error")
|
|
3596
3582
|
chai.assert.fail(`expected ${ordinalCall} to return #{exp}, but instead it threw an error`);
|
|
3597
|
-
const nthCallReturn =
|
|
3598
|
-
this.assert(nthCallReturn, `expected ${ordinalCall} spy call to return #{exp}`, `expected ${ordinalCall} spy call not
|
|
3583
|
+
const nthCallReturn = equals(callResult, value);
|
|
3584
|
+
this.assert(nthCallReturn, `expected ${ordinalCall} spy call to return #{exp}`, `expected ${ordinalCall} spy call to not return #{exp}`, value, callResult);
|
|
3599
3585
|
});
|
|
3600
3586
|
};
|
|
3601
3587
|
}
|
|
@@ -3604,7 +3590,6 @@ let installed = false;
|
|
|
3604
3590
|
async function setupChai() {
|
|
3605
3591
|
if (installed)
|
|
3606
3592
|
return;
|
|
3607
|
-
chai.use(SinonChai);
|
|
3608
3593
|
chai.use(JestExtend());
|
|
3609
3594
|
chai.use(JestChaiExpect());
|
|
3610
3595
|
chai.use(Subset);
|
|
@@ -3620,7 +3605,7 @@ async function setupGlobalEnv(config) {
|
|
|
3620
3605
|
setupConsoleLogSpy();
|
|
3621
3606
|
await setupChai();
|
|
3622
3607
|
if (config.global)
|
|
3623
|
-
(await import('./global-
|
|
3608
|
+
(await import('./global-cae0ce06.js')).registerApiGlobally();
|
|
3624
3609
|
}
|
|
3625
3610
|
function setupConsoleLogSpy() {
|
|
3626
3611
|
const stdout = new Writable({
|
|
@@ -3669,6 +3654,23 @@ async function runSetupFiles(config) {
|
|
|
3669
3654
|
}));
|
|
3670
3655
|
}
|
|
3671
3656
|
|
|
3657
|
+
function serialize(err) {
|
|
3658
|
+
if (typeof err !== "object")
|
|
3659
|
+
return err;
|
|
3660
|
+
Object.keys(err).forEach((key) => {
|
|
3661
|
+
const val = err[key];
|
|
3662
|
+
if (typeof val === "function")
|
|
3663
|
+
err[key] = `Function<${val.name}>`;
|
|
3664
|
+
if (typeof val !== "object")
|
|
3665
|
+
return;
|
|
3666
|
+
if ("then" in val)
|
|
3667
|
+
err[key] = "Promise";
|
|
3668
|
+
if (typeof Element !== "undefined" && val instanceof Element)
|
|
3669
|
+
err[key] = val.tagName;
|
|
3670
|
+
serialize(err[key]);
|
|
3671
|
+
});
|
|
3672
|
+
return err;
|
|
3673
|
+
}
|
|
3672
3674
|
function processError(err) {
|
|
3673
3675
|
if (!err)
|
|
3674
3676
|
return err;
|
|
@@ -3676,7 +3678,7 @@ function processError(err) {
|
|
|
3676
3678
|
err.stackStr = String(err.stack);
|
|
3677
3679
|
if (err.name)
|
|
3678
3680
|
err.nameStr = String(err.name);
|
|
3679
|
-
return err;
|
|
3681
|
+
return serialize(err);
|
|
3680
3682
|
}
|
|
3681
3683
|
|
|
3682
3684
|
async function collectTests(paths, config) {
|
|
@@ -3696,9 +3698,12 @@ async function collectTests(paths, config) {
|
|
|
3696
3698
|
try {
|
|
3697
3699
|
await runSetupFiles(config);
|
|
3698
3700
|
await import(filepath);
|
|
3699
|
-
|
|
3701
|
+
const defaultTasks = await defaultSuite.collect(file);
|
|
3702
|
+
for (const c of [...defaultTasks.tasks, ...context.tasks]) {
|
|
3700
3703
|
if (c.type === "test") {
|
|
3701
3704
|
file.tasks.push(c);
|
|
3705
|
+
} else if (c.type === "suite") {
|
|
3706
|
+
file.tasks.push(c);
|
|
3702
3707
|
} else {
|
|
3703
3708
|
const suite = await c.collect(file);
|
|
3704
3709
|
if (suite.name || suite.tasks.length)
|
|
@@ -1303,7 +1303,7 @@ async function printStack(ctx, stack, highlight, onStack) {
|
|
|
1303
1303
|
const color = frame === highlight ? c.yellow : c.gray;
|
|
1304
1304
|
const path = relative(ctx.config.root, frame.file);
|
|
1305
1305
|
ctx.console.log(color(` ${c.dim(F_POINTER)} ${[frame.method, c.dim(`${path}:${pos.line}:${pos.column}`)].filter(Boolean).join(" ")}`));
|
|
1306
|
-
onStack == null ? void 0 : onStack(frame, pos);
|
|
1306
|
+
await (onStack == null ? void 0 : onStack(frame, pos));
|
|
1307
1307
|
if (frame.file in ctx.state.filesMap)
|
|
1308
1308
|
break;
|
|
1309
1309
|
}
|
|
@@ -1428,4 +1428,4 @@ function notBlank(line) {
|
|
|
1428
1428
|
return typeof line !== "undefined" && line !== null;
|
|
1429
1429
|
}
|
|
1430
1430
|
|
|
1431
|
-
export { F_POINTER as F, ansiStyles as a, stripAnsi as b,
|
|
1431
|
+
export { F_POINTER as F, ansiStyles as a, stripAnsi as b, c, sliceAnsi as d, F_DOWN as e, F_LONG_DASH as f, F_DOWN_RIGHT as g, F_DOT as h, F_CHECK as i, F_CROSS as j, cliTruncate as k, F_RIGHT as l, generateDiff as m, printError as p, stringWidth as s };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { g as globalApis } from './constants-
|
|
2
|
-
import { i as index } from './index-
|
|
1
|
+
import { g as globalApis } from './constants-adef7ffb.js';
|
|
2
|
+
import { i as index } from './index-16a06164.js';
|
|
3
3
|
import 'path';
|
|
4
4
|
import 'url';
|
|
5
5
|
import './suite-95be5909.js';
|
|
6
6
|
import './index-9e71c815.js';
|
|
7
7
|
import 'chai';
|
|
8
|
-
import '
|
|
8
|
+
import 'tinyspy';
|
|
9
9
|
|
|
10
10
|
function registerApiGlobally() {
|
|
11
11
|
globalApis.forEach((api) => {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it } from './suite-95be5909.js';
|
|
2
2
|
import chai, { assert, should, expect } from 'chai';
|
|
3
|
-
import
|
|
3
|
+
import { spyOn, spy } from 'tinyspy';
|
|
4
4
|
|
|
5
5
|
const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
6
6
|
const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
7
7
|
const beforeEach = (fn, timeout) => getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
8
8
|
const afterEach = (fn, timeout) => getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const vitest = {
|
|
11
|
+
spyOn,
|
|
12
|
+
fn: spy
|
|
13
|
+
};
|
|
12
14
|
|
|
13
15
|
var index = /*#__PURE__*/Object.freeze({
|
|
14
16
|
__proto__: null,
|
|
@@ -24,10 +26,9 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
24
26
|
should: should,
|
|
25
27
|
expect: expect,
|
|
26
28
|
chai: chai,
|
|
27
|
-
sinon: sinon,
|
|
28
|
-
mock: mock,
|
|
29
29
|
spy: spy,
|
|
30
|
-
|
|
30
|
+
spyOn: spyOn,
|
|
31
|
+
vitest: vitest
|
|
31
32
|
});
|
|
32
33
|
|
|
33
|
-
export { afterAll as a, beforeAll as b, beforeEach as c, afterEach as d,
|
|
34
|
+
export { afterAll as a, beforeAll as b, beforeEach as c, afterEach as d, index as i, vitest as v };
|