vitest 2.0.0-beta.1 → 2.0.0-beta.11
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 +1 -1
- package/dist/browser.d.ts +22 -2
- package/dist/browser.js +5 -3
- package/dist/chunks/{integrations-globals.B5Jl0grA.js → integrations-globals.CC2ed6Py.js} +9 -9
- package/dist/chunks/{node-git.CCI8evVZ.js → node-git.ZtkbKc8u.js} +14 -15
- package/dist/chunks/{runtime-console.CUES-L8X.js → runtime-console.Ckl0vEQr.js} +76 -31
- package/dist/chunks/{runtime-runBaseTests._dXkRAZc.js → runtime-runBaseTests.BXW_BJeO.js} +40 -32
- package/dist/cli.js +3 -3
- package/dist/config.cjs +43 -20
- package/dist/config.d.ts +2 -2
- package/dist/config.js +43 -21
- package/dist/coverage.d.ts +4 -4
- package/dist/coverage.js +125 -37
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +2 -2
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +20 -30
- package/dist/index.js +9 -9
- package/dist/node.d.ts +22 -9
- package/dist/node.js +25 -15
- package/dist/path.js +4 -1
- package/dist/{reporters-MGvT5U9f.d.ts → reporters-fiIq_dT9.d.ts} +310 -148
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +8 -8
- package/dist/runners.d.ts +4 -2
- package/dist/runners.js +103 -57
- package/dist/{suite-8WAe-urM.d.ts → suite-D4aoU9rI.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/suite.js +2 -2
- package/dist/utils.d.ts +1 -5
- package/dist/utils.js +1 -6
- package/dist/vendor/{base.VFkIJ66g.js → base.C2DbLEfT.js} +4 -3
- package/dist/vendor/{base._gnK9Slw.js → base.CTYV4Gnz.js} +24 -17
- package/dist/vendor/{benchmark.BNLebNi5.js → benchmark.CMp8QfyL.js} +13 -14
- package/dist/vendor/{cac.DzKZaJu2.js → cac.BcJW7n2j.js} +127 -51
- package/dist/vendor/{cli-api.DTeni0Qq.js → cli-api.C8t8m4__.js} +2771 -1711
- package/dist/vendor/{constants.5SOfHUj0.js → constants.BWsVtsAj.js} +6 -22
- package/dist/vendor/{coverage.ChSqD-qS.js → coverage.BhYSDdTT.js} +27 -11
- package/dist/vendor/{date.BKM1wewY.js → date.W2xKR2qe.js} +5 -3
- package/dist/vendor/{execute.CLLNVNnK.js → execute.T3gg2ZK6.js} +177 -63
- package/dist/vendor/{index.BfoZyXD1.js → index.-dbR4KUi.js} +17 -9
- package/dist/vendor/{index.CRxYS9H3.js → index.BC5zhX9y.js} +1201 -491
- package/dist/vendor/{index.DP-km6lF.js → index.BMmMjLIQ.js} +64 -51
- package/dist/vendor/{index._7XLd8Kd.js → index.C9Thslzw.js} +2 -1
- package/dist/vendor/{index.CmILuxzC.js → index.CQJ2m700.js} +3 -3
- package/dist/vendor/{index.DeR1hhfY.js → index.D4nqnQWz.js} +71 -74
- package/dist/vendor/{rpc.DRDE9Pu1.js → rpc.BGx7q_k2.js} +30 -19
- package/dist/vendor/{run-once.DLomgGUH.js → run-once.Db8Hgq9X.js} +2 -1
- package/dist/vendor/{setup-common.XeoZAW8t.js → setup-common.uqZOEWuR.js} +30 -15
- package/dist/vendor/spy.Cf_4R5Oe.js +22 -0
- package/dist/vendor/{tasks.WC7M-K-v.js → tasks.DhVtQBtW.js} +3 -1
- package/dist/vendor/{utils.D5gGkwyH.js → utils.DSO2UK15.js} +41 -26
- package/dist/vendor/{utils.CUjzkRH7.js → utils.DkxLWvS1.js} +12 -5
- package/dist/vendor/{vi.ClD3hi7L.js → vi.BPjl8cAZ.js} +350 -166
- package/dist/vendor/{vm.Bi3bljci.js → vm.CycSoHnJ.js} +151 -86
- package/dist/worker.js +31 -15
- package/dist/workers/forks.js +4 -4
- package/dist/workers/runVmTests.js +14 -13
- package/dist/workers/threads.js +4 -4
- package/dist/workers/vmForks.js +6 -6
- package/dist/workers/vmThreads.js +6 -6
- package/dist/workers.d.ts +2 -2
- package/dist/workers.js +9 -9
- package/package.json +22 -22
- package/suppress-warnings.cjs +2 -4
|
@@ -37,7 +37,7 @@ var utils$8 = {};
|
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
39
|
exports.escapeNode = (block, n = 0, type) => {
|
|
40
|
-
|
|
40
|
+
const node = block.nodes[n];
|
|
41
41
|
if (!node) return;
|
|
42
42
|
|
|
43
43
|
if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
|
|
@@ -106,13 +106,23 @@ var utils$8 = {};
|
|
|
106
106
|
|
|
107
107
|
exports.flatten = (...args) => {
|
|
108
108
|
const result = [];
|
|
109
|
+
|
|
109
110
|
const flat = arr => {
|
|
110
111
|
for (let i = 0; i < arr.length; i++) {
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
const ele = arr[i];
|
|
113
|
+
|
|
114
|
+
if (Array.isArray(ele)) {
|
|
115
|
+
flat(ele);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (ele !== undefined) {
|
|
120
|
+
result.push(ele);
|
|
121
|
+
}
|
|
113
122
|
}
|
|
114
123
|
return result;
|
|
115
124
|
};
|
|
125
|
+
|
|
116
126
|
flat(args);
|
|
117
127
|
return result;
|
|
118
128
|
};
|
|
@@ -121,9 +131,9 @@ var utils$8 = {};
|
|
|
121
131
|
const utils$7 = utils$8;
|
|
122
132
|
|
|
123
133
|
var stringify$4 = (ast, options = {}) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
134
|
+
const stringify = (node, parent = {}) => {
|
|
135
|
+
const invalidBlock = options.escapeInvalid && utils$7.isInvalidBrace(parent);
|
|
136
|
+
const invalidNode = node.invalid === true && options.escapeInvalid === true;
|
|
127
137
|
let output = '';
|
|
128
138
|
|
|
129
139
|
if (node.value) {
|
|
@@ -138,7 +148,7 @@ var stringify$4 = (ast, options = {}) => {
|
|
|
138
148
|
}
|
|
139
149
|
|
|
140
150
|
if (node.nodes) {
|
|
141
|
-
for (
|
|
151
|
+
for (const child of node.nodes) {
|
|
142
152
|
output += stringify(child);
|
|
143
153
|
}
|
|
144
154
|
}
|
|
@@ -512,7 +522,7 @@ const toMaxLen = (input, maxLength) => {
|
|
|
512
522
|
return negative ? ('-' + input) : input;
|
|
513
523
|
};
|
|
514
524
|
|
|
515
|
-
const toSequence = (parts, options) => {
|
|
525
|
+
const toSequence = (parts, options, maxLen) => {
|
|
516
526
|
parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
517
527
|
parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
|
|
518
528
|
|
|
@@ -522,11 +532,11 @@ const toSequence = (parts, options) => {
|
|
|
522
532
|
let result;
|
|
523
533
|
|
|
524
534
|
if (parts.positives.length) {
|
|
525
|
-
positives = parts.positives.join('|');
|
|
535
|
+
positives = parts.positives.map(v => toMaxLen(String(v), maxLen)).join('|');
|
|
526
536
|
}
|
|
527
537
|
|
|
528
538
|
if (parts.negatives.length) {
|
|
529
|
-
negatives = `-(${prefix}${parts.negatives.join('|')})`;
|
|
539
|
+
negatives = `-(${prefix}${parts.negatives.map(v => toMaxLen(String(v), maxLen)).join('|')})`;
|
|
530
540
|
}
|
|
531
541
|
|
|
532
542
|
if (positives && negatives) {
|
|
@@ -624,7 +634,7 @@ const fillNumbers = (start, end, step = 1, options = {}) => {
|
|
|
624
634
|
|
|
625
635
|
if (options.toRegex === true) {
|
|
626
636
|
return step > 1
|
|
627
|
-
? toSequence(parts, options)
|
|
637
|
+
? toSequence(parts, options, maxLen)
|
|
628
638
|
: toRegex(range, null, { wrap: false, ...options });
|
|
629
639
|
}
|
|
630
640
|
|
|
@@ -636,7 +646,6 @@ const fillLetters = (start, end, step = 1, options = {}) => {
|
|
|
636
646
|
return invalidRange(start, end, options);
|
|
637
647
|
}
|
|
638
648
|
|
|
639
|
-
|
|
640
649
|
let format = options.transform || (val => String.fromCharCode(val));
|
|
641
650
|
let a = `${start}`.charCodeAt(0);
|
|
642
651
|
let b = `${end}`.charCodeAt(0);
|
|
@@ -704,30 +713,32 @@ const fill$1 = fillRange;
|
|
|
704
713
|
const utils$6 = utils$8;
|
|
705
714
|
|
|
706
715
|
const compile$1 = (ast, options = {}) => {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
716
|
+
const walk = (node, parent = {}) => {
|
|
717
|
+
const invalidBlock = utils$6.isInvalidBrace(parent);
|
|
718
|
+
const invalidNode = node.invalid === true && options.escapeInvalid === true;
|
|
719
|
+
const invalid = invalidBlock === true || invalidNode === true;
|
|
720
|
+
const prefix = options.escapeInvalid === true ? '\\' : '';
|
|
712
721
|
let output = '';
|
|
713
722
|
|
|
714
723
|
if (node.isOpen === true) {
|
|
715
724
|
return prefix + node.value;
|
|
716
725
|
}
|
|
726
|
+
|
|
717
727
|
if (node.isClose === true) {
|
|
728
|
+
console.log('node.isClose', prefix, node.value);
|
|
718
729
|
return prefix + node.value;
|
|
719
730
|
}
|
|
720
731
|
|
|
721
732
|
if (node.type === 'open') {
|
|
722
|
-
return invalid ?
|
|
733
|
+
return invalid ? prefix + node.value : '(';
|
|
723
734
|
}
|
|
724
735
|
|
|
725
736
|
if (node.type === 'close') {
|
|
726
|
-
return invalid ?
|
|
737
|
+
return invalid ? prefix + node.value : ')';
|
|
727
738
|
}
|
|
728
739
|
|
|
729
740
|
if (node.type === 'comma') {
|
|
730
|
-
return node.prev.type === 'comma' ? '' :
|
|
741
|
+
return node.prev.type === 'comma' ? '' : invalid ? node.value : '|';
|
|
731
742
|
}
|
|
732
743
|
|
|
733
744
|
if (node.value) {
|
|
@@ -735,8 +746,8 @@ const compile$1 = (ast, options = {}) => {
|
|
|
735
746
|
}
|
|
736
747
|
|
|
737
748
|
if (node.nodes && node.ranges > 0) {
|
|
738
|
-
|
|
739
|
-
|
|
749
|
+
const args = utils$6.reduce(node.nodes);
|
|
750
|
+
const range = fill$1(...args, { ...options, wrap: false, toRegex: true, strictZeros: true });
|
|
740
751
|
|
|
741
752
|
if (range.length !== 0) {
|
|
742
753
|
return args.length > 1 && range.length > 1 ? `(${range})` : range;
|
|
@@ -744,10 +755,11 @@ const compile$1 = (ast, options = {}) => {
|
|
|
744
755
|
}
|
|
745
756
|
|
|
746
757
|
if (node.nodes) {
|
|
747
|
-
for (
|
|
758
|
+
for (const child of node.nodes) {
|
|
748
759
|
output += walk(child, node);
|
|
749
760
|
}
|
|
750
761
|
}
|
|
762
|
+
|
|
751
763
|
return output;
|
|
752
764
|
};
|
|
753
765
|
|
|
@@ -761,7 +773,7 @@ const stringify$2 = stringify$4;
|
|
|
761
773
|
const utils$5 = utils$8;
|
|
762
774
|
|
|
763
775
|
const append = (queue = '', stash = '', enclose = false) => {
|
|
764
|
-
|
|
776
|
+
const result = [];
|
|
765
777
|
|
|
766
778
|
queue = [].concat(queue);
|
|
767
779
|
stash = [].concat(stash);
|
|
@@ -771,15 +783,15 @@ const append = (queue = '', stash = '', enclose = false) => {
|
|
|
771
783
|
return enclose ? utils$5.flatten(stash).map(ele => `{${ele}}`) : stash;
|
|
772
784
|
}
|
|
773
785
|
|
|
774
|
-
for (
|
|
786
|
+
for (const item of queue) {
|
|
775
787
|
if (Array.isArray(item)) {
|
|
776
|
-
for (
|
|
788
|
+
for (const value of item) {
|
|
777
789
|
result.push(append(value, stash, enclose));
|
|
778
790
|
}
|
|
779
791
|
} else {
|
|
780
792
|
for (let ele of stash) {
|
|
781
793
|
if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
|
|
782
|
-
result.push(Array.isArray(ele) ? append(item, ele, enclose) :
|
|
794
|
+
result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
|
|
783
795
|
}
|
|
784
796
|
}
|
|
785
797
|
}
|
|
@@ -787,9 +799,9 @@ const append = (queue = '', stash = '', enclose = false) => {
|
|
|
787
799
|
};
|
|
788
800
|
|
|
789
801
|
const expand$1 = (ast, options = {}) => {
|
|
790
|
-
|
|
802
|
+
const rangeLimit = options.rangeLimit === undefined ? 1000 : options.rangeLimit;
|
|
791
803
|
|
|
792
|
-
|
|
804
|
+
const walk = (node, parent = {}) => {
|
|
793
805
|
node.queue = [];
|
|
794
806
|
|
|
795
807
|
let p = parent;
|
|
@@ -811,7 +823,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
811
823
|
}
|
|
812
824
|
|
|
813
825
|
if (node.nodes && node.ranges > 0) {
|
|
814
|
-
|
|
826
|
+
const args = utils$5.reduce(node.nodes);
|
|
815
827
|
|
|
816
828
|
if (utils$5.exceedsLimit(...args, options.step, rangeLimit)) {
|
|
817
829
|
throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
|
|
@@ -827,7 +839,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
827
839
|
return;
|
|
828
840
|
}
|
|
829
841
|
|
|
830
|
-
|
|
842
|
+
const enclose = utils$5.encloseBrace(node);
|
|
831
843
|
let queue = node.queue;
|
|
832
844
|
let block = node;
|
|
833
845
|
|
|
@@ -837,7 +849,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
837
849
|
}
|
|
838
850
|
|
|
839
851
|
for (let i = 0; i < node.nodes.length; i++) {
|
|
840
|
-
|
|
852
|
+
const child = node.nodes[i];
|
|
841
853
|
|
|
842
854
|
if (child.type === 'comma' && node.type === 'brace') {
|
|
843
855
|
if (i === 1) queue.push('');
|
|
@@ -869,7 +881,7 @@ const expand$1 = (ast, options = {}) => {
|
|
|
869
881
|
var expand_1 = expand$1;
|
|
870
882
|
|
|
871
883
|
var constants$3 = {
|
|
872
|
-
MAX_LENGTH:
|
|
884
|
+
MAX_LENGTH: 10000,
|
|
873
885
|
|
|
874
886
|
// Digits
|
|
875
887
|
CHAR_0: '0', /* 0 */
|
|
@@ -957,18 +969,18 @@ const parse$3 = (input, options = {}) => {
|
|
|
957
969
|
throw new TypeError('Expected a string');
|
|
958
970
|
}
|
|
959
971
|
|
|
960
|
-
|
|
961
|
-
|
|
972
|
+
const opts = options || {};
|
|
973
|
+
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$1, opts.maxLength) : MAX_LENGTH$1;
|
|
962
974
|
if (input.length > max) {
|
|
963
975
|
throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
|
|
964
976
|
}
|
|
965
977
|
|
|
966
|
-
|
|
967
|
-
|
|
978
|
+
const ast = { type: 'root', input, nodes: [] };
|
|
979
|
+
const stack = [ast];
|
|
968
980
|
let block = ast;
|
|
969
981
|
let prev = ast;
|
|
970
982
|
let brackets = 0;
|
|
971
|
-
|
|
983
|
+
const length = input.length;
|
|
972
984
|
let index = 0;
|
|
973
985
|
let depth = 0;
|
|
974
986
|
let value;
|
|
@@ -1033,6 +1045,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
1033
1045
|
|
|
1034
1046
|
if (value === CHAR_LEFT_SQUARE_BRACKET$1) {
|
|
1035
1047
|
brackets++;
|
|
1048
|
+
|
|
1036
1049
|
let next;
|
|
1037
1050
|
|
|
1038
1051
|
while (index < length && (next = advance())) {
|
|
@@ -1088,7 +1101,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
1088
1101
|
*/
|
|
1089
1102
|
|
|
1090
1103
|
if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
|
|
1091
|
-
|
|
1104
|
+
const open = value;
|
|
1092
1105
|
let next;
|
|
1093
1106
|
|
|
1094
1107
|
if (options.keepQuotes !== true) {
|
|
@@ -1120,8 +1133,8 @@ const parse$3 = (input, options = {}) => {
|
|
|
1120
1133
|
if (value === CHAR_LEFT_CURLY_BRACE$1) {
|
|
1121
1134
|
depth++;
|
|
1122
1135
|
|
|
1123
|
-
|
|
1124
|
-
|
|
1136
|
+
const dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
|
|
1137
|
+
const brace = {
|
|
1125
1138
|
type: 'brace',
|
|
1126
1139
|
open: true,
|
|
1127
1140
|
close: false,
|
|
@@ -1148,7 +1161,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
1148
1161
|
continue;
|
|
1149
1162
|
}
|
|
1150
1163
|
|
|
1151
|
-
|
|
1164
|
+
const type = 'close';
|
|
1152
1165
|
block = stack.pop();
|
|
1153
1166
|
block.close = true;
|
|
1154
1167
|
|
|
@@ -1166,7 +1179,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
1166
1179
|
if (value === CHAR_COMMA$1 && depth > 0) {
|
|
1167
1180
|
if (block.ranges > 0) {
|
|
1168
1181
|
block.ranges = 0;
|
|
1169
|
-
|
|
1182
|
+
const open = block.nodes.shift();
|
|
1170
1183
|
block.nodes = [open, { type: 'text', value: stringify$1(block) }];
|
|
1171
1184
|
}
|
|
1172
1185
|
|
|
@@ -1180,7 +1193,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
1180
1193
|
*/
|
|
1181
1194
|
|
|
1182
1195
|
if (value === CHAR_DOT$1 && depth > 0 && block.commas === 0) {
|
|
1183
|
-
|
|
1196
|
+
const siblings = block.nodes;
|
|
1184
1197
|
|
|
1185
1198
|
if (depth === 0 || siblings.length === 0) {
|
|
1186
1199
|
push({ type: 'text', value });
|
|
@@ -1207,7 +1220,7 @@ const parse$3 = (input, options = {}) => {
|
|
|
1207
1220
|
if (prev.type === 'range') {
|
|
1208
1221
|
siblings.pop();
|
|
1209
1222
|
|
|
1210
|
-
|
|
1223
|
+
const before = siblings[siblings.length - 1];
|
|
1211
1224
|
before.value += prev.value + value;
|
|
1212
1225
|
prev = before;
|
|
1213
1226
|
block.ranges--;
|
|
@@ -1240,8 +1253,8 @@ const parse$3 = (input, options = {}) => {
|
|
|
1240
1253
|
});
|
|
1241
1254
|
|
|
1242
1255
|
// get the location of the block on parent.nodes (block's siblings)
|
|
1243
|
-
|
|
1244
|
-
|
|
1256
|
+
const parent = stack[stack.length - 1];
|
|
1257
|
+
const index = parent.nodes.indexOf(block);
|
|
1245
1258
|
// replace the (invalid) block with it's nodes
|
|
1246
1259
|
parent.nodes.splice(index, 1, ...block.nodes);
|
|
1247
1260
|
}
|
|
@@ -1276,8 +1289,8 @@ const braces$1 = (input, options = {}) => {
|
|
|
1276
1289
|
let output = [];
|
|
1277
1290
|
|
|
1278
1291
|
if (Array.isArray(input)) {
|
|
1279
|
-
for (
|
|
1280
|
-
|
|
1292
|
+
for (const pattern of input) {
|
|
1293
|
+
const result = braces$1.create(pattern, options);
|
|
1281
1294
|
if (Array.isArray(result)) {
|
|
1282
1295
|
output.push(...result);
|
|
1283
1296
|
} else {
|
|
@@ -1411,7 +1424,7 @@ braces$1.create = (input, options = {}) => {
|
|
|
1411
1424
|
return [input];
|
|
1412
1425
|
}
|
|
1413
1426
|
|
|
1414
|
-
|
|
1427
|
+
return options.expand !== true
|
|
1415
1428
|
? braces$1.compile(input, options)
|
|
1416
1429
|
: braces$1.expand(input, options);
|
|
1417
1430
|
};
|
|
@@ -3959,4 +3972,4 @@ var micromatch_1 = micromatch;
|
|
|
3959
3972
|
|
|
3960
3973
|
var mm = /*@__PURE__*/getDefaultExportFromCjs(micromatch_1);
|
|
3961
3974
|
|
|
3962
|
-
export {
|
|
3975
|
+
export { braces_1 as b, mm as m, picomatch$1 as p, utils$4 as u };
|
|
@@ -13,8 +13,9 @@ function isRunningInBenchmark() {
|
|
|
13
13
|
const relativePath = relative;
|
|
14
14
|
function removeUndefinedValues(obj) {
|
|
15
15
|
for (const key in Object.keys(obj)) {
|
|
16
|
-
if (obj[key] === void 0)
|
|
16
|
+
if (obj[key] === void 0) {
|
|
17
17
|
delete obj[key];
|
|
18
|
+
}
|
|
18
19
|
}
|
|
19
20
|
return obj;
|
|
20
21
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
|
|
2
|
-
import { b as bench } from './benchmark.
|
|
3
|
-
import { i as isFirstRun, a as runOnce } from './run-once.
|
|
4
|
-
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.
|
|
2
|
+
import { b as bench } from './benchmark.CMp8QfyL.js';
|
|
3
|
+
import { i as isFirstRun, a as runOnce } from './run-once.Db8Hgq9X.js';
|
|
4
|
+
import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.BPjl8cAZ.js';
|
|
5
5
|
import { g as getWorkerState } from './global.7bFbnyXl.js';
|
|
6
6
|
import * as chai from 'chai';
|
|
7
7
|
import { assert, should } from 'chai';
|
|
@@ -29,10 +29,7 @@ var node = {
|
|
|
29
29
|
async setupVM() {
|
|
30
30
|
const vm = await import('node:vm');
|
|
31
31
|
let context = vm.createContext();
|
|
32
|
-
let global = vm.runInContext(
|
|
33
|
-
"this",
|
|
34
|
-
context
|
|
35
|
-
);
|
|
32
|
+
let global = vm.runInContext("this", context);
|
|
36
33
|
const contextGlobals = new Set(Object.getOwnPropertyNames(global));
|
|
37
34
|
for (const [nodeGlobalsKey, descriptor] of nodeGlobals) {
|
|
38
35
|
if (!contextGlobals.has(nodeGlobalsKey)) {
|
|
@@ -345,21 +342,20 @@ const OTHER_KEYS = [
|
|
|
345
342
|
];
|
|
346
343
|
const KEYS = LIVING_KEYS.concat(OTHER_KEYS);
|
|
347
344
|
|
|
348
|
-
const skipKeys = [
|
|
349
|
-
"window",
|
|
350
|
-
"self",
|
|
351
|
-
"top",
|
|
352
|
-
"parent"
|
|
353
|
-
];
|
|
345
|
+
const skipKeys = ["window", "self", "top", "parent"];
|
|
354
346
|
function getWindowKeys(global, win, additionalKeys = []) {
|
|
355
347
|
const keysArray = [...additionalKeys, ...KEYS];
|
|
356
|
-
const keys = new Set(
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
348
|
+
const keys = new Set(
|
|
349
|
+
keysArray.concat(Object.getOwnPropertyNames(win)).filter((k) => {
|
|
350
|
+
if (skipKeys.includes(k)) {
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
353
|
+
if (k in global) {
|
|
354
|
+
return keysArray.includes(k);
|
|
355
|
+
}
|
|
356
|
+
return true;
|
|
357
|
+
})
|
|
358
|
+
);
|
|
363
359
|
return keys;
|
|
364
360
|
}
|
|
365
361
|
function isClassLikeName(name) {
|
|
@@ -372,14 +368,17 @@ function populateGlobal(global, win, options = {}) {
|
|
|
372
368
|
const overrideObject = /* @__PURE__ */ new Map();
|
|
373
369
|
for (const key of keys) {
|
|
374
370
|
const boundFunction = bindFunctions && typeof win[key] === "function" && !isClassLikeName(key) && win[key].bind(win);
|
|
375
|
-
if (KEYS.includes(key) && key in global)
|
|
371
|
+
if (KEYS.includes(key) && key in global) {
|
|
376
372
|
originals.set(key, global[key]);
|
|
373
|
+
}
|
|
377
374
|
Object.defineProperty(global, key, {
|
|
378
375
|
get() {
|
|
379
|
-
if (overrideObject.has(key))
|
|
376
|
+
if (overrideObject.has(key)) {
|
|
380
377
|
return overrideObject.get(key);
|
|
381
|
-
|
|
378
|
+
}
|
|
379
|
+
if (boundFunction) {
|
|
382
380
|
return boundFunction;
|
|
381
|
+
}
|
|
383
382
|
return win[key];
|
|
384
383
|
},
|
|
385
384
|
set(v) {
|
|
@@ -392,8 +391,9 @@ function populateGlobal(global, win, options = {}) {
|
|
|
392
391
|
global.self = global;
|
|
393
392
|
global.top = global;
|
|
394
393
|
global.parent = global;
|
|
395
|
-
if (global.global)
|
|
394
|
+
if (global.global) {
|
|
396
395
|
global.global = global;
|
|
396
|
+
}
|
|
397
397
|
if (global.document && global.document.defaultView) {
|
|
398
398
|
Object.defineProperty(global.document, "defaultView", {
|
|
399
399
|
get: () => global,
|
|
@@ -412,20 +412,23 @@ function populateGlobal(global, win, options = {}) {
|
|
|
412
412
|
function catchWindowErrors(window) {
|
|
413
413
|
let userErrorListenerCount = 0;
|
|
414
414
|
function throwUnhandlerError(e) {
|
|
415
|
-
if (userErrorListenerCount === 0 && e.error != null)
|
|
415
|
+
if (userErrorListenerCount === 0 && e.error != null) {
|
|
416
416
|
process.emit("uncaughtException", e.error);
|
|
417
|
+
}
|
|
417
418
|
}
|
|
418
419
|
const addEventListener = window.addEventListener.bind(window);
|
|
419
420
|
const removeEventListener = window.removeEventListener.bind(window);
|
|
420
421
|
window.addEventListener("error", throwUnhandlerError);
|
|
421
422
|
window.addEventListener = function(...args) {
|
|
422
|
-
if (args[0] === "error")
|
|
423
|
+
if (args[0] === "error") {
|
|
423
424
|
userErrorListenerCount++;
|
|
425
|
+
}
|
|
424
426
|
return addEventListener.apply(this, args);
|
|
425
427
|
};
|
|
426
428
|
window.removeEventListener = function(...args) {
|
|
427
|
-
if (args[0] === "error" && userErrorListenerCount)
|
|
429
|
+
if (args[0] === "error" && userErrorListenerCount) {
|
|
428
430
|
userErrorListenerCount--;
|
|
431
|
+
}
|
|
429
432
|
return removeEventListener.apply(this, args);
|
|
430
433
|
};
|
|
431
434
|
return function clearErrorHandlers() {
|
|
@@ -436,12 +439,7 @@ var jsdom = {
|
|
|
436
439
|
name: "jsdom",
|
|
437
440
|
transformMode: "web",
|
|
438
441
|
async setupVM({ jsdom = {} }) {
|
|
439
|
-
const {
|
|
440
|
-
CookieJar,
|
|
441
|
-
JSDOM,
|
|
442
|
-
ResourceLoader,
|
|
443
|
-
VirtualConsole
|
|
444
|
-
} = await import('jsdom');
|
|
442
|
+
const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import('jsdom');
|
|
445
443
|
const {
|
|
446
444
|
html = "<!DOCTYPE html>",
|
|
447
445
|
userAgent,
|
|
@@ -455,21 +453,18 @@ var jsdom = {
|
|
|
455
453
|
cookieJar = false,
|
|
456
454
|
...restOptions
|
|
457
455
|
} = jsdom;
|
|
458
|
-
let dom = new JSDOM(
|
|
459
|
-
|
|
460
|
-
{
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
...restOptions
|
|
471
|
-
}
|
|
472
|
-
);
|
|
456
|
+
let dom = new JSDOM(html, {
|
|
457
|
+
pretendToBeVisual,
|
|
458
|
+
resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) : void 0),
|
|
459
|
+
runScripts,
|
|
460
|
+
url,
|
|
461
|
+
virtualConsole: console && globalThis.console ? new VirtualConsole().sendTo(globalThis.console) : void 0,
|
|
462
|
+
cookieJar: cookieJar ? new CookieJar() : void 0,
|
|
463
|
+
includeNodeLocations,
|
|
464
|
+
contentType,
|
|
465
|
+
userAgent,
|
|
466
|
+
...restOptions
|
|
467
|
+
});
|
|
473
468
|
const clearWindowErrors = catchWindowErrors(dom.window);
|
|
474
469
|
dom.window.Buffer = Buffer;
|
|
475
470
|
dom.window.jsdom = dom;
|
|
@@ -486,8 +481,9 @@ var jsdom = {
|
|
|
486
481
|
];
|
|
487
482
|
for (const name of globalNames) {
|
|
488
483
|
const value = globalThis[name];
|
|
489
|
-
if (typeof value !== "undefined" && typeof dom.window[name] === "undefined")
|
|
484
|
+
if (typeof value !== "undefined" && typeof dom.window[name] === "undefined") {
|
|
490
485
|
dom.window[name] = value;
|
|
486
|
+
}
|
|
491
487
|
}
|
|
492
488
|
return {
|
|
493
489
|
getVmContext() {
|
|
@@ -501,12 +497,7 @@ var jsdom = {
|
|
|
501
497
|
};
|
|
502
498
|
},
|
|
503
499
|
async setup(global, { jsdom = {} }) {
|
|
504
|
-
const {
|
|
505
|
-
CookieJar,
|
|
506
|
-
JSDOM,
|
|
507
|
-
ResourceLoader,
|
|
508
|
-
VirtualConsole
|
|
509
|
-
} = await import('jsdom');
|
|
500
|
+
const { CookieJar, JSDOM, ResourceLoader, VirtualConsole } = await import('jsdom');
|
|
510
501
|
const {
|
|
511
502
|
html = "<!DOCTYPE html>",
|
|
512
503
|
userAgent,
|
|
@@ -520,22 +511,21 @@ var jsdom = {
|
|
|
520
511
|
cookieJar = false,
|
|
521
512
|
...restOptions
|
|
522
513
|
} = jsdom;
|
|
523
|
-
const dom = new JSDOM(
|
|
524
|
-
|
|
525
|
-
{
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
);
|
|
538
|
-
const { keys, originals } = populateGlobal(global, dom.window, { bindFunctions: true });
|
|
514
|
+
const dom = new JSDOM(html, {
|
|
515
|
+
pretendToBeVisual,
|
|
516
|
+
resources: resources ?? (userAgent ? new ResourceLoader({ userAgent }) : void 0),
|
|
517
|
+
runScripts,
|
|
518
|
+
url,
|
|
519
|
+
virtualConsole: console && global.console ? new VirtualConsole().sendTo(global.console) : void 0,
|
|
520
|
+
cookieJar: cookieJar ? new CookieJar() : void 0,
|
|
521
|
+
includeNodeLocations,
|
|
522
|
+
contentType,
|
|
523
|
+
userAgent,
|
|
524
|
+
...restOptions
|
|
525
|
+
});
|
|
526
|
+
const { keys, originals } = populateGlobal(global, dom.window, {
|
|
527
|
+
bindFunctions: true
|
|
528
|
+
});
|
|
539
529
|
const clearWindowErrors = catchWindowErrors(global);
|
|
540
530
|
global.jsdom = dom;
|
|
541
531
|
return {
|
|
@@ -573,8 +563,9 @@ var happy = {
|
|
|
573
563
|
}
|
|
574
564
|
});
|
|
575
565
|
win.Buffer = Buffer;
|
|
576
|
-
if (typeof structuredClone !== "undefined" && !win.structuredClone)
|
|
566
|
+
if (typeof structuredClone !== "undefined" && !win.structuredClone) {
|
|
577
567
|
win.structuredClone = structuredClone;
|
|
568
|
+
}
|
|
578
569
|
return {
|
|
579
570
|
getVmContext() {
|
|
580
571
|
return win;
|
|
@@ -638,13 +629,16 @@ var edge = {
|
|
|
638
629
|
context.global = context;
|
|
639
630
|
context.Buffer = Buffer;
|
|
640
631
|
KEYS.forEach((key) => {
|
|
641
|
-
if (key in global)
|
|
632
|
+
if (key in global) {
|
|
642
633
|
context[key] = global[key];
|
|
634
|
+
}
|
|
643
635
|
});
|
|
644
636
|
return context;
|
|
645
637
|
}
|
|
646
638
|
});
|
|
647
|
-
const { keys, originals } = populateGlobal(global, vm.context, {
|
|
639
|
+
const { keys, originals } = populateGlobal(global, vm.context, {
|
|
640
|
+
bindFunctions: true
|
|
641
|
+
});
|
|
648
642
|
return {
|
|
649
643
|
teardown(global2) {
|
|
650
644
|
keys.forEach((key) => delete global2[key]);
|
|
@@ -666,12 +660,15 @@ const envPackageNames = {
|
|
|
666
660
|
"edge-runtime": "@edge-runtime/vm"
|
|
667
661
|
};
|
|
668
662
|
function getEnvPackageName(env) {
|
|
669
|
-
if (env === "node")
|
|
663
|
+
if (env === "node") {
|
|
670
664
|
return null;
|
|
671
|
-
|
|
665
|
+
}
|
|
666
|
+
if (env in envPackageNames) {
|
|
672
667
|
return envPackageNames[env];
|
|
673
|
-
|
|
668
|
+
}
|
|
669
|
+
if (env[0] === "." || env[0] === "/") {
|
|
674
670
|
return null;
|
|
671
|
+
}
|
|
675
672
|
return `vitest-environment-${env}`;
|
|
676
673
|
}
|
|
677
674
|
|