vitest 0.0.69 → 0.0.73
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/README.gh.md +10 -276
- package/dist/cli.js +29 -1423
- package/dist/entry.js +551 -83
- package/dist/error-5a04e54b.js +1415 -0
- package/dist/index.d.ts +118 -2
- package/dist/worker.js +14 -0
- package/global.d.ts +0 -1
- package/package.json +8 -7
package/dist/entry.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Console } from 'console';
|
|
2
|
+
import { Writable } from 'stream';
|
|
3
|
+
import { importModule } from 'local-pkg';
|
|
4
|
+
import chai, { expect, util } from 'chai';
|
|
2
5
|
import SinonChai from 'sinon-chai';
|
|
3
6
|
import Subset from 'chai-subset';
|
|
4
7
|
import path, { basename } from 'path';
|
|
5
8
|
import { g as getNames, i as interpretOnlyMode, p as partitionSuiteChildren, c as hasTests, h as hasFailed } from './utils-9dcc4050.js';
|
|
6
9
|
import fs from 'fs';
|
|
10
|
+
import { d as c$1, l as generateDiff } from './error-5a04e54b.js';
|
|
7
11
|
import { performance } from 'perf_hooks';
|
|
8
12
|
import { j as setHooks, c as createSuiteHooks, h as clearContext, d as defaultSuite, k as context, l as getHooks, m as getFn } from './suite-819c135e.js';
|
|
9
13
|
import { n as nanoid } from './index-6427e0f2.js';
|
|
14
|
+
import 'tty';
|
|
15
|
+
import 'source-map';
|
|
10
16
|
|
|
11
17
|
var node = {
|
|
12
18
|
name: "node",
|
|
@@ -235,7 +241,7 @@ const KEYS = LIVING_KEYS.concat(OTHER_KEYS);
|
|
|
235
241
|
var jsdom = {
|
|
236
242
|
name: "jsdom",
|
|
237
243
|
async setup(global) {
|
|
238
|
-
const { JSDOM } = await
|
|
244
|
+
const { JSDOM } = await importModule("jsdom");
|
|
239
245
|
const dom = new JSDOM("<!DOCTYPE html>", {
|
|
240
246
|
pretendToBeVisual: true,
|
|
241
247
|
runScripts: "dangerously",
|
|
@@ -255,7 +261,7 @@ var jsdom = {
|
|
|
255
261
|
var happy = {
|
|
256
262
|
name: "happy-dom",
|
|
257
263
|
async setup(global) {
|
|
258
|
-
const { Window } = await
|
|
264
|
+
const { Window } = await importModule("happy-dom");
|
|
259
265
|
const win = new Window();
|
|
260
266
|
const keys = KEYS.concat(Object.getOwnPropertyNames(win)).filter((k) => !k.startsWith("_")).filter((k) => !(k in global));
|
|
261
267
|
for (const key of keys)
|
|
@@ -701,12 +707,12 @@ function printObjectProperties(val, config, indentation, depth, refs, printer) {
|
|
|
701
707
|
return result;
|
|
702
708
|
}
|
|
703
709
|
|
|
704
|
-
var AsymmetricMatcher$
|
|
710
|
+
var AsymmetricMatcher$2 = {};
|
|
705
711
|
|
|
706
|
-
Object.defineProperty(AsymmetricMatcher$
|
|
712
|
+
Object.defineProperty(AsymmetricMatcher$2, '__esModule', {
|
|
707
713
|
value: true
|
|
708
714
|
});
|
|
709
|
-
AsymmetricMatcher$
|
|
715
|
+
AsymmetricMatcher$2.default = AsymmetricMatcher$2.test = AsymmetricMatcher$2.serialize = void 0;
|
|
710
716
|
|
|
711
717
|
var _collections$3 = collections;
|
|
712
718
|
|
|
@@ -807,17 +813,17 @@ const serialize$7 = (val, config, indentation, depth, refs, printer) => {
|
|
|
807
813
|
return val.toAsymmetricMatcher();
|
|
808
814
|
};
|
|
809
815
|
|
|
810
|
-
AsymmetricMatcher$
|
|
816
|
+
AsymmetricMatcher$2.serialize = serialize$7;
|
|
811
817
|
|
|
812
818
|
const test$6 = val => val && val.$$typeof === asymmetricMatcher;
|
|
813
819
|
|
|
814
|
-
AsymmetricMatcher$
|
|
820
|
+
AsymmetricMatcher$2.test = test$6;
|
|
815
821
|
const plugin$6 = {
|
|
816
822
|
serialize: serialize$7,
|
|
817
823
|
test: test$6
|
|
818
824
|
};
|
|
819
825
|
var _default$7 = plugin$6;
|
|
820
|
-
AsymmetricMatcher$
|
|
826
|
+
AsymmetricMatcher$2.default = _default$7;
|
|
821
827
|
|
|
822
828
|
var ConvertAnsi = {};
|
|
823
829
|
|
|
@@ -925,12 +931,12 @@ const plugin$5 = {
|
|
|
925
931
|
var _default$6 = plugin$5;
|
|
926
932
|
ConvertAnsi.default = _default$6;
|
|
927
933
|
|
|
928
|
-
var DOMCollection$
|
|
934
|
+
var DOMCollection$2 = {};
|
|
929
935
|
|
|
930
|
-
Object.defineProperty(DOMCollection$
|
|
936
|
+
Object.defineProperty(DOMCollection$2, '__esModule', {
|
|
931
937
|
value: true
|
|
932
938
|
});
|
|
933
|
-
DOMCollection$
|
|
939
|
+
DOMCollection$2.default = DOMCollection$2.serialize = DOMCollection$2.test = void 0;
|
|
934
940
|
|
|
935
941
|
var _collections$2 = collections;
|
|
936
942
|
|
|
@@ -955,7 +961,7 @@ const test$4 = val =>
|
|
|
955
961
|
!!val.constructor.name &&
|
|
956
962
|
testName(val.constructor.name);
|
|
957
963
|
|
|
958
|
-
DOMCollection$
|
|
964
|
+
DOMCollection$2.test = test$4;
|
|
959
965
|
|
|
960
966
|
const isNamedNodeMap = collection =>
|
|
961
967
|
collection.constructor.name === 'NamedNodeMap';
|
|
@@ -998,15 +1004,15 @@ const serialize$5 = (collection, config, indentation, depth, refs, printer) => {
|
|
|
998
1004
|
);
|
|
999
1005
|
};
|
|
1000
1006
|
|
|
1001
|
-
DOMCollection$
|
|
1007
|
+
DOMCollection$2.serialize = serialize$5;
|
|
1002
1008
|
const plugin$4 = {
|
|
1003
1009
|
serialize: serialize$5,
|
|
1004
1010
|
test: test$4
|
|
1005
1011
|
};
|
|
1006
1012
|
var _default$5 = plugin$4;
|
|
1007
|
-
DOMCollection$
|
|
1013
|
+
DOMCollection$2.default = _default$5;
|
|
1008
1014
|
|
|
1009
|
-
var DOMElement$
|
|
1015
|
+
var DOMElement$2 = {};
|
|
1010
1016
|
|
|
1011
1017
|
var markup = {};
|
|
1012
1018
|
|
|
@@ -1179,10 +1185,10 @@ const printElementAsLeaf = (type, config) => {
|
|
|
1179
1185
|
|
|
1180
1186
|
markup.printElementAsLeaf = printElementAsLeaf;
|
|
1181
1187
|
|
|
1182
|
-
Object.defineProperty(DOMElement$
|
|
1188
|
+
Object.defineProperty(DOMElement$2, '__esModule', {
|
|
1183
1189
|
value: true
|
|
1184
1190
|
});
|
|
1185
|
-
DOMElement$
|
|
1191
|
+
DOMElement$2.default = DOMElement$2.serialize = DOMElement$2.test = void 0;
|
|
1186
1192
|
|
|
1187
1193
|
var _markup$2 = markup;
|
|
1188
1194
|
|
|
@@ -1234,7 +1240,7 @@ const test$3 = val => {
|
|
|
1234
1240
|
);
|
|
1235
1241
|
};
|
|
1236
1242
|
|
|
1237
|
-
DOMElement$
|
|
1243
|
+
DOMElement$2.test = test$3;
|
|
1238
1244
|
|
|
1239
1245
|
function nodeIsText(node) {
|
|
1240
1246
|
return node.nodeType === TEXT_NODE;
|
|
@@ -1298,20 +1304,20 @@ const serialize$4 = (node, config, indentation, depth, refs, printer) => {
|
|
|
1298
1304
|
);
|
|
1299
1305
|
};
|
|
1300
1306
|
|
|
1301
|
-
DOMElement$
|
|
1307
|
+
DOMElement$2.serialize = serialize$4;
|
|
1302
1308
|
const plugin$3 = {
|
|
1303
1309
|
serialize: serialize$4,
|
|
1304
1310
|
test: test$3
|
|
1305
1311
|
};
|
|
1306
1312
|
var _default$4 = plugin$3;
|
|
1307
|
-
DOMElement$
|
|
1313
|
+
DOMElement$2.default = _default$4;
|
|
1308
1314
|
|
|
1309
|
-
var Immutable$
|
|
1315
|
+
var Immutable$2 = {};
|
|
1310
1316
|
|
|
1311
|
-
Object.defineProperty(Immutable$
|
|
1317
|
+
Object.defineProperty(Immutable$2, '__esModule', {
|
|
1312
1318
|
value: true
|
|
1313
1319
|
});
|
|
1314
|
-
Immutable$
|
|
1320
|
+
Immutable$2.default = Immutable$2.test = Immutable$2.serialize = void 0;
|
|
1315
1321
|
|
|
1316
1322
|
var _collections$1 = collections;
|
|
1317
1323
|
|
|
@@ -1324,13 +1330,13 @@ var _collections$1 = collections;
|
|
|
1324
1330
|
// SENTINEL constants are from https://github.com/facebook/immutable-js
|
|
1325
1331
|
const IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
|
|
1326
1332
|
const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
|
|
1327
|
-
const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
|
|
1333
|
+
const IS_KEYED_SENTINEL$1 = '@@__IMMUTABLE_KEYED__@@';
|
|
1328
1334
|
const IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
|
|
1329
|
-
const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
|
|
1335
|
+
const IS_ORDERED_SENTINEL$1 = '@@__IMMUTABLE_ORDERED__@@';
|
|
1330
1336
|
const IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4
|
|
1331
1337
|
|
|
1332
1338
|
const IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
|
|
1333
|
-
const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
|
|
1339
|
+
const IS_SET_SENTINEL$1 = '@@__IMMUTABLE_SET__@@';
|
|
1334
1340
|
const IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
|
|
1335
1341
|
|
|
1336
1342
|
const getImmutableName = name => 'Immutable.' + name;
|
|
@@ -1419,7 +1425,7 @@ const printImmutableSeq = (val, config, indentation, depth, refs, printer) => {
|
|
|
1419
1425
|
return printAsLeaf(name);
|
|
1420
1426
|
}
|
|
1421
1427
|
|
|
1422
|
-
if (val[IS_KEYED_SENTINEL]) {
|
|
1428
|
+
if (val[IS_KEYED_SENTINEL$1]) {
|
|
1423
1429
|
return (
|
|
1424
1430
|
name +
|
|
1425
1431
|
SPACE +
|
|
@@ -1492,7 +1498,7 @@ const serialize$3 = (val, config, indentation, depth, refs, printer) => {
|
|
|
1492
1498
|
depth,
|
|
1493
1499
|
refs,
|
|
1494
1500
|
printer,
|
|
1495
|
-
val[IS_ORDERED_SENTINEL] ? 'OrderedMap' : 'Map'
|
|
1501
|
+
val[IS_ORDERED_SENTINEL$1] ? 'OrderedMap' : 'Map'
|
|
1496
1502
|
);
|
|
1497
1503
|
}
|
|
1498
1504
|
|
|
@@ -1508,7 +1514,7 @@ const serialize$3 = (val, config, indentation, depth, refs, printer) => {
|
|
|
1508
1514
|
);
|
|
1509
1515
|
}
|
|
1510
1516
|
|
|
1511
|
-
if (val[IS_SET_SENTINEL]) {
|
|
1517
|
+
if (val[IS_SET_SENTINEL$1]) {
|
|
1512
1518
|
return printImmutableValues(
|
|
1513
1519
|
val,
|
|
1514
1520
|
config,
|
|
@@ -1516,7 +1522,7 @@ const serialize$3 = (val, config, indentation, depth, refs, printer) => {
|
|
|
1516
1522
|
depth,
|
|
1517
1523
|
refs,
|
|
1518
1524
|
printer,
|
|
1519
|
-
val[IS_ORDERED_SENTINEL] ? 'OrderedSet' : 'Set'
|
|
1525
|
+
val[IS_ORDERED_SENTINEL$1] ? 'OrderedSet' : 'Set'
|
|
1520
1526
|
);
|
|
1521
1527
|
}
|
|
1522
1528
|
|
|
@@ -1540,21 +1546,21 @@ const serialize$3 = (val, config, indentation, depth, refs, printer) => {
|
|
|
1540
1546
|
}; // Explicitly comparing sentinel properties to true avoids false positive
|
|
1541
1547
|
// when mock identity-obj-proxy returns the key as the value for any key.
|
|
1542
1548
|
|
|
1543
|
-
Immutable$
|
|
1549
|
+
Immutable$2.serialize = serialize$3;
|
|
1544
1550
|
|
|
1545
1551
|
const test$2 = val =>
|
|
1546
1552
|
val &&
|
|
1547
1553
|
(val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
|
|
1548
1554
|
|
|
1549
|
-
Immutable$
|
|
1555
|
+
Immutable$2.test = test$2;
|
|
1550
1556
|
const plugin$2 = {
|
|
1551
1557
|
serialize: serialize$3,
|
|
1552
1558
|
test: test$2
|
|
1553
1559
|
};
|
|
1554
1560
|
var _default$3 = plugin$2;
|
|
1555
|
-
Immutable$
|
|
1561
|
+
Immutable$2.default = _default$3;
|
|
1556
1562
|
|
|
1557
|
-
var ReactElement$
|
|
1563
|
+
var ReactElement$2 = {};
|
|
1558
1564
|
|
|
1559
1565
|
var reactIs = {exports: {}};
|
|
1560
1566
|
|
|
@@ -1804,10 +1810,10 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
1804
1810
|
reactIs.exports = reactIs_development;
|
|
1805
1811
|
}
|
|
1806
1812
|
|
|
1807
|
-
Object.defineProperty(ReactElement$
|
|
1813
|
+
Object.defineProperty(ReactElement$2, '__esModule', {
|
|
1808
1814
|
value: true
|
|
1809
1815
|
});
|
|
1810
|
-
ReactElement$
|
|
1816
|
+
ReactElement$2.default = ReactElement$2.test = ReactElement$2.serialize = void 0;
|
|
1811
1817
|
|
|
1812
1818
|
var ReactIs = _interopRequireWildcard(reactIs.exports);
|
|
1813
1819
|
|
|
@@ -1957,24 +1963,24 @@ const serialize$2 = (element, config, indentation, depth, refs, printer) =>
|
|
|
1957
1963
|
indentation
|
|
1958
1964
|
);
|
|
1959
1965
|
|
|
1960
|
-
ReactElement$
|
|
1966
|
+
ReactElement$2.serialize = serialize$2;
|
|
1961
1967
|
|
|
1962
1968
|
const test$1 = val => val != null && ReactIs.isElement(val);
|
|
1963
1969
|
|
|
1964
|
-
ReactElement$
|
|
1970
|
+
ReactElement$2.test = test$1;
|
|
1965
1971
|
const plugin$1 = {
|
|
1966
1972
|
serialize: serialize$2,
|
|
1967
1973
|
test: test$1
|
|
1968
1974
|
};
|
|
1969
1975
|
var _default$2 = plugin$1;
|
|
1970
|
-
ReactElement$
|
|
1976
|
+
ReactElement$2.default = _default$2;
|
|
1971
1977
|
|
|
1972
|
-
var ReactTestComponent$
|
|
1978
|
+
var ReactTestComponent$2 = {};
|
|
1973
1979
|
|
|
1974
|
-
Object.defineProperty(ReactTestComponent$
|
|
1980
|
+
Object.defineProperty(ReactTestComponent$2, '__esModule', {
|
|
1975
1981
|
value: true
|
|
1976
1982
|
});
|
|
1977
|
-
ReactTestComponent$
|
|
1983
|
+
ReactTestComponent$2.default = ReactTestComponent$2.test = ReactTestComponent$2.serialize = void 0;
|
|
1978
1984
|
|
|
1979
1985
|
var _markup = markup;
|
|
1980
1986
|
|
|
@@ -2037,17 +2043,17 @@ const serialize$1 = (object, config, indentation, depth, refs, printer) =>
|
|
|
2037
2043
|
indentation
|
|
2038
2044
|
);
|
|
2039
2045
|
|
|
2040
|
-
ReactTestComponent$
|
|
2046
|
+
ReactTestComponent$2.serialize = serialize$1;
|
|
2041
2047
|
|
|
2042
2048
|
const test = val => val && val.$$typeof === testSymbol;
|
|
2043
2049
|
|
|
2044
|
-
ReactTestComponent$
|
|
2050
|
+
ReactTestComponent$2.test = test;
|
|
2045
2051
|
const plugin = {
|
|
2046
2052
|
serialize: serialize$1,
|
|
2047
2053
|
test
|
|
2048
2054
|
};
|
|
2049
2055
|
var _default$1 = plugin;
|
|
2050
|
-
ReactTestComponent$
|
|
2056
|
+
ReactTestComponent$2.default = _default$1;
|
|
2051
2057
|
|
|
2052
2058
|
Object.defineProperty(build, '__esModule', {
|
|
2053
2059
|
value: true
|
|
@@ -2060,21 +2066,21 @@ var _ansiStyles = _interopRequireDefault(ansiStyles.exports);
|
|
|
2060
2066
|
var _collections = collections;
|
|
2061
2067
|
|
|
2062
2068
|
var _AsymmetricMatcher = _interopRequireDefault(
|
|
2063
|
-
AsymmetricMatcher$
|
|
2069
|
+
AsymmetricMatcher$2
|
|
2064
2070
|
);
|
|
2065
2071
|
|
|
2066
2072
|
var _ConvertAnsi = _interopRequireDefault(ConvertAnsi);
|
|
2067
2073
|
|
|
2068
|
-
var _DOMCollection = _interopRequireDefault(DOMCollection$
|
|
2074
|
+
var _DOMCollection = _interopRequireDefault(DOMCollection$2);
|
|
2069
2075
|
|
|
2070
|
-
var _DOMElement = _interopRequireDefault(DOMElement$
|
|
2076
|
+
var _DOMElement = _interopRequireDefault(DOMElement$2);
|
|
2071
2077
|
|
|
2072
|
-
var _Immutable = _interopRequireDefault(Immutable$
|
|
2078
|
+
var _Immutable = _interopRequireDefault(Immutable$2);
|
|
2073
2079
|
|
|
2074
|
-
var _ReactElement = _interopRequireDefault(ReactElement$
|
|
2080
|
+
var _ReactElement = _interopRequireDefault(ReactElement$2);
|
|
2075
2081
|
|
|
2076
2082
|
var _ReactTestComponent = _interopRequireDefault(
|
|
2077
|
-
ReactTestComponent$
|
|
2083
|
+
ReactTestComponent$2
|
|
2078
2084
|
);
|
|
2079
2085
|
|
|
2080
2086
|
function _interopRequireDefault(obj) {
|
|
@@ -2089,7 +2095,7 @@ function _interopRequireDefault(obj) {
|
|
|
2089
2095
|
*/
|
|
2090
2096
|
|
|
2091
2097
|
/* eslint-disable local/ban-types-eventually */
|
|
2092
|
-
const toString = Object.prototype.toString;
|
|
2098
|
+
const toString$1 = Object.prototype.toString;
|
|
2093
2099
|
const toISOString = Date.prototype.toISOString;
|
|
2094
2100
|
const errorToString = Error.prototype.toString;
|
|
2095
2101
|
const regExpToString = RegExp.prototype.toString;
|
|
@@ -2201,7 +2207,7 @@ function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
|
|
|
2201
2207
|
return printSymbol(val);
|
|
2202
2208
|
}
|
|
2203
2209
|
|
|
2204
|
-
const toStringed = toString.call(val);
|
|
2210
|
+
const toStringed = toString$1.call(val);
|
|
2205
2211
|
|
|
2206
2212
|
if (toStringed === '[object WeakMap]') {
|
|
2207
2213
|
return 'WeakMap {}';
|
|
@@ -2277,7 +2283,7 @@ function printComplexValue(
|
|
|
2277
2283
|
return printer(val.toJSON(), config, indentation, depth, refs, true);
|
|
2278
2284
|
}
|
|
2279
2285
|
|
|
2280
|
-
const toStringed = toString.call(val);
|
|
2286
|
+
const toStringed = toString$1.call(val);
|
|
2281
2287
|
|
|
2282
2288
|
if (toStringed === '[object Arguments]') {
|
|
2283
2289
|
return hitMaxDepth
|
|
@@ -2645,36 +2651,36 @@ var _default = format;
|
|
|
2645
2651
|
build.default = _default;
|
|
2646
2652
|
|
|
2647
2653
|
const {
|
|
2648
|
-
DOMCollection,
|
|
2649
|
-
DOMElement,
|
|
2650
|
-
Immutable,
|
|
2651
|
-
ReactElement,
|
|
2652
|
-
ReactTestComponent,
|
|
2653
|
-
AsymmetricMatcher
|
|
2654
|
+
DOMCollection: DOMCollection$1,
|
|
2655
|
+
DOMElement: DOMElement$1,
|
|
2656
|
+
Immutable: Immutable$1,
|
|
2657
|
+
ReactElement: ReactElement$1,
|
|
2658
|
+
ReactTestComponent: ReactTestComponent$1,
|
|
2659
|
+
AsymmetricMatcher: AsymmetricMatcher$1
|
|
2654
2660
|
} = plugins_1;
|
|
2655
|
-
let PLUGINS = [
|
|
2656
|
-
ReactTestComponent,
|
|
2657
|
-
ReactElement,
|
|
2658
|
-
DOMElement,
|
|
2659
|
-
DOMCollection,
|
|
2660
|
-
Immutable,
|
|
2661
|
-
AsymmetricMatcher
|
|
2661
|
+
let PLUGINS$1 = [
|
|
2662
|
+
ReactTestComponent$1,
|
|
2663
|
+
ReactElement$1,
|
|
2664
|
+
DOMElement$1,
|
|
2665
|
+
DOMCollection$1,
|
|
2666
|
+
Immutable$1,
|
|
2667
|
+
AsymmetricMatcher$1
|
|
2662
2668
|
];
|
|
2663
|
-
const getSerializers = () => PLUGINS;
|
|
2664
|
-
|
|
2665
|
-
var __defProp = Object.defineProperty;
|
|
2666
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
2667
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
2668
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
2669
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2670
|
-
var __spreadValues = (a, b) => {
|
|
2669
|
+
const getSerializers = () => PLUGINS$1;
|
|
2670
|
+
|
|
2671
|
+
var __defProp$1 = Object.defineProperty;
|
|
2672
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
2673
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
2674
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
2675
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2676
|
+
var __spreadValues$1 = (a, b) => {
|
|
2671
2677
|
for (var prop in b || (b = {}))
|
|
2672
|
-
if (__hasOwnProp.call(b, prop))
|
|
2673
|
-
__defNormalProp(a, prop, b[prop]);
|
|
2674
|
-
if (__getOwnPropSymbols)
|
|
2675
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
2676
|
-
if (__propIsEnum.call(b, prop))
|
|
2677
|
-
__defNormalProp(a, prop, b[prop]);
|
|
2678
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
2679
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
2680
|
+
if (__getOwnPropSymbols$1)
|
|
2681
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
2682
|
+
if (__propIsEnum$1.call(b, prop))
|
|
2683
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
2678
2684
|
}
|
|
2679
2685
|
return a;
|
|
2680
2686
|
};
|
|
@@ -2710,7 +2716,7 @@ const removeExtraLineBreaks = (string) => string.length > 2 && string.startsWith
|
|
|
2710
2716
|
const escapeRegex = true;
|
|
2711
2717
|
const printFunctionName = false;
|
|
2712
2718
|
function serialize(val, indent = 2, formatOverrides = {}) {
|
|
2713
|
-
return normalizeNewlines(format_1(val, __spreadValues({
|
|
2719
|
+
return normalizeNewlines(format_1(val, __spreadValues$1({
|
|
2714
2720
|
escapeRegex,
|
|
2715
2721
|
indent,
|
|
2716
2722
|
plugins: getSerializers(),
|
|
@@ -2967,6 +2973,426 @@ function SnapshotPlugin() {
|
|
|
2967
2973
|
};
|
|
2968
2974
|
}
|
|
2969
2975
|
|
|
2976
|
+
const EXPECTED_COLOR = c$1.green;
|
|
2977
|
+
const RECEIVED_COLOR = c$1.red;
|
|
2978
|
+
const INVERTED_COLOR = c$1.inverse;
|
|
2979
|
+
const BOLD_WEIGHT = c$1.bold;
|
|
2980
|
+
const DIM_COLOR = c$1.dim;
|
|
2981
|
+
const {
|
|
2982
|
+
AsymmetricMatcher,
|
|
2983
|
+
DOMCollection,
|
|
2984
|
+
DOMElement,
|
|
2985
|
+
Immutable,
|
|
2986
|
+
ReactElement,
|
|
2987
|
+
ReactTestComponent
|
|
2988
|
+
} = plugins_1;
|
|
2989
|
+
const PLUGINS = [
|
|
2990
|
+
ReactTestComponent,
|
|
2991
|
+
ReactElement,
|
|
2992
|
+
DOMElement,
|
|
2993
|
+
DOMCollection,
|
|
2994
|
+
Immutable,
|
|
2995
|
+
AsymmetricMatcher
|
|
2996
|
+
];
|
|
2997
|
+
function matcherHint(matcherName, received = "received", expected = "expected", options = {}) {
|
|
2998
|
+
const {
|
|
2999
|
+
comment = "",
|
|
3000
|
+
expectedColor = EXPECTED_COLOR,
|
|
3001
|
+
isDirectExpectCall = false,
|
|
3002
|
+
isNot = false,
|
|
3003
|
+
promise = "",
|
|
3004
|
+
receivedColor = RECEIVED_COLOR,
|
|
3005
|
+
secondArgument = "",
|
|
3006
|
+
secondArgumentColor = EXPECTED_COLOR
|
|
3007
|
+
} = options;
|
|
3008
|
+
let hint = "";
|
|
3009
|
+
let dimString = "expect";
|
|
3010
|
+
if (!isDirectExpectCall && received !== "") {
|
|
3011
|
+
hint += DIM_COLOR(`${dimString}(`) + receivedColor(received);
|
|
3012
|
+
dimString = ")";
|
|
3013
|
+
}
|
|
3014
|
+
if (promise !== "") {
|
|
3015
|
+
hint += DIM_COLOR(`${dimString}.`) + promise;
|
|
3016
|
+
dimString = "";
|
|
3017
|
+
}
|
|
3018
|
+
if (isNot) {
|
|
3019
|
+
hint += `${DIM_COLOR(`${dimString}.`)}not`;
|
|
3020
|
+
dimString = "";
|
|
3021
|
+
}
|
|
3022
|
+
if (matcherName.includes(".")) {
|
|
3023
|
+
dimString += matcherName;
|
|
3024
|
+
} else {
|
|
3025
|
+
hint += DIM_COLOR(`${dimString}.`) + matcherName;
|
|
3026
|
+
dimString = "";
|
|
3027
|
+
}
|
|
3028
|
+
if (expected === "") {
|
|
3029
|
+
dimString += "()";
|
|
3030
|
+
} else {
|
|
3031
|
+
hint += DIM_COLOR(`${dimString}(`) + expectedColor(expected);
|
|
3032
|
+
if (secondArgument)
|
|
3033
|
+
hint += DIM_COLOR(", ") + secondArgumentColor(secondArgument);
|
|
3034
|
+
dimString = ")";
|
|
3035
|
+
}
|
|
3036
|
+
if (comment !== "")
|
|
3037
|
+
dimString += ` // ${comment}`;
|
|
3038
|
+
if (dimString !== "")
|
|
3039
|
+
hint += DIM_COLOR(dimString);
|
|
3040
|
+
return hint;
|
|
3041
|
+
}
|
|
3042
|
+
const SPACE_SYMBOL = "\xB7";
|
|
3043
|
+
const replaceTrailingSpaces = (text) => text.replace(/\s+$/gm, (spaces) => SPACE_SYMBOL.repeat(spaces.length));
|
|
3044
|
+
const stringify = (object, maxDepth = 10) => {
|
|
3045
|
+
const MAX_LENGTH = 1e4;
|
|
3046
|
+
let result;
|
|
3047
|
+
try {
|
|
3048
|
+
result = format_1(object, {
|
|
3049
|
+
maxDepth,
|
|
3050
|
+
min: true,
|
|
3051
|
+
plugins: PLUGINS
|
|
3052
|
+
});
|
|
3053
|
+
} catch {
|
|
3054
|
+
result = format_1(object, {
|
|
3055
|
+
callToJSON: false,
|
|
3056
|
+
maxDepth,
|
|
3057
|
+
min: true,
|
|
3058
|
+
plugins: PLUGINS
|
|
3059
|
+
});
|
|
3060
|
+
}
|
|
3061
|
+
return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(maxDepth / 2)) : result;
|
|
3062
|
+
};
|
|
3063
|
+
const printReceived = (object) => RECEIVED_COLOR(replaceTrailingSpaces(stringify(object)));
|
|
3064
|
+
const printExpected = (value) => EXPECTED_COLOR(replaceTrailingSpaces(stringify(value)));
|
|
3065
|
+
function diff(a, b, options) {
|
|
3066
|
+
return generateDiff(stringify(a), stringify(b));
|
|
3067
|
+
}
|
|
3068
|
+
|
|
3069
|
+
var matcherUtils = /*#__PURE__*/Object.freeze({
|
|
3070
|
+
__proto__: null,
|
|
3071
|
+
EXPECTED_COLOR: EXPECTED_COLOR,
|
|
3072
|
+
RECEIVED_COLOR: RECEIVED_COLOR,
|
|
3073
|
+
INVERTED_COLOR: INVERTED_COLOR,
|
|
3074
|
+
BOLD_WEIGHT: BOLD_WEIGHT,
|
|
3075
|
+
DIM_COLOR: DIM_COLOR,
|
|
3076
|
+
matcherHint: matcherHint,
|
|
3077
|
+
stringify: stringify,
|
|
3078
|
+
printReceived: printReceived,
|
|
3079
|
+
printExpected: printExpected,
|
|
3080
|
+
diff: diff
|
|
3081
|
+
});
|
|
3082
|
+
|
|
3083
|
+
// src/math.ts
|
|
3084
|
+
var isObject = (val) => toString.call(val) === "[object Object]";
|
|
3085
|
+
|
|
3086
|
+
function equals(a, b, customTesters, strictCheck) {
|
|
3087
|
+
customTesters = customTesters || [];
|
|
3088
|
+
return eq(a, b, [], [], customTesters, strictCheck ? hasKey : hasDefinedKey);
|
|
3089
|
+
}
|
|
3090
|
+
function isAsymmetric(obj) {
|
|
3091
|
+
return !!obj && isA("Function", obj.asymmetricMatch);
|
|
3092
|
+
}
|
|
3093
|
+
function asymmetricMatch(a, b) {
|
|
3094
|
+
var asymmetricA = isAsymmetric(a), asymmetricB = isAsymmetric(b);
|
|
3095
|
+
if (asymmetricA && asymmetricB) {
|
|
3096
|
+
return void 0;
|
|
3097
|
+
}
|
|
3098
|
+
if (asymmetricA) {
|
|
3099
|
+
return a.asymmetricMatch(b);
|
|
3100
|
+
}
|
|
3101
|
+
if (asymmetricB) {
|
|
3102
|
+
return b.asymmetricMatch(a);
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
function eq(a, b, aStack, bStack, customTesters, hasKey2) {
|
|
3106
|
+
var result = true;
|
|
3107
|
+
var asymmetricResult = asymmetricMatch(a, b);
|
|
3108
|
+
if (asymmetricResult !== void 0) {
|
|
3109
|
+
return asymmetricResult;
|
|
3110
|
+
}
|
|
3111
|
+
for (var i = 0; i < customTesters.length; i++) {
|
|
3112
|
+
var customTesterResult = customTesters[i](a, b);
|
|
3113
|
+
if (customTesterResult !== void 0) {
|
|
3114
|
+
return customTesterResult;
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3117
|
+
if (a instanceof Error && b instanceof Error) {
|
|
3118
|
+
return a.message == b.message;
|
|
3119
|
+
}
|
|
3120
|
+
if (Object.is(a, b)) {
|
|
3121
|
+
return true;
|
|
3122
|
+
}
|
|
3123
|
+
if (a === null || b === null) {
|
|
3124
|
+
return a === b;
|
|
3125
|
+
}
|
|
3126
|
+
var className = Object.prototype.toString.call(a);
|
|
3127
|
+
if (className != Object.prototype.toString.call(b)) {
|
|
3128
|
+
return false;
|
|
3129
|
+
}
|
|
3130
|
+
switch (className) {
|
|
3131
|
+
case "[object Boolean]":
|
|
3132
|
+
case "[object String]":
|
|
3133
|
+
case "[object Number]":
|
|
3134
|
+
if (typeof a !== typeof b) {
|
|
3135
|
+
return false;
|
|
3136
|
+
} else if (typeof a !== "object" && typeof b !== "object") {
|
|
3137
|
+
return Object.is(a, b);
|
|
3138
|
+
} else {
|
|
3139
|
+
return Object.is(a.valueOf(), b.valueOf());
|
|
3140
|
+
}
|
|
3141
|
+
case "[object Date]":
|
|
3142
|
+
return +a == +b;
|
|
3143
|
+
case "[object RegExp]":
|
|
3144
|
+
return a.source === b.source && a.flags === b.flags;
|
|
3145
|
+
}
|
|
3146
|
+
if (typeof a !== "object" || typeof b !== "object") {
|
|
3147
|
+
return false;
|
|
3148
|
+
}
|
|
3149
|
+
if (isDomNode(a) && isDomNode(b)) {
|
|
3150
|
+
return a.isEqualNode(b);
|
|
3151
|
+
}
|
|
3152
|
+
var length = aStack.length;
|
|
3153
|
+
while (length--) {
|
|
3154
|
+
if (aStack[length] === a) {
|
|
3155
|
+
return bStack[length] === b;
|
|
3156
|
+
} else if (bStack[length] === b) {
|
|
3157
|
+
return false;
|
|
3158
|
+
}
|
|
3159
|
+
}
|
|
3160
|
+
aStack.push(a);
|
|
3161
|
+
bStack.push(b);
|
|
3162
|
+
if (className == "[object Array]" && a.length !== b.length) {
|
|
3163
|
+
return false;
|
|
3164
|
+
}
|
|
3165
|
+
var aKeys = keys(a, hasKey2), key;
|
|
3166
|
+
var size = aKeys.length;
|
|
3167
|
+
if (keys(b, hasKey2).length !== size) {
|
|
3168
|
+
return false;
|
|
3169
|
+
}
|
|
3170
|
+
while (size--) {
|
|
3171
|
+
key = aKeys[size];
|
|
3172
|
+
result = hasKey2(b, key) && eq(a[key], b[key], aStack, bStack, customTesters, hasKey2);
|
|
3173
|
+
if (!result) {
|
|
3174
|
+
return false;
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3177
|
+
aStack.pop();
|
|
3178
|
+
bStack.pop();
|
|
3179
|
+
return result;
|
|
3180
|
+
}
|
|
3181
|
+
function keys(obj, hasKey2) {
|
|
3182
|
+
var keys2 = [];
|
|
3183
|
+
for (var key in obj) {
|
|
3184
|
+
if (hasKey2(obj, key)) {
|
|
3185
|
+
keys2.push(key);
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
return keys2.concat(Object.getOwnPropertySymbols(obj).filter((symbol) => Object.getOwnPropertyDescriptor(obj, symbol).enumerable));
|
|
3189
|
+
}
|
|
3190
|
+
function hasDefinedKey(obj, key) {
|
|
3191
|
+
return hasKey(obj, key) && obj[key] !== void 0;
|
|
3192
|
+
}
|
|
3193
|
+
function hasKey(obj, key) {
|
|
3194
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
3195
|
+
}
|
|
3196
|
+
function isA(typeName, value) {
|
|
3197
|
+
return Object.prototype.toString.apply(value) === "[object " + typeName + "]";
|
|
3198
|
+
}
|
|
3199
|
+
function isDomNode(obj) {
|
|
3200
|
+
return obj !== null && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string" && typeof obj.isEqualNode === "function";
|
|
3201
|
+
}
|
|
3202
|
+
const IS_KEYED_SENTINEL = "@@__IMMUTABLE_KEYED__@@";
|
|
3203
|
+
const IS_SET_SENTINEL = "@@__IMMUTABLE_SET__@@";
|
|
3204
|
+
const IS_ORDERED_SENTINEL = "@@__IMMUTABLE_ORDERED__@@";
|
|
3205
|
+
function isImmutableUnorderedKeyed(maybeKeyed) {
|
|
3206
|
+
return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL] && !maybeKeyed[IS_ORDERED_SENTINEL]);
|
|
3207
|
+
}
|
|
3208
|
+
function isImmutableUnorderedSet(maybeSet) {
|
|
3209
|
+
return !!(maybeSet && maybeSet[IS_SET_SENTINEL] && !maybeSet[IS_ORDERED_SENTINEL]);
|
|
3210
|
+
}
|
|
3211
|
+
const IteratorSymbol = Symbol.iterator;
|
|
3212
|
+
const hasIterator = (object) => !!(object != null && object[IteratorSymbol]);
|
|
3213
|
+
const iterableEquality = (a, b, aStack = [], bStack = []) => {
|
|
3214
|
+
if (typeof a !== "object" || typeof b !== "object" || Array.isArray(a) || Array.isArray(b) || !hasIterator(a) || !hasIterator(b)) {
|
|
3215
|
+
return void 0;
|
|
3216
|
+
}
|
|
3217
|
+
if (a.constructor !== b.constructor) {
|
|
3218
|
+
return false;
|
|
3219
|
+
}
|
|
3220
|
+
let length = aStack.length;
|
|
3221
|
+
while (length--) {
|
|
3222
|
+
if (aStack[length] === a) {
|
|
3223
|
+
return bStack[length] === b;
|
|
3224
|
+
}
|
|
3225
|
+
}
|
|
3226
|
+
aStack.push(a);
|
|
3227
|
+
bStack.push(b);
|
|
3228
|
+
const iterableEqualityWithStack = (a2, b2) => iterableEquality(a2, b2, [...aStack], [...bStack]);
|
|
3229
|
+
if (a.size !== void 0) {
|
|
3230
|
+
if (a.size !== b.size) {
|
|
3231
|
+
return false;
|
|
3232
|
+
} else if (isA("Set", a) || isImmutableUnorderedSet(a)) {
|
|
3233
|
+
let allFound = true;
|
|
3234
|
+
for (const aValue of a) {
|
|
3235
|
+
if (!b.has(aValue)) {
|
|
3236
|
+
let has = false;
|
|
3237
|
+
for (const bValue of b) {
|
|
3238
|
+
const isEqual = equals(aValue, bValue, [iterableEqualityWithStack]);
|
|
3239
|
+
if (isEqual === true) {
|
|
3240
|
+
has = true;
|
|
3241
|
+
}
|
|
3242
|
+
}
|
|
3243
|
+
if (has === false) {
|
|
3244
|
+
allFound = false;
|
|
3245
|
+
break;
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
aStack.pop();
|
|
3250
|
+
bStack.pop();
|
|
3251
|
+
return allFound;
|
|
3252
|
+
} else if (isA("Map", a) || isImmutableUnorderedKeyed(a)) {
|
|
3253
|
+
let allFound = true;
|
|
3254
|
+
for (const aEntry of a) {
|
|
3255
|
+
if (!b.has(aEntry[0]) || !equals(aEntry[1], b.get(aEntry[0]), [iterableEqualityWithStack])) {
|
|
3256
|
+
let has = false;
|
|
3257
|
+
for (const bEntry of b) {
|
|
3258
|
+
const matchedKey = equals(aEntry[0], bEntry[0], [
|
|
3259
|
+
iterableEqualityWithStack
|
|
3260
|
+
]);
|
|
3261
|
+
let matchedValue = false;
|
|
3262
|
+
if (matchedKey === true) {
|
|
3263
|
+
matchedValue = equals(aEntry[1], bEntry[1], [
|
|
3264
|
+
iterableEqualityWithStack
|
|
3265
|
+
]);
|
|
3266
|
+
}
|
|
3267
|
+
if (matchedValue === true) {
|
|
3268
|
+
has = true;
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
if (has === false) {
|
|
3272
|
+
allFound = false;
|
|
3273
|
+
break;
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
aStack.pop();
|
|
3278
|
+
bStack.pop();
|
|
3279
|
+
return allFound;
|
|
3280
|
+
}
|
|
3281
|
+
}
|
|
3282
|
+
const bIterator = b[IteratorSymbol]();
|
|
3283
|
+
for (const aValue of a) {
|
|
3284
|
+
const nextB = bIterator.next();
|
|
3285
|
+
if (nextB.done || !equals(aValue, nextB.value, [iterableEqualityWithStack])) {
|
|
3286
|
+
return false;
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
if (!bIterator.next().done) {
|
|
3290
|
+
return false;
|
|
3291
|
+
}
|
|
3292
|
+
aStack.pop();
|
|
3293
|
+
bStack.pop();
|
|
3294
|
+
return true;
|
|
3295
|
+
};
|
|
3296
|
+
const hasPropertyInObject = (object, key) => {
|
|
3297
|
+
const shouldTerminate = !object || typeof object !== "object" || object === Object.prototype;
|
|
3298
|
+
if (shouldTerminate) {
|
|
3299
|
+
return false;
|
|
3300
|
+
}
|
|
3301
|
+
return Object.prototype.hasOwnProperty.call(object, key) || hasPropertyInObject(Object.getPrototypeOf(object), key);
|
|
3302
|
+
};
|
|
3303
|
+
const isObjectWithKeys = (a) => isObject(a) && !(a instanceof Error) && !(a instanceof Array) && !(a instanceof Date);
|
|
3304
|
+
const subsetEquality = (object, subset) => {
|
|
3305
|
+
const subsetEqualityWithContext = (seenReferences = new WeakMap()) => (object2, subset2) => {
|
|
3306
|
+
if (!isObjectWithKeys(subset2)) {
|
|
3307
|
+
return void 0;
|
|
3308
|
+
}
|
|
3309
|
+
return Object.keys(subset2).every((key) => {
|
|
3310
|
+
if (isObjectWithKeys(subset2[key])) {
|
|
3311
|
+
if (seenReferences.has(subset2[key])) {
|
|
3312
|
+
return equals(object2[key], subset2[key], [iterableEquality]);
|
|
3313
|
+
}
|
|
3314
|
+
seenReferences.set(subset2[key], true);
|
|
3315
|
+
}
|
|
3316
|
+
const result = object2 != null && hasPropertyInObject(object2, key) && equals(object2[key], subset2[key], [
|
|
3317
|
+
iterableEquality,
|
|
3318
|
+
subsetEqualityWithContext(seenReferences)
|
|
3319
|
+
]);
|
|
3320
|
+
seenReferences.delete(subset2[key]);
|
|
3321
|
+
return result;
|
|
3322
|
+
});
|
|
3323
|
+
};
|
|
3324
|
+
return subsetEqualityWithContext()(object, subset);
|
|
3325
|
+
};
|
|
3326
|
+
|
|
3327
|
+
var __defProp = Object.defineProperty;
|
|
3328
|
+
var __defProps = Object.defineProperties;
|
|
3329
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
3330
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3331
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3332
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
3333
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3334
|
+
var __spreadValues = (a, b) => {
|
|
3335
|
+
for (var prop in b || (b = {}))
|
|
3336
|
+
if (__hasOwnProp.call(b, prop))
|
|
3337
|
+
__defNormalProp(a, prop, b[prop]);
|
|
3338
|
+
if (__getOwnPropSymbols)
|
|
3339
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
3340
|
+
if (__propIsEnum.call(b, prop))
|
|
3341
|
+
__defNormalProp(a, prop, b[prop]);
|
|
3342
|
+
}
|
|
3343
|
+
return a;
|
|
3344
|
+
};
|
|
3345
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
3346
|
+
const isAsyncFunction = (fn) => typeof fn === "function" && fn[Symbol.toStringTag] === "AsyncFunction";
|
|
3347
|
+
const getMatcherState = (assertion) => {
|
|
3348
|
+
const actual = assertion._obj;
|
|
3349
|
+
const isNot = util.flag(assertion, "negate");
|
|
3350
|
+
const jestUtils = __spreadProps(__spreadValues({}, matcherUtils), {
|
|
3351
|
+
iterableEquality,
|
|
3352
|
+
subsetEquality
|
|
3353
|
+
});
|
|
3354
|
+
const matcherState = {
|
|
3355
|
+
isNot,
|
|
3356
|
+
utils: jestUtils,
|
|
3357
|
+
assertionCalls: 0,
|
|
3358
|
+
promise: "",
|
|
3359
|
+
equals,
|
|
3360
|
+
suppressedErrors: []
|
|
3361
|
+
};
|
|
3362
|
+
return {
|
|
3363
|
+
state: matcherState,
|
|
3364
|
+
isNot,
|
|
3365
|
+
actual
|
|
3366
|
+
};
|
|
3367
|
+
};
|
|
3368
|
+
function JestExtendPlugin(expects) {
|
|
3369
|
+
return (c, utils) => {
|
|
3370
|
+
Object.entries(expects).forEach(([expectAssertionName, expectAssertion]) => {
|
|
3371
|
+
function expectSyncWrapper(...args) {
|
|
3372
|
+
const { state, isNot, actual } = getMatcherState(this);
|
|
3373
|
+
const { pass, message } = expectAssertion.call(state, actual, ...args);
|
|
3374
|
+
if (pass && isNot || !pass && !isNot)
|
|
3375
|
+
c.expect.fail(message());
|
|
3376
|
+
}
|
|
3377
|
+
async function expectAsyncWrapper(...args) {
|
|
3378
|
+
const { state, isNot, actual } = getMatcherState(this);
|
|
3379
|
+
const { pass, message } = await expectAssertion.call(state, actual, ...args);
|
|
3380
|
+
if (pass && isNot || !pass && !isNot)
|
|
3381
|
+
c.expect.fail(message());
|
|
3382
|
+
}
|
|
3383
|
+
const expectAssertionWrapper = isAsyncFunction(expectAssertion) ? expectAsyncWrapper : expectSyncWrapper;
|
|
3384
|
+
utils.addMethod(chai.Assertion.prototype, expectAssertionName, expectAssertionWrapper);
|
|
3385
|
+
});
|
|
3386
|
+
};
|
|
3387
|
+
}
|
|
3388
|
+
function JestExtend() {
|
|
3389
|
+
return (chai2, utils) => {
|
|
3390
|
+
utils.addMethod(chai2.expect, "extend", (expects) => {
|
|
3391
|
+
chai2.use(JestExtendPlugin(expects));
|
|
3392
|
+
});
|
|
3393
|
+
};
|
|
3394
|
+
}
|
|
3395
|
+
|
|
2970
3396
|
function JestChaiExpect() {
|
|
2971
3397
|
return (chai, utils) => {
|
|
2972
3398
|
function def(name, fn) {
|
|
@@ -3049,6 +3475,9 @@ function JestChaiExpect() {
|
|
|
3049
3475
|
def("toHaveLength", function(length) {
|
|
3050
3476
|
return this.have.length(length);
|
|
3051
3477
|
});
|
|
3478
|
+
def("toHaveProperty", function(...args) {
|
|
3479
|
+
return this.have.deep.nested.property(...args);
|
|
3480
|
+
});
|
|
3052
3481
|
def("toBeCloseTo", function(number, numDigits = 2) {
|
|
3053
3482
|
utils.expectTypes(this, ["number"]);
|
|
3054
3483
|
return this.closeTo(number, numDigits);
|
|
@@ -3150,17 +3579,54 @@ async function setupChai() {
|
|
|
3150
3579
|
if (installed)
|
|
3151
3580
|
return;
|
|
3152
3581
|
chai.use(SinonChai);
|
|
3582
|
+
chai.use(JestExtend());
|
|
3153
3583
|
chai.use(JestChaiExpect());
|
|
3154
3584
|
chai.use(Subset);
|
|
3155
3585
|
chai.use(SnapshotPlugin());
|
|
3156
3586
|
installed = true;
|
|
3157
3587
|
}
|
|
3158
3588
|
|
|
3589
|
+
let globalSetup = false;
|
|
3159
3590
|
async function setupGlobalEnv(config) {
|
|
3591
|
+
if (globalSetup)
|
|
3592
|
+
return;
|
|
3593
|
+
globalSetup = true;
|
|
3594
|
+
setupConsoleLogSpy();
|
|
3160
3595
|
await setupChai();
|
|
3161
3596
|
if (config.global)
|
|
3162
3597
|
(await import('./global-e40b54d6.js')).registerApiGlobally();
|
|
3163
3598
|
}
|
|
3599
|
+
function setupConsoleLogSpy() {
|
|
3600
|
+
const stdout = new Writable({
|
|
3601
|
+
write(data, encoding, callback) {
|
|
3602
|
+
var _a;
|
|
3603
|
+
send("log", {
|
|
3604
|
+
type: "stdout",
|
|
3605
|
+
content: String(data),
|
|
3606
|
+
taskId: (_a = process.__vitest_worker__.current) == null ? void 0 : _a.id
|
|
3607
|
+
});
|
|
3608
|
+
callback();
|
|
3609
|
+
}
|
|
3610
|
+
});
|
|
3611
|
+
const stderr = new Writable({
|
|
3612
|
+
write(data, encoding, callback) {
|
|
3613
|
+
var _a;
|
|
3614
|
+
send("log", {
|
|
3615
|
+
type: "stderr",
|
|
3616
|
+
content: String(data),
|
|
3617
|
+
taskId: (_a = process.__vitest_worker__.current) == null ? void 0 : _a.id
|
|
3618
|
+
});
|
|
3619
|
+
callback();
|
|
3620
|
+
}
|
|
3621
|
+
});
|
|
3622
|
+
const newConsole = new Console({
|
|
3623
|
+
stdout,
|
|
3624
|
+
stderr,
|
|
3625
|
+
colorMode: true,
|
|
3626
|
+
groupIndentation: 2
|
|
3627
|
+
});
|
|
3628
|
+
globalThis.console = newConsole;
|
|
3629
|
+
}
|
|
3164
3630
|
async function withEnv(name, fn) {
|
|
3165
3631
|
const env = await environments[name].setup(globalThis);
|
|
3166
3632
|
try {
|
|
@@ -3243,6 +3709,7 @@ async function runTest(test) {
|
|
|
3243
3709
|
};
|
|
3244
3710
|
updateTask(test);
|
|
3245
3711
|
getSnapshotClient().setTest(test);
|
|
3712
|
+
process.__vitest_worker__.current = test;
|
|
3246
3713
|
try {
|
|
3247
3714
|
await callHook(test.suite, "beforeEach", [test, test.suite]);
|
|
3248
3715
|
await getFn(test)();
|
|
@@ -3259,6 +3726,7 @@ async function runTest(test) {
|
|
|
3259
3726
|
}
|
|
3260
3727
|
getSnapshotClient().clearTest();
|
|
3261
3728
|
test.result.end = performance.now();
|
|
3729
|
+
process.__vitest_worker__.current = void 0;
|
|
3262
3730
|
updateTask(test);
|
|
3263
3731
|
}
|
|
3264
3732
|
async function runSuite(suite) {
|