vitest 0.9.3 → 0.10.1

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.
Files changed (31) hide show
  1. package/LICENSE.md +7 -0
  2. package/dist/{chunk-api-setup.d764f144.js → chunk-api-setup.b55307fb.js} +41 -18
  3. package/dist/{chunk-constants.a6ce1057.js → chunk-constants.90075174.js} +1 -1
  4. package/dist/{chunk-defaults.aecec9d4.js → chunk-defaults.fd5b939d.js} +1 -1
  5. package/dist/{chunk-install-pkg.7dd40977.js → chunk-install-pkg.73b84ae1.js} +113 -115
  6. package/dist/chunk-integrations-globals.a759742a.js +29 -0
  7. package/dist/chunk-integrations-spy.f036df6f.js +102 -0
  8. package/dist/{chunk-runtime-chain.e17b859e.js → chunk-runtime-chain.6292a3de.js} +944 -901
  9. package/dist/{chunk-runtime-mocker.d325f149.js → chunk-runtime-mocker.ca5ecf98.js} +5 -21
  10. package/dist/{chunk-runtime-rpc.9e81f15b.js → chunk-runtime-rpc.8e14ae4f.js} +1 -1
  11. package/dist/{chunk-utils-global.46331799.js → chunk-utils-global.9b434e81.js} +42 -10
  12. package/dist/{chunk-utils-timers.6cfeb494.js → chunk-utils-timers.c50fec92.js} +1406 -1057
  13. package/dist/{chunk-vite-node-externalize.9aaddc2d.js → chunk-vite-node-externalize.4dd7260b.js} +1852 -4425
  14. package/dist/{chunk-vite-node-utils.3400d522.js → chunk-vite-node-utils.c160b239.js} +73 -71
  15. package/dist/cli.js +12 -12
  16. package/dist/entry.js +15 -919
  17. package/dist/index.d.ts +107 -31
  18. package/dist/index.js +8 -8
  19. package/dist/node.d.ts +34 -12
  20. package/dist/node.js +11 -11
  21. package/dist/spy.js +2 -102
  22. package/dist/vendor-_commonjsHelpers.addc3445.js +3 -0
  23. package/dist/vendor-entry.9dd6e6e6.js +986 -0
  24. package/dist/vendor-index.405e58ef.js +6291 -0
  25. package/dist/{vendor-index.87b2fc14.js → vendor-index.40be925a.js} +167 -152
  26. package/dist/worker.js +9 -6
  27. package/package.json +15 -16
  28. package/vitest.mjs +1 -1
  29. package/dist/chunk-integrations-globals.5686bfb8.js +0 -23
  30. package/dist/vendor-_commonjsHelpers.34b404ce.js +0 -7
  31. package/dist/vendor-index.13468339.js +0 -5707
@@ -1,11 +1,11 @@
1
- import require$$0, { format } from 'util';
2
- import { g as getWorkerState, i as isObject, t as toArray, n as noop, a as index$1, b as getCallLastIndex, s as slash, c as getNames, d as assertTypes, e as c, r as resetModules } from './chunk-utils-global.46331799.js';
3
- import { s as setTimeout, c as clearTimeout, p as plugins_1, f as format_1, g as getOriginalPos, a as posToNumber, n as numberToPos, l as lineSplitRE, b as parseStacktrace, u as unifiedDiff, d as stringify, m as matcherUtils } from './chunk-utils-timers.6cfeb494.js';
4
- import chai$1, { expect as expect$1, util, assert, should } from 'chai';
5
- import { c as commonjsRequire, a as commonjsGlobal } from './vendor-_commonjsHelpers.34b404ce.js';
6
- import { r as rpc } from './chunk-runtime-rpc.9e81f15b.js';
1
+ import chai$1, { expect as expect$1, util } from 'chai';
2
+ import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
3
+ import { r as rpc } from './chunk-runtime-rpc.8e14ae4f.js';
4
+ import { i as isObject, a as index, g as getCallLastIndex, s as slash, b as getWorkerState, c as getNames, d as assertTypes, p as picocolors, n as noop, t as toArray, r as resetModules } from './chunk-utils-global.9b434e81.js';
7
5
  import fs, { promises } from 'fs';
8
- import { isMockFunction, spyOn, fn, spies } from './spy.js';
6
+ import { p as plugins_1, f as format_1, g as getOriginalPos, a as posToNumber, n as numberToPos, l as lineSplitRE, b as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils, c as setTimeout, d as clearTimeout } from './chunk-utils-timers.c50fec92.js';
7
+ import { i as isMockFunction, s as spyOn, f as fn, a as spies } from './chunk-integrations-spy.f036df6f.js';
8
+ import require$$0, { format } from 'util';
9
9
 
10
10
  var __defProp$4 = Object.defineProperty;
11
11
  var __defProps$2 = Object.defineProperties;
@@ -45,313 +45,92 @@ function createChainable(keys, fn) {
45
45
  return chain;
46
46
  }
47
47
 
48
- const context = {
49
- tasks: [],
50
- currentSuite: null
51
- };
52
- function collectTask(task) {
53
- var _a;
54
- (_a = context.currentSuite) == null ? void 0 : _a.tasks.push(task);
55
- }
56
- async function runWithSuite(suite, fn) {
57
- const prev = context.currentSuite;
58
- context.currentSuite = suite;
59
- await fn();
60
- context.currentSuite = prev;
61
- }
62
- function getDefaultTestTimeout() {
63
- return getWorkerState().config.testTimeout;
64
- }
65
- function getDefaultHookTimeout() {
66
- return getWorkerState().config.hookTimeout;
67
- }
68
- function withTimeout(fn, timeout = getDefaultTestTimeout(), isHook = false) {
69
- if (timeout <= 0 || timeout === Infinity)
70
- return fn;
71
- return (...args) => {
72
- return Promise.race([fn(...args), new Promise((resolve, reject) => {
73
- const timer = setTimeout(() => {
74
- clearTimeout(timer);
75
- reject(new Error(makeTimeoutMsg(isHook, timeout)));
76
- }, timeout);
77
- timer.unref();
78
- })]);
79
- };
80
- }
81
- function makeTimeoutMsg(isHook, timeout) {
82
- return `${isHook ? "Hook" : "Test"} timed out in ${timeout}ms.
83
- If this is a long-running test, pass a timeout value as the last argument or configure it globally with "${isHook ? "hookTimeout" : "testTimeout"}".`;
84
- }
85
- function ensureAsyncTest(fn) {
86
- if (!fn.length)
87
- return fn;
88
- return () => new Promise((resolve, reject) => {
89
- const done = (...args) => args[0] ? reject(args[0]) : resolve();
90
- fn(done);
91
- });
92
- }
93
- function normalizeTest(fn, timeout) {
94
- return withTimeout(ensureAsyncTest(fn), timeout);
95
- }
96
-
97
- const fnMap = /* @__PURE__ */ new WeakMap();
98
- const hooksMap = /* @__PURE__ */ new WeakMap();
99
- function setFn(key, fn) {
100
- fnMap.set(key, fn);
101
- }
102
- function getFn(key) {
103
- return fnMap.get(key);
104
- }
105
- function setHooks(key, hooks) {
106
- hooksMap.set(key, hooks);
107
- }
108
- function getHooks(key) {
109
- return hooksMap.get(key);
110
- }
111
-
112
- const suite = createSuite();
113
- const test = createTest(function(name, fn, timeout) {
114
- getCurrentSuite().test.fn.call(this, name, fn, timeout);
115
- });
116
- function formatTitle(template, items, idx) {
117
- if (template.includes("%#")) {
118
- template = template.replace(/%%/g, "__vitest_escaped_%__").replace(/%#/g, `${idx}`).replace(/__vitest_escaped_%__/g, "%%");
119
- }
120
- const count = template.split("%").length - 1;
121
- let formatted = format(template, ...items.slice(0, count));
122
- if (isObject(items[0])) {
123
- formatted = formatted.replace(/\$([$\w_]+)/g, (_, key) => {
124
- return items[0][key];
125
- });
126
- }
127
- return formatted;
128
- }
129
- const describe = suite;
130
- const it = test;
131
- const defaultSuite = suite("");
132
- function clearContext() {
133
- context.tasks.length = 0;
134
- defaultSuite.clear();
135
- context.currentSuite = defaultSuite;
136
- }
137
- function getCurrentSuite() {
138
- return context.currentSuite || defaultSuite;
139
- }
140
- function createSuiteHooks() {
141
- return {
142
- beforeAll: [],
143
- afterAll: [],
144
- beforeEach: [],
145
- afterEach: []
146
- };
147
- }
148
- function createSuiteCollector(name, factory = () => {
149
- }, mode, concurrent) {
150
- const tasks = [];
151
- const factoryQueue = [];
152
- let suite2;
153
- initSuite();
154
- const test2 = createTest(function(name2, fn, timeout) {
155
- const mode2 = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
156
- const test3 = {
157
- id: "",
158
- type: "test",
159
- name: name2,
160
- mode: mode2,
161
- suite: void 0,
162
- fails: this.fails
163
- };
164
- if (this.concurrent || concurrent)
165
- test3.concurrent = true;
166
- setFn(test3, normalizeTest(fn || noop, timeout));
167
- tasks.push(test3);
168
- });
169
- const collector = {
170
- type: "collector",
171
- name,
172
- mode,
173
- test: test2,
174
- tasks,
175
- collect,
176
- clear,
177
- on: addHook
178
- };
179
- function addHook(name2, ...fn) {
180
- getHooks(suite2)[name2].push(...fn);
181
- }
182
- function initSuite() {
183
- suite2 = {
184
- id: "",
185
- type: "suite",
186
- name,
187
- mode,
188
- tasks: []
189
- };
190
- setHooks(suite2, createSuiteHooks());
191
- }
192
- function clear() {
193
- tasks.length = 0;
194
- factoryQueue.length = 0;
195
- initSuite();
196
- }
197
- async function collect(file) {
198
- factoryQueue.length = 0;
199
- if (factory)
200
- await runWithSuite(collector, () => factory(test2));
201
- const allChildren = [];
202
- for (const i of [...factoryQueue, ...tasks])
203
- allChildren.push(i.type === "collector" ? await i.collect(file) : i);
204
- suite2.file = file;
205
- suite2.tasks = allChildren;
206
- allChildren.forEach((task) => {
207
- task.suite = suite2;
208
- if (file)
209
- task.file = file;
210
- });
211
- return suite2;
212
- }
213
- collectTask(collector);
214
- return collector;
215
- }
216
- function createSuite() {
217
- const suite2 = createChainable(["concurrent", "skip", "only", "todo"], function(name, factory) {
218
- const mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
219
- return createSuiteCollector(name, factory, mode, this.concurrent);
220
- });
221
- suite2.each = (cases) => {
222
- return (name, fn) => {
223
- cases.forEach((i, idx) => {
224
- const items = toArray(i);
225
- suite2(formatTitle(name, items, idx), () => fn(...items));
226
- });
227
- };
228
- };
229
- return suite2;
230
- }
231
- function createTest(fn) {
232
- const test2 = createChainable(["concurrent", "skip", "only", "todo", "fails"], fn);
233
- test2.each = (cases) => {
234
- return (name, fn2) => {
235
- cases.forEach((i, idx) => {
236
- const items = toArray(i);
237
- test2(formatTitle(name, items, idx), () => fn2(...items));
238
- });
239
- };
240
- };
241
- return test2;
242
- }
243
-
244
- const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
245
- const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
246
- const beforeEach = (fn, timeout) => getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
247
- const afterEach = (fn, timeout) => getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
248
-
249
- const filesCount = /* @__PURE__ */ new Map();
250
- const cache = /* @__PURE__ */ new Map();
251
- function runOnce(fn, key) {
252
- const filepath = getWorkerState().filepath || "__unknown_files__";
253
- if (!key) {
254
- filesCount.set(filepath, (filesCount.get(filepath) || 0) + 1);
255
- key = String(filesCount.get(filepath));
256
- }
257
- const id = `${filepath}:${key}`;
258
- if (!cache.has(id))
259
- cache.set(id, fn());
260
- return cache.get(id);
261
- }
262
- function isFirstRun() {
263
- let firstRun = false;
264
- runOnce(() => {
265
- firstRun = true;
266
- }, "__vitest_first_run__");
267
- return firstRun;
268
- }
269
- function resetRunOnceCounter() {
270
- filesCount.clear();
48
+ function commonjsRequire(path) {
49
+ throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
271
50
  }
272
51
 
273
52
  var chaiSubset = {exports: {}};
274
53
 
275
54
  (function (module, exports) {
276
- (function() {
277
- (function(chaiSubset) {
278
- if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') {
279
- return module.exports = chaiSubset;
280
- } else {
281
- return chai.use(chaiSubset);
282
- }
283
- })(function(chai, utils) {
284
- var Assertion = chai.Assertion;
285
- var assertionPrototype = Assertion.prototype;
286
-
287
- Assertion.addMethod('containSubset', function (expected) {
288
- var actual = utils.flag(this, 'object');
289
- var showDiff = chai.config.showDiff;
290
-
291
- assertionPrototype.assert.call(this,
292
- compare(expected, actual),
293
- 'expected #{act} to contain subset #{exp}',
294
- 'expected #{act} to not contain subset #{exp}',
295
- expected,
296
- actual,
297
- showDiff
298
- );
299
- });
300
-
301
- chai.assert.containSubset = function(val, exp, msg) {
302
- new chai.Assertion(val, msg).to.be.containSubset(exp);
303
- };
304
-
305
- function compare(expected, actual) {
306
- if (expected === actual) {
307
- return true;
308
- }
309
- if (typeof(actual) !== typeof(expected)) {
310
- return false;
311
- }
312
- if (typeof(expected) !== 'object' || expected === null) {
313
- return expected === actual;
314
- }
315
- if (!!expected && !actual) {
316
- return false;
55
+ (function() {
56
+ (function(chaiSubset) {
57
+ if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') {
58
+ return module.exports = chaiSubset;
59
+ } else {
60
+ return chai.use(chaiSubset);
317
61
  }
62
+ })(function(chai, utils) {
63
+ var Assertion = chai.Assertion;
64
+ var assertionPrototype = Assertion.prototype;
65
+
66
+ Assertion.addMethod('containSubset', function (expected) {
67
+ var actual = utils.flag(this, 'object');
68
+ var showDiff = chai.config.showDiff;
69
+
70
+ assertionPrototype.assert.call(this,
71
+ compare(expected, actual),
72
+ 'expected #{act} to contain subset #{exp}',
73
+ 'expected #{act} to not contain subset #{exp}',
74
+ expected,
75
+ actual,
76
+ showDiff
77
+ );
78
+ });
79
+
80
+ chai.assert.containSubset = function(val, exp, msg) {
81
+ new chai.Assertion(val, msg).to.be.containSubset(exp);
82
+ };
318
83
 
319
- if (Array.isArray(expected)) {
320
- if (typeof(actual.length) !== 'number') {
84
+ function compare(expected, actual) {
85
+ if (expected === actual) {
86
+ return true;
87
+ }
88
+ if (typeof(actual) !== typeof(expected)) {
321
89
  return false;
322
90
  }
323
- var aa = Array.prototype.slice.call(actual);
324
- return expected.every(function (exp) {
325
- return aa.some(function (act) {
326
- return compare(exp, act);
327
- });
328
- });
329
- }
330
-
331
- if (expected instanceof Date) {
332
- if (actual instanceof Date) {
333
- return expected.getTime() === actual.getTime();
334
- } else {
91
+ if (typeof(expected) !== 'object' || expected === null) {
92
+ return expected === actual;
93
+ }
94
+ if (!!expected && !actual) {
335
95
  return false;
336
96
  }
337
- }
338
97
 
339
- return Object.keys(expected).every(function (key) {
340
- var eo = expected[key];
341
- var ao = actual[key];
342
- if (typeof(eo) === 'object' && eo !== null && ao !== null) {
343
- return compare(eo, ao);
98
+ if (Array.isArray(expected)) {
99
+ if (typeof(actual.length) !== 'number') {
100
+ return false;
101
+ }
102
+ var aa = Array.prototype.slice.call(actual);
103
+ return expected.every(function (exp) {
104
+ return aa.some(function (act) {
105
+ return compare(exp, act);
106
+ });
107
+ });
344
108
  }
345
- if (typeof(eo) === 'function') {
346
- return eo(ao);
109
+
110
+ if (expected instanceof Date) {
111
+ if (actual instanceof Date) {
112
+ return expected.getTime() === actual.getTime();
113
+ } else {
114
+ return false;
115
+ }
347
116
  }
348
- return ao === eo;
349
- });
350
- }
351
- });
352
117
 
353
- }).call(commonjsGlobal);
354
- }(chaiSubset));
118
+ return Object.keys(expected).every(function (key) {
119
+ var eo = expected[key];
120
+ var ao = actual[key];
121
+ if (typeof(eo) === 'object' && eo !== null && ao !== null) {
122
+ return compare(eo, ao);
123
+ }
124
+ if (typeof(eo) === 'function') {
125
+ return eo(ao);
126
+ }
127
+ return ao === eo;
128
+ });
129
+ }
130
+ });
131
+
132
+ }).call(commonjsGlobal);
133
+ } (chaiSubset));
355
134
 
356
135
  var Subset = chaiSubset.exports;
357
136
 
@@ -597,7 +376,7 @@ const sparseArrayEquality = (a, b) => {
597
376
  return equals(a, b, [iterableEquality, typeEquality], true) && equals(aKeys, bKeys);
598
377
  };
599
378
 
600
- var naturalCompare$2 = {exports: {}};
379
+ var naturalCompare$1 = {exports: {}};
601
380
 
602
381
  /*
603
382
  * @version 1.4.0
@@ -649,13 +428,11 @@ var naturalCompare = function(a, b) {
649
428
  };
650
429
 
651
430
  try {
652
- naturalCompare$2.exports = naturalCompare;
431
+ naturalCompare$1.exports = naturalCompare;
653
432
  } catch (e) {
654
433
  String.naturalCompare = naturalCompare;
655
434
  }
656
435
 
657
- var naturalCompare$1 = naturalCompare$2.exports;
658
-
659
436
  const {
660
437
  DOMCollection,
661
438
  DOMElement,
@@ -740,7 +517,7 @@ function printBacktickString(str) {
740
517
  }
741
518
  function ensureDirectoryExists(filePath) {
742
519
  try {
743
- fs.mkdirSync(index$1.join(index$1.dirname(filePath)), { recursive: true });
520
+ fs.mkdirSync(index.join(index.dirname(filePath)), { recursive: true });
744
521
  } catch {
745
522
  }
746
523
  }
@@ -748,7 +525,7 @@ function normalizeNewlines(string) {
748
525
  return string.replace(/\r\n|\r/g, "\n");
749
526
  }
750
527
  async function saveSnapshotFile(snapshotData, snapshotPath) {
751
- const snapshots = Object.keys(snapshotData).sort(naturalCompare$1).map((key) => `exports[${printBacktickString(key)}] = ${printBacktickString(normalizeNewlines(snapshotData[key]))};`);
528
+ const snapshots = Object.keys(snapshotData).sort(naturalCompare$1.exports).map((key) => `exports[${printBacktickString(key)}] = ${printBacktickString(normalizeNewlines(snapshotData[key]))};`);
752
529
  ensureDirectoryExists(snapshotPath);
753
530
  await promises.writeFile(snapshotPath, `${writeSnapshotVersion()}
754
531
 
@@ -911,9 +688,10 @@ var __spreadValues$2 = (a, b) => {
911
688
  return a;
912
689
  };
913
690
  class SnapshotState {
914
- constructor(snapshotPath, options) {
915
- this._snapshotPath = snapshotPath;
916
- const { data, dirty } = getSnapshotData(this._snapshotPath, options.updateSnapshot);
691
+ constructor(testFilePath, snapshotPath, options) {
692
+ this.testFilePath = testFilePath;
693
+ this.snapshotPath = snapshotPath;
694
+ const { data, dirty } = getSnapshotData(this.snapshotPath, options.updateSnapshot);
917
695
  this._initialData = data;
918
696
  this._snapshotData = data;
919
697
  this._dirty = dirty;
@@ -968,6 +746,7 @@ ${JSON.stringify(stacks)}`);
968
746
  this.matched = 0;
969
747
  this.unmatched = 0;
970
748
  this.updated = 0;
749
+ this._dirty = false;
971
750
  }
972
751
  async save() {
973
752
  const hasExternalSnapshots = Object.keys(this._snapshotData).length;
@@ -979,13 +758,13 @@ ${JSON.stringify(stacks)}`);
979
758
  };
980
759
  if ((this._dirty || this._uncheckedKeys.size) && !isEmpty) {
981
760
  if (hasExternalSnapshots)
982
- await saveSnapshotFile(this._snapshotData, this._snapshotPath);
761
+ await saveSnapshotFile(this._snapshotData, this.snapshotPath);
983
762
  if (hasInlineSnapshots)
984
763
  await saveInlineSnapshots(this._inlineSnapshots);
985
764
  status.saved = true;
986
- } else if (!hasExternalSnapshots && fs.existsSync(this._snapshotPath)) {
765
+ } else if (!hasExternalSnapshots && fs.existsSync(this.snapshotPath)) {
987
766
  if (this._updateSnapshot === "all")
988
- fs.unlinkSync(this._snapshotPath);
767
+ fs.unlinkSync(this.snapshotPath);
989
768
  status.deleted = true;
990
769
  }
991
770
  return status;
@@ -1022,7 +801,7 @@ ${JSON.stringify(stacks)}`);
1022
801
  const expectedTrimmed = prepareExpected(expected);
1023
802
  const pass = expectedTrimmed === prepareExpected(receivedSerialized);
1024
803
  const hasSnapshot = expected !== void 0;
1025
- const snapshotIsPersisted = isInline || fs.existsSync(this._snapshotPath);
804
+ const snapshotIsPersisted = isInline || fs.existsSync(this.snapshotPath);
1026
805
  if (pass && !isInline) {
1027
806
  this._snapshotData[key] = receivedSerialized;
1028
807
  }
@@ -1070,26 +849,57 @@ ${JSON.stringify(stacks)}`);
1070
849
  }
1071
850
  }
1072
851
  }
852
+ async pack() {
853
+ const snapshot = {
854
+ filepath: this.testFilePath,
855
+ added: 0,
856
+ fileDeleted: false,
857
+ matched: 0,
858
+ unchecked: 0,
859
+ uncheckedKeys: [],
860
+ unmatched: 0,
861
+ updated: 0
862
+ };
863
+ const uncheckedCount = this.getUncheckedCount();
864
+ const uncheckedKeys = this.getUncheckedKeys();
865
+ if (uncheckedCount)
866
+ this.removeUncheckedKeys();
867
+ const status = await this.save();
868
+ snapshot.fileDeleted = status.deleted;
869
+ snapshot.added = this.added;
870
+ snapshot.matched = this.matched;
871
+ snapshot.unmatched = this.unmatched;
872
+ snapshot.updated = this.updated;
873
+ snapshot.unchecked = !status.deleted ? uncheckedCount : 0;
874
+ snapshot.uncheckedKeys = Array.from(uncheckedKeys);
875
+ return snapshot;
876
+ }
1073
877
  }
1074
878
 
1075
879
  class SnapshotClient {
1076
880
  constructor() {
1077
- this.testFile = "";
881
+ this.snapshotStateMap = /* @__PURE__ */ new Map();
1078
882
  }
1079
883
  async setTest(test) {
884
+ var _a;
1080
885
  this.test = test;
1081
- if (this.testFile !== this.test.file.filepath) {
1082
- if (this.snapshotState)
1083
- this.saveSnap();
1084
- this.testFile = this.test.file.filepath;
1085
- this.snapshotState = new SnapshotState(await rpc().resolveSnapshotPath(this.testFile), getWorkerState().config.snapshotOptions);
886
+ if (((_a = this.snapshotState) == null ? void 0 : _a.testFilePath) !== this.test.file.filepath) {
887
+ this.saveCurrent();
888
+ const filePath = this.test.file.filepath;
889
+ if (!this.getSnapshotState(test)) {
890
+ this.snapshotStateMap.set(filePath, new SnapshotState(filePath, await rpc().resolveSnapshotPath(filePath), getWorkerState().config.snapshotOptions));
891
+ }
892
+ this.snapshotState = this.getSnapshotState(test);
1086
893
  }
1087
894
  }
895
+ getSnapshotState(test) {
896
+ return this.snapshotStateMap.get(test.file.filepath);
897
+ }
1088
898
  clearTest() {
1089
899
  this.test = void 0;
1090
900
  }
1091
- assert(received, message, isInline = false, properties, inlineSnapshot, error) {
1092
- if (!this.test)
901
+ assert(received, test = this.test, message, isInline = false, properties, inlineSnapshot, error) {
902
+ if (!test)
1093
903
  throw new Error("Snapshot cannot be used outside of test");
1094
904
  if (typeof properties === "object") {
1095
905
  if (typeof received !== "object" || !received)
@@ -1106,10 +916,11 @@ class SnapshotClient {
1106
916
  }
1107
917
  }
1108
918
  const testName = [
1109
- ...getNames(this.test).slice(1),
919
+ ...getNames(test).slice(1),
1110
920
  ...message ? [message] : []
1111
921
  ].join(" > ");
1112
- const { actual, expected, key, pass } = this.snapshotState.match({
922
+ const snapshotState = this.getSnapshotState(test);
923
+ const { actual, expected, key, pass } = snapshotState.match({
1113
924
  testName,
1114
925
  received,
1115
926
  isInline,
@@ -1125,39 +936,16 @@ class SnapshotClient {
1125
936
  }
1126
937
  }
1127
938
  }
1128
- async saveSnap() {
1129
- if (!this.testFile || !this.snapshotState)
939
+ async saveCurrent() {
940
+ if (!this.snapshotState)
1130
941
  return;
1131
- const result = await packSnapshotState(this.testFile, this.snapshotState);
942
+ const result = await this.snapshotState.pack();
1132
943
  await rpc().snapshotSaved(result);
1133
- this.testFile = "";
1134
944
  this.snapshotState = void 0;
1135
945
  }
1136
- }
1137
- async function packSnapshotState(filepath, state) {
1138
- const snapshot = {
1139
- filepath,
1140
- added: 0,
1141
- fileDeleted: false,
1142
- matched: 0,
1143
- unchecked: 0,
1144
- uncheckedKeys: [],
1145
- unmatched: 0,
1146
- updated: 0
1147
- };
1148
- const uncheckedCount = state.getUncheckedCount();
1149
- const uncheckedKeys = state.getUncheckedKeys();
1150
- if (uncheckedCount)
1151
- state.removeUncheckedKeys();
1152
- const status = await state.save();
1153
- snapshot.fileDeleted = status.deleted;
1154
- snapshot.added = state.added;
1155
- snapshot.matched = state.matched;
1156
- snapshot.unmatched = state.unmatched;
1157
- snapshot.updated = state.updated;
1158
- snapshot.unchecked = !status.deleted ? uncheckedCount : 0;
1159
- snapshot.uncheckedKeys = Array.from(uncheckedKeys);
1160
- return snapshot;
946
+ clear() {
947
+ this.snapshotStateMap.clear();
948
+ }
1161
949
  }
1162
950
 
1163
951
  let _client;
@@ -1180,16 +968,18 @@ const SnapshotPlugin = (chai, utils) => {
1180
968
  for (const key of ["matchSnapshot", "toMatchSnapshot"]) {
1181
969
  utils.addMethod(chai.Assertion.prototype, key, function(properties, message) {
1182
970
  const expected = utils.flag(this, "object");
971
+ const test = utils.flag(this, "vitest-test");
1183
972
  if (typeof properties === "string" && typeof message === "undefined") {
1184
973
  message = properties;
1185
974
  properties = void 0;
1186
975
  }
1187
- getSnapshotClient().assert(expected, message, false, properties);
976
+ getSnapshotClient().assert(expected, test, message, false, properties);
1188
977
  });
1189
978
  }
1190
979
  utils.addMethod(chai.Assertion.prototype, "toMatchInlineSnapshot", function __VITEST_INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
1191
980
  const expected = utils.flag(this, "object");
1192
981
  const error = utils.flag(this, "error");
982
+ const test = utils.flag(this, "vitest-test");
1193
983
  if (typeof properties === "string") {
1194
984
  message = inlineSnapshot;
1195
985
  inlineSnapshot = properties;
@@ -1197,16 +987,18 @@ const SnapshotPlugin = (chai, utils) => {
1197
987
  }
1198
988
  if (inlineSnapshot)
1199
989
  inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
1200
- getSnapshotClient().assert(expected, message, true, properties, inlineSnapshot, error);
990
+ getSnapshotClient().assert(expected, test, message, true, properties, inlineSnapshot, error);
1201
991
  });
1202
992
  utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingSnapshot", function(message) {
1203
993
  const expected = utils.flag(this, "object");
1204
- getSnapshotClient().assert(getErrorString(expected), message);
994
+ const test = utils.flag(this, "vitest-test");
995
+ getSnapshotClient().assert(getErrorString(expected), test, message);
1205
996
  });
1206
997
  utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", function __VITEST_INLINE_SNAPSHOT__(inlineSnapshot, message) {
1207
998
  const expected = utils.flag(this, "object");
1208
999
  const error = utils.flag(this, "error");
1209
- getSnapshotClient().assert(getErrorString(expected), message, true, void 0, inlineSnapshot, error);
1000
+ const test = utils.flag(this, "vitest-test");
1001
+ getSnapshotClient().assert(getErrorString(expected), test, message, true, void 0, inlineSnapshot, error);
1210
1002
  });
1211
1003
  };
1212
1004
 
@@ -1253,6 +1045,10 @@ const JestChaiExpect = (chai, utils) => {
1253
1045
  };
1254
1046
  });
1255
1047
  });
1048
+ def("withTest", function(test) {
1049
+ utils.flag(this, "vitest-test", test);
1050
+ return this;
1051
+ });
1256
1052
  def("toEqual", function(expected) {
1257
1053
  const actual = utils.flag(this, "object");
1258
1054
  const equal = equals(actual, expected, [iterableEquality]);
@@ -1392,11 +1188,11 @@ const JestChaiExpect = (chai, utils) => {
1392
1188
  return `${i}th`;
1393
1189
  };
1394
1190
  const formatCalls = (spy, msg, actualCall) => {
1395
- msg += c.gray(`
1191
+ msg += picocolors.exports.gray(`
1396
1192
 
1397
1193
  Received:
1398
1194
  ${spy.mock.calls.map((callArg, i) => {
1399
- let methodCall = c.bold(` ${ordinalOf(i + 1)} ${spy.getMockName()} call:
1195
+ let methodCall = picocolors.exports.bold(` ${ordinalOf(i + 1)} ${spy.getMockName()} call:
1400
1196
 
1401
1197
  `);
1402
1198
  if (actualCall)
@@ -1406,9 +1202,9 @@ ${spy.mock.calls.map((callArg, i) => {
1406
1202
  methodCall += "\n";
1407
1203
  return methodCall;
1408
1204
  }).join("\n")}`);
1409
- msg += c.gray(`
1205
+ msg += picocolors.exports.gray(`
1410
1206
 
1411
- Number of calls: ${c.bold(spy.mock.calls.length)}
1207
+ Number of calls: ${picocolors.exports.bold(spy.mock.calls.length)}
1412
1208
  `);
1413
1209
  return msg;
1414
1210
  };
@@ -1511,8 +1307,8 @@ Number of calls: ${c.bold(spy.mock.calls.length)}
1511
1307
  def(["toHaveReturnedTimes", "toReturnTimes"], function(times) {
1512
1308
  const spy = getSpy(this);
1513
1309
  const spyName = spy.getMockName();
1514
- const successfullReturns = spy.mock.results.reduce((success, { type }) => type === "throw" ? success : ++success, 0);
1515
- this.assert(successfullReturns === times, `expected "${spyName}" to be successfully called ${times} times`, `expected "${spyName}" to not be successfully called ${times} times`, `expected number of returns: ${times}`, `received number of returns: ${successfullReturns}`);
1310
+ const successfulReturns = spy.mock.results.reduce((success, { type }) => type === "throw" ? success : ++success, 0);
1311
+ this.assert(successfulReturns === times, `expected "${spyName}" to be successfully called ${times} times`, `expected "${spyName}" to not be successfully called ${times} times`, `expected number of returns: ${times}`, `received number of returns: ${successfulReturns}`);
1516
1312
  });
1517
1313
  def(["toHaveReturnedWith", "toReturnWith"], function(value) {
1518
1314
  const spy = getSpy(this);
@@ -1538,6 +1334,9 @@ Number of calls: ${c.bold(spy.mock.calls.length)}
1538
1334
  const nthCallReturn = equals(callResult, value);
1539
1335
  this.assert(nthCallReturn, `expected ${ordinalCall} "${spyName}" call to return #{exp}`, `expected ${ordinalCall} "${spyName}" call to not return #{exp}`, value, callResult);
1540
1336
  });
1337
+ def("toSatisfy", function() {
1338
+ return this.be.satisfy;
1339
+ });
1541
1340
  utils.addProperty(chai.Assertion.prototype, "resolves", function __VITEST_RESOLVES__() {
1542
1341
  utils.flag(this, "promise", "resolves");
1543
1342
  utils.flag(this, "error", new Error("resolves"));
@@ -1837,90 +1636,345 @@ const getMatcherState = (assertion) => {
1837
1636
  equals,
1838
1637
  suppressedErrors: []
1839
1638
  });
1840
- return {
1841
- state: matcherState,
1842
- isNot,
1843
- obj
1639
+ return {
1640
+ state: matcherState,
1641
+ isNot,
1642
+ obj
1643
+ };
1644
+ };
1645
+ class JestExtendError extends Error {
1646
+ constructor(message, actual, expected) {
1647
+ super(message);
1648
+ this.actual = actual;
1649
+ this.expected = expected;
1650
+ }
1651
+ }
1652
+ function JestExtendPlugin(expect, matchers) {
1653
+ return (c, utils) => {
1654
+ Object.entries(matchers).forEach(([expectAssertionName, expectAssertion]) => {
1655
+ function expectSyncWrapper(...args) {
1656
+ const { state, isNot, obj } = getMatcherState(this);
1657
+ const { pass, message, actual, expected } = expectAssertion.call(state, obj, ...args);
1658
+ if (pass && isNot || !pass && !isNot)
1659
+ throw new JestExtendError(message(), actual, expected);
1660
+ }
1661
+ async function expectAsyncWrapper(...args) {
1662
+ const { state, isNot, obj } = getMatcherState(this);
1663
+ const { pass, message, actual, expected } = await expectAssertion.call(state, obj, ...args);
1664
+ if (pass && isNot || !pass && !isNot)
1665
+ throw new JestExtendError(message(), actual, expected);
1666
+ }
1667
+ const expectAssertionWrapper = isAsyncFunction(expectAssertion) ? expectAsyncWrapper : expectSyncWrapper;
1668
+ utils.addMethod(c.Assertion.prototype, expectAssertionName, expectAssertionWrapper);
1669
+ class CustomMatcher extends AsymmetricMatcher {
1670
+ constructor(inverse = false, ...sample) {
1671
+ super(sample, inverse);
1672
+ }
1673
+ asymmetricMatch(other) {
1674
+ const { pass } = expectAssertion.call(this.getMatcherContext(), other, ...this.sample);
1675
+ return this.inverse ? !pass : pass;
1676
+ }
1677
+ toString() {
1678
+ return `${this.inverse ? "not." : ""}${expectAssertionName}`;
1679
+ }
1680
+ getExpectedType() {
1681
+ return "any";
1682
+ }
1683
+ toAsymmetricMatcher() {
1684
+ return `${this.toString()}<${this.sample.map(String).join(", ")}>`;
1685
+ }
1686
+ }
1687
+ Object.defineProperty(expect, expectAssertionName, {
1688
+ configurable: true,
1689
+ enumerable: true,
1690
+ value: (...sample) => new CustomMatcher(false, ...sample),
1691
+ writable: true
1692
+ });
1693
+ Object.defineProperty(expect.not, expectAssertionName, {
1694
+ configurable: true,
1695
+ enumerable: true,
1696
+ value: (...sample) => new CustomMatcher(true, ...sample),
1697
+ writable: true
1698
+ });
1699
+ });
1700
+ };
1701
+ }
1702
+ const JestExtend = (chai, utils) => {
1703
+ utils.addMethod(chai.expect, "extend", (expect, expects) => {
1704
+ chai.use(JestExtendPlugin(expect, expects));
1705
+ });
1706
+ };
1707
+
1708
+ chai$1.use(JestExtend);
1709
+ chai$1.use(JestChaiExpect);
1710
+ chai$1.use(Subset);
1711
+ chai$1.use(SnapshotPlugin);
1712
+ chai$1.use(JestAsymmetricMatchers);
1713
+
1714
+ function createExpect(test) {
1715
+ const expect2 = (value, message) => {
1716
+ const { assertionCalls } = getState();
1717
+ setState({ assertionCalls: assertionCalls + 1 });
1718
+ const assert2 = chai$1.expect(value, message);
1719
+ if (test)
1720
+ return assert2.withTest(test);
1721
+ else
1722
+ return assert2;
1723
+ };
1724
+ Object.assign(expect2, chai$1.expect);
1725
+ expect2.getState = getState;
1726
+ expect2.setState = setState;
1727
+ expect2.extend = (matchers) => chai$1.expect.extend(expect2, matchers);
1728
+ return expect2;
1729
+ }
1730
+ const expect = createExpect();
1731
+
1732
+ const collectorContext = {
1733
+ tasks: [],
1734
+ currentSuite: null
1735
+ };
1736
+ function collectTask(task) {
1737
+ var _a;
1738
+ (_a = collectorContext.currentSuite) == null ? void 0 : _a.tasks.push(task);
1739
+ }
1740
+ async function runWithSuite(suite, fn) {
1741
+ const prev = collectorContext.currentSuite;
1742
+ collectorContext.currentSuite = suite;
1743
+ await fn();
1744
+ collectorContext.currentSuite = prev;
1745
+ }
1746
+ function getDefaultTestTimeout() {
1747
+ return getWorkerState().config.testTimeout;
1748
+ }
1749
+ function getDefaultHookTimeout() {
1750
+ return getWorkerState().config.hookTimeout;
1751
+ }
1752
+ function withTimeout(fn, timeout = getDefaultTestTimeout(), isHook = false) {
1753
+ if (timeout <= 0 || timeout === Infinity)
1754
+ return fn;
1755
+ return (...args) => {
1756
+ return Promise.race([fn(...args), new Promise((resolve, reject) => {
1757
+ const timer = setTimeout(() => {
1758
+ clearTimeout(timer);
1759
+ reject(new Error(makeTimeoutMsg(isHook, timeout)));
1760
+ }, timeout);
1761
+ timer.unref();
1762
+ })]);
1763
+ };
1764
+ }
1765
+ function createTestContext(test) {
1766
+ const context = function() {
1767
+ throw new Error("done() callback is deprecated, use promise instead");
1768
+ };
1769
+ context.meta = test;
1770
+ let _expect;
1771
+ Object.defineProperty(context, "expect", {
1772
+ get() {
1773
+ if (!_expect)
1774
+ _expect = createExpect(test);
1775
+ return _expect;
1776
+ }
1777
+ });
1778
+ return context;
1779
+ }
1780
+ function makeTimeoutMsg(isHook, timeout) {
1781
+ return `${isHook ? "Hook" : "Test"} timed out in ${timeout}ms.
1782
+ If this is a long-running test, pass a timeout value as the last argument or configure it globally with "${isHook ? "hookTimeout" : "testTimeout"}".`;
1783
+ }
1784
+
1785
+ const fnMap = /* @__PURE__ */ new WeakMap();
1786
+ const hooksMap = /* @__PURE__ */ new WeakMap();
1787
+ function setFn(key, fn) {
1788
+ fnMap.set(key, fn);
1789
+ }
1790
+ function getFn(key) {
1791
+ return fnMap.get(key);
1792
+ }
1793
+ function setHooks(key, hooks) {
1794
+ hooksMap.set(key, hooks);
1795
+ }
1796
+ function getHooks(key) {
1797
+ return hooksMap.get(key);
1798
+ }
1799
+
1800
+ const suite = createSuite();
1801
+ const test = createTest(function(name, fn, timeout) {
1802
+ getCurrentSuite().test.fn.call(this, name, fn, timeout);
1803
+ });
1804
+ function formatTitle(template, items, idx) {
1805
+ if (template.includes("%#")) {
1806
+ template = template.replace(/%%/g, "__vitest_escaped_%__").replace(/%#/g, `${idx}`).replace(/__vitest_escaped_%__/g, "%%");
1807
+ }
1808
+ const count = template.split("%").length - 1;
1809
+ let formatted = format(template, ...items.slice(0, count));
1810
+ if (isObject(items[0])) {
1811
+ formatted = formatted.replace(/\$([$\w_]+)/g, (_, key) => {
1812
+ return items[0][key];
1813
+ });
1814
+ }
1815
+ return formatted;
1816
+ }
1817
+ const describe = suite;
1818
+ const it = test;
1819
+ const defaultSuite = suite("");
1820
+ function clearCollectorContext() {
1821
+ collectorContext.tasks.length = 0;
1822
+ defaultSuite.clear();
1823
+ collectorContext.currentSuite = defaultSuite;
1824
+ }
1825
+ function getCurrentSuite() {
1826
+ return collectorContext.currentSuite || defaultSuite;
1827
+ }
1828
+ function createSuiteHooks() {
1829
+ return {
1830
+ beforeAll: [],
1831
+ afterAll: [],
1832
+ beforeEach: [],
1833
+ afterEach: []
1834
+ };
1835
+ }
1836
+ function createSuiteCollector(name, factory = () => {
1837
+ }, mode, concurrent) {
1838
+ const tasks = [];
1839
+ const factoryQueue = [];
1840
+ let suite2;
1841
+ initSuite();
1842
+ const test2 = createTest(function(name2, fn = noop, timeout) {
1843
+ const mode2 = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
1844
+ const test3 = {
1845
+ id: "",
1846
+ type: "test",
1847
+ name: name2,
1848
+ mode: mode2,
1849
+ suite: void 0,
1850
+ fails: this.fails
1851
+ };
1852
+ if (this.concurrent || concurrent)
1853
+ test3.concurrent = true;
1854
+ const context = createTestContext(test3);
1855
+ Object.defineProperty(test3, "context", {
1856
+ value: context,
1857
+ enumerable: false
1858
+ });
1859
+ setFn(test3, withTimeout(() => fn(context), timeout));
1860
+ tasks.push(test3);
1861
+ });
1862
+ const collector = {
1863
+ type: "collector",
1864
+ name,
1865
+ mode,
1866
+ test: test2,
1867
+ tasks,
1868
+ collect,
1869
+ clear,
1870
+ on: addHook
1844
1871
  };
1845
- };
1846
- class JestExtendError extends Error {
1847
- constructor(message, actual, expected) {
1848
- super(message);
1849
- this.actual = actual;
1850
- this.expected = expected;
1872
+ function addHook(name2, ...fn) {
1873
+ getHooks(suite2)[name2].push(...fn);
1874
+ }
1875
+ function initSuite() {
1876
+ suite2 = {
1877
+ id: "",
1878
+ type: "suite",
1879
+ name,
1880
+ mode,
1881
+ tasks: []
1882
+ };
1883
+ setHooks(suite2, createSuiteHooks());
1884
+ }
1885
+ function clear() {
1886
+ tasks.length = 0;
1887
+ factoryQueue.length = 0;
1888
+ initSuite();
1889
+ }
1890
+ async function collect(file) {
1891
+ factoryQueue.length = 0;
1892
+ if (factory)
1893
+ await runWithSuite(collector, () => factory(test2));
1894
+ const allChildren = [];
1895
+ for (const i of [...factoryQueue, ...tasks])
1896
+ allChildren.push(i.type === "collector" ? await i.collect(file) : i);
1897
+ suite2.file = file;
1898
+ suite2.tasks = allChildren;
1899
+ allChildren.forEach((task) => {
1900
+ task.suite = suite2;
1901
+ if (file)
1902
+ task.file = file;
1903
+ });
1904
+ return suite2;
1851
1905
  }
1906
+ collectTask(collector);
1907
+ return collector;
1852
1908
  }
1853
- function JestExtendPlugin(expect, matchers) {
1854
- return (c, utils) => {
1855
- Object.entries(matchers).forEach(([expectAssertionName, expectAssertion]) => {
1856
- function expectSyncWrapper(...args) {
1857
- const { state, isNot, obj } = getMatcherState(this);
1858
- const { pass, message, actual, expected } = expectAssertion.call(state, obj, ...args);
1859
- if (pass && isNot || !pass && !isNot)
1860
- throw new JestExtendError(message(), actual, expected);
1861
- }
1862
- async function expectAsyncWrapper(...args) {
1863
- const { state, isNot, obj } = getMatcherState(this);
1864
- const { pass, message, actual, expected } = await expectAssertion.call(state, obj, ...args);
1865
- if (pass && isNot || !pass && !isNot)
1866
- throw new JestExtendError(message(), actual, expected);
1867
- }
1868
- const expectAssertionWrapper = isAsyncFunction(expectAssertion) ? expectAsyncWrapper : expectSyncWrapper;
1869
- utils.addMethod(c.Assertion.prototype, expectAssertionName, expectAssertionWrapper);
1870
- class CustomMatcher extends AsymmetricMatcher {
1871
- constructor(inverse = false, ...sample) {
1872
- super(sample, inverse);
1873
- }
1874
- asymmetricMatch(other) {
1875
- const { pass } = expectAssertion.call(this.getMatcherContext(), other, ...this.sample);
1876
- return this.inverse ? !pass : pass;
1877
- }
1878
- toString() {
1879
- return `${this.inverse ? "not." : ""}${expectAssertionName}`;
1880
- }
1881
- getExpectedType() {
1882
- return "any";
1883
- }
1884
- toAsymmetricMatcher() {
1885
- return `${this.toString()}<${this.sample.map(String).join(", ")}>`;
1886
- }
1887
- }
1888
- Object.defineProperty(expect, expectAssertionName, {
1889
- configurable: true,
1890
- enumerable: true,
1891
- value: (...sample) => new CustomMatcher(false, ...sample),
1892
- writable: true
1909
+ function createSuite() {
1910
+ const suite2 = createChainable(["concurrent", "skip", "only", "todo"], function(name, factory) {
1911
+ const mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
1912
+ return createSuiteCollector(name, factory, mode, this.concurrent);
1913
+ });
1914
+ suite2.each = (cases) => {
1915
+ return (name, fn) => {
1916
+ cases.forEach((i, idx) => {
1917
+ const items = toArray(i);
1918
+ suite2(formatTitle(name, items, idx), () => fn(...items));
1893
1919
  });
1894
- Object.defineProperty(expect.not, expectAssertionName, {
1895
- configurable: true,
1896
- enumerable: true,
1897
- value: (...sample) => new CustomMatcher(true, ...sample),
1898
- writable: true
1920
+ };
1921
+ };
1922
+ suite2.skipIf = (condition) => condition ? suite2.skip : suite2;
1923
+ suite2.runIf = (condition) => condition ? suite2 : suite2.skip;
1924
+ return suite2;
1925
+ }
1926
+ function createTest(fn) {
1927
+ const test2 = createChainable(["concurrent", "skip", "only", "todo", "fails"], fn);
1928
+ test2.each = (cases) => {
1929
+ return (name, fn2) => {
1930
+ cases.forEach((i, idx) => {
1931
+ const items = toArray(i);
1932
+ test2(formatTitle(name, items, idx), () => fn2(...items));
1899
1933
  });
1900
- });
1934
+ };
1901
1935
  };
1936
+ test2.skipIf = (condition) => condition ? test2.skip : test2;
1937
+ test2.runIf = (condition) => condition ? test2 : test2.skip;
1938
+ return test2;
1902
1939
  }
1903
- const JestExtend = (chai, utils) => {
1904
- utils.addMethod(chai.expect, "extend", (expect, expects) => {
1905
- chai.use(JestExtendPlugin(expect, expects));
1906
- });
1907
- };
1908
1940
 
1909
- chai$1.use(JestExtend);
1910
- chai$1.use(JestChaiExpect);
1911
- chai$1.use(Subset);
1912
- chai$1.use(SnapshotPlugin);
1913
- chai$1.use(JestAsymmetricMatchers);
1941
+ const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
1942
+ const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
1943
+ const beforeEach = (fn, timeout) => getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
1944
+ const afterEach = (fn, timeout) => getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true));
1914
1945
 
1915
- const expect = (value, message) => {
1916
- const { assertionCalls } = getState();
1917
- setState({ assertionCalls: assertionCalls + 1 });
1918
- return chai$1.expect(value, message);
1919
- };
1920
- Object.assign(expect, chai$1.expect);
1921
- expect.getState = getState;
1922
- expect.setState = setState;
1923
- expect.extend = (matchers) => chai$1.expect.extend(expect, matchers);
1946
+ function withCallback(fn) {
1947
+ return new Promise((resolve, reject) => fn((err) => {
1948
+ if (err)
1949
+ reject(err);
1950
+ else
1951
+ resolve();
1952
+ }));
1953
+ }
1954
+
1955
+ const filesCount = /* @__PURE__ */ new Map();
1956
+ const cache = /* @__PURE__ */ new Map();
1957
+ function runOnce(fn, key) {
1958
+ const filepath = getWorkerState().filepath || "__unknown_files__";
1959
+ if (!key) {
1960
+ filesCount.set(filepath, (filesCount.get(filepath) || 0) + 1);
1961
+ key = String(filesCount.get(filepath));
1962
+ }
1963
+ const id = `${filepath}:${key}`;
1964
+ if (!cache.has(id))
1965
+ cache.set(id, fn());
1966
+ return cache.get(id);
1967
+ }
1968
+ function isFirstRun() {
1969
+ let firstRun = false;
1970
+ runOnce(() => {
1971
+ firstRun = true;
1972
+ }, "__vitest_first_run__");
1973
+ return firstRun;
1974
+ }
1975
+ function resetRunOnceCounter() {
1976
+ filesCount.clear();
1977
+ }
1924
1978
 
1925
1979
  /**
1926
1980
  * A reference to the global object
@@ -2083,62 +2137,62 @@ var deprecated = {};
2083
2137
 
2084
2138
  (function (exports) {
2085
2139
 
2086
- /**
2087
- * Returns a function that will invoke the supplied function and print a
2088
- * deprecation warning to the console each time it is called.
2089
- *
2090
- * @param {Function} func
2091
- * @param {string} msg
2092
- * @returns {Function}
2093
- */
2094
- exports.wrap = function(func, msg) {
2095
- var wrapped = function() {
2096
- exports.printWarning(msg);
2097
- return func.apply(this, arguments);
2098
- };
2099
- if (func.prototype) {
2100
- wrapped.prototype = func.prototype;
2101
- }
2102
- return wrapped;
2103
- };
2104
-
2105
- /**
2106
- * Returns a string which can be supplied to `wrap()` to notify the user that a
2107
- * particular part of the sinon API has been deprecated.
2108
- *
2109
- * @param {string} packageName
2110
- * @param {string} funcName
2111
- * @returns {string}
2112
- */
2113
- exports.defaultMsg = function(packageName, funcName) {
2114
- return (
2115
- packageName +
2116
- "." +
2117
- funcName +
2118
- " is deprecated and will be removed from the public API in a future version of " +
2119
- packageName +
2120
- "."
2121
- );
2122
- };
2123
-
2124
- /**
2125
- * Prints a warning on the console, when it exists
2126
- *
2127
- * @param {string} msg
2128
- * @returns {undefined}
2129
- */
2130
- exports.printWarning = function(msg) {
2131
- /* istanbul ignore next */
2132
- if (typeof process === "object" && process.emitWarning) {
2133
- // Emit Warnings in Node
2134
- process.emitWarning(msg);
2135
- } else if (console.info) {
2136
- console.info(msg);
2137
- } else {
2138
- console.log(msg);
2139
- }
2140
- };
2141
- }(deprecated));
2140
+ /**
2141
+ * Returns a function that will invoke the supplied function and print a
2142
+ * deprecation warning to the console each time it is called.
2143
+ *
2144
+ * @param {Function} func
2145
+ * @param {string} msg
2146
+ * @returns {Function}
2147
+ */
2148
+ exports.wrap = function(func, msg) {
2149
+ var wrapped = function() {
2150
+ exports.printWarning(msg);
2151
+ return func.apply(this, arguments);
2152
+ };
2153
+ if (func.prototype) {
2154
+ wrapped.prototype = func.prototype;
2155
+ }
2156
+ return wrapped;
2157
+ };
2158
+
2159
+ /**
2160
+ * Returns a string which can be supplied to `wrap()` to notify the user that a
2161
+ * particular part of the sinon API has been deprecated.
2162
+ *
2163
+ * @param {string} packageName
2164
+ * @param {string} funcName
2165
+ * @returns {string}
2166
+ */
2167
+ exports.defaultMsg = function(packageName, funcName) {
2168
+ return (
2169
+ packageName +
2170
+ "." +
2171
+ funcName +
2172
+ " is deprecated and will be removed from the public API in a future version of " +
2173
+ packageName +
2174
+ "."
2175
+ );
2176
+ };
2177
+
2178
+ /**
2179
+ * Prints a warning on the console, when it exists
2180
+ *
2181
+ * @param {string} msg
2182
+ * @returns {undefined}
2183
+ */
2184
+ exports.printWarning = function(msg) {
2185
+ /* istanbul ignore next */
2186
+ if (typeof process === "object" && process.emitWarning) {
2187
+ // Emit Warnings in Node
2188
+ process.emitWarning(msg);
2189
+ } else if (console.info) {
2190
+ console.info(msg);
2191
+ } else {
2192
+ console.log(msg);
2193
+ }
2194
+ };
2195
+ } (deprecated));
2142
2196
 
2143
2197
  /**
2144
2198
  * Returns true when fn returns true for all members of obj.
@@ -2233,392 +2287,392 @@ var prototypes = {
2233
2287
  var typeDetect = {exports: {}};
2234
2288
 
2235
2289
  (function (module, exports) {
2236
- (function (global, factory) {
2237
- module.exports = factory() ;
2238
- }(commonjsGlobal, (function () {
2239
- /* !
2240
- * type-detect
2241
- * Copyright(c) 2013 jake luer <jake@alogicalparadox.com>
2242
- * MIT Licensed
2243
- */
2244
- var promiseExists = typeof Promise === 'function';
2245
-
2246
- /* eslint-disable no-undef */
2247
- var globalObject = typeof self === 'object' ? self : commonjsGlobal; // eslint-disable-line id-blacklist
2248
-
2249
- var symbolExists = typeof Symbol !== 'undefined';
2250
- var mapExists = typeof Map !== 'undefined';
2251
- var setExists = typeof Set !== 'undefined';
2252
- var weakMapExists = typeof WeakMap !== 'undefined';
2253
- var weakSetExists = typeof WeakSet !== 'undefined';
2254
- var dataViewExists = typeof DataView !== 'undefined';
2255
- var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== 'undefined';
2256
- var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== 'undefined';
2257
- var setEntriesExists = setExists && typeof Set.prototype.entries === 'function';
2258
- var mapEntriesExists = mapExists && typeof Map.prototype.entries === 'function';
2259
- var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf(new Set().entries());
2260
- var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf(new Map().entries());
2261
- var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function';
2262
- var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
2263
- var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === 'function';
2264
- var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]());
2265
- var toStringLeftSliceLength = 8;
2266
- var toStringRightSliceLength = -1;
2267
- /**
2268
- * ### typeOf (obj)
2269
- *
2270
- * Uses `Object.prototype.toString` to determine the type of an object,
2271
- * normalising behaviour across engine versions & well optimised.
2272
- *
2273
- * @param {Mixed} object
2274
- * @return {String} object type
2275
- * @api public
2276
- */
2277
- function typeDetect(obj) {
2278
- /* ! Speed optimisation
2279
- * Pre:
2280
- * string literal x 3,039,035 ops/sec ±1.62% (78 runs sampled)
2281
- * boolean literal x 1,424,138 ops/sec ±4.54% (75 runs sampled)
2282
- * number literal x 1,653,153 ops/sec ±1.91% (82 runs sampled)
2283
- * undefined x 9,978,660 ops/sec ±1.92% (75 runs sampled)
2284
- * function x 2,556,769 ops/sec ±1.73% (77 runs sampled)
2285
- * Post:
2286
- * string literal x 38,564,796 ops/sec ±1.15% (79 runs sampled)
2287
- * boolean literal x 31,148,940 ops/sec ±1.10% (79 runs sampled)
2288
- * number literal x 32,679,330 ops/sec ±1.90% (78 runs sampled)
2289
- * undefined x 32,363,368 ops/sec ±1.07% (82 runs sampled)
2290
- * function x 31,296,870 ops/sec ±0.96% (83 runs sampled)
2291
- */
2292
- var typeofObj = typeof obj;
2293
- if (typeofObj !== 'object') {
2294
- return typeofObj;
2295
- }
2296
-
2297
- /* ! Speed optimisation
2298
- * Pre:
2299
- * null x 28,645,765 ops/sec ±1.17% (82 runs sampled)
2300
- * Post:
2301
- * null x 36,428,962 ops/sec ±1.37% (84 runs sampled)
2302
- */
2303
- if (obj === null) {
2304
- return 'null';
2305
- }
2306
-
2307
- /* ! Spec Conformance
2308
- * Test: `Object.prototype.toString.call(window)``
2309
- * - Node === "[object global]"
2310
- * - Chrome === "[object global]"
2311
- * - Firefox === "[object Window]"
2312
- * - PhantomJS === "[object Window]"
2313
- * - Safari === "[object Window]"
2314
- * - IE 11 === "[object Window]"
2315
- * - IE Edge === "[object Window]"
2316
- * Test: `Object.prototype.toString.call(this)``
2317
- * - Chrome Worker === "[object global]"
2318
- * - Firefox Worker === "[object DedicatedWorkerGlobalScope]"
2319
- * - Safari Worker === "[object DedicatedWorkerGlobalScope]"
2320
- * - IE 11 Worker === "[object WorkerGlobalScope]"
2321
- * - IE Edge Worker === "[object WorkerGlobalScope]"
2322
- */
2323
- if (obj === globalObject) {
2324
- return 'global';
2325
- }
2326
-
2327
- /* ! Speed optimisation
2328
- * Pre:
2329
- * array literal x 2,888,352 ops/sec ±0.67% (82 runs sampled)
2330
- * Post:
2331
- * array literal x 22,479,650 ops/sec ±0.96% (81 runs sampled)
2332
- */
2333
- if (
2334
- Array.isArray(obj) &&
2335
- (symbolToStringTagExists === false || !(Symbol.toStringTag in obj))
2336
- ) {
2337
- return 'Array';
2338
- }
2339
-
2340
- // Not caching existence of `window` and related properties due to potential
2341
- // for `window` to be unset before tests in quasi-browser environments.
2342
- if (typeof window === 'object' && window !== null) {
2343
- /* ! Spec Conformance
2344
- * (https://html.spec.whatwg.org/multipage/browsers.html#location)
2345
- * WhatWG HTML$7.7.3 - The `Location` interface
2346
- * Test: `Object.prototype.toString.call(window.location)``
2347
- * - IE <=11 === "[object Object]"
2348
- * - IE Edge <=13 === "[object Object]"
2349
- */
2350
- if (typeof window.location === 'object' && obj === window.location) {
2351
- return 'Location';
2352
- }
2353
-
2354
- /* ! Spec Conformance
2355
- * (https://html.spec.whatwg.org/#document)
2356
- * WhatWG HTML$3.1.1 - The `Document` object
2357
- * Note: Most browsers currently adher to the W3C DOM Level 2 spec
2358
- * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268)
2359
- * which suggests that browsers should use HTMLTableCellElement for
2360
- * both TD and TH elements. WhatWG separates these.
2361
- * WhatWG HTML states:
2362
- * > For historical reasons, Window objects must also have a
2363
- * > writable, configurable, non-enumerable property named
2364
- * > HTMLDocument whose value is the Document interface object.
2365
- * Test: `Object.prototype.toString.call(document)``
2366
- * - Chrome === "[object HTMLDocument]"
2367
- * - Firefox === "[object HTMLDocument]"
2368
- * - Safari === "[object HTMLDocument]"
2369
- * - IE <=10 === "[object Document]"
2370
- * - IE 11 === "[object HTMLDocument]"
2371
- * - IE Edge <=13 === "[object HTMLDocument]"
2372
- */
2373
- if (typeof window.document === 'object' && obj === window.document) {
2374
- return 'Document';
2375
- }
2376
-
2377
- if (typeof window.navigator === 'object') {
2378
- /* ! Spec Conformance
2379
- * (https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray)
2380
- * WhatWG HTML$8.6.1.5 - Plugins - Interface MimeTypeArray
2381
- * Test: `Object.prototype.toString.call(navigator.mimeTypes)``
2382
- * - IE <=10 === "[object MSMimeTypesCollection]"
2383
- */
2384
- if (typeof window.navigator.mimeTypes === 'object' &&
2385
- obj === window.navigator.mimeTypes) {
2386
- return 'MimeTypeArray';
2387
- }
2388
-
2389
- /* ! Spec Conformance
2390
- * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
2391
- * WhatWG HTML$8.6.1.5 - Plugins - Interface PluginArray
2392
- * Test: `Object.prototype.toString.call(navigator.plugins)``
2393
- * - IE <=10 === "[object MSPluginsCollection]"
2394
- */
2395
- if (typeof window.navigator.plugins === 'object' &&
2396
- obj === window.navigator.plugins) {
2397
- return 'PluginArray';
2398
- }
2399
- }
2400
-
2401
- if ((typeof window.HTMLElement === 'function' ||
2402
- typeof window.HTMLElement === 'object') &&
2403
- obj instanceof window.HTMLElement) {
2404
- /* ! Spec Conformance
2405
- * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
2406
- * WhatWG HTML$4.4.4 - The `blockquote` element - Interface `HTMLQuoteElement`
2407
- * Test: `Object.prototype.toString.call(document.createElement('blockquote'))``
2408
- * - IE <=10 === "[object HTMLBlockElement]"
2409
- */
2410
- if (obj.tagName === 'BLOCKQUOTE') {
2411
- return 'HTMLQuoteElement';
2412
- }
2413
-
2414
- /* ! Spec Conformance
2415
- * (https://html.spec.whatwg.org/#htmltabledatacellelement)
2416
- * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableDataCellElement`
2417
- * Note: Most browsers currently adher to the W3C DOM Level 2 spec
2418
- * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
2419
- * which suggests that browsers should use HTMLTableCellElement for
2420
- * both TD and TH elements. WhatWG separates these.
2421
- * Test: Object.prototype.toString.call(document.createElement('td'))
2422
- * - Chrome === "[object HTMLTableCellElement]"
2423
- * - Firefox === "[object HTMLTableCellElement]"
2424
- * - Safari === "[object HTMLTableCellElement]"
2425
- */
2426
- if (obj.tagName === 'TD') {
2427
- return 'HTMLTableDataCellElement';
2428
- }
2429
-
2430
- /* ! Spec Conformance
2431
- * (https://html.spec.whatwg.org/#htmltableheadercellelement)
2432
- * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableHeaderCellElement`
2433
- * Note: Most browsers currently adher to the W3C DOM Level 2 spec
2434
- * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
2435
- * which suggests that browsers should use HTMLTableCellElement for
2436
- * both TD and TH elements. WhatWG separates these.
2437
- * Test: Object.prototype.toString.call(document.createElement('th'))
2438
- * - Chrome === "[object HTMLTableCellElement]"
2439
- * - Firefox === "[object HTMLTableCellElement]"
2440
- * - Safari === "[object HTMLTableCellElement]"
2441
- */
2442
- if (obj.tagName === 'TH') {
2443
- return 'HTMLTableHeaderCellElement';
2444
- }
2445
- }
2446
- }
2447
-
2448
- /* ! Speed optimisation
2449
- * Pre:
2450
- * Float64Array x 625,644 ops/sec ±1.58% (80 runs sampled)
2451
- * Float32Array x 1,279,852 ops/sec ±2.91% (77 runs sampled)
2452
- * Uint32Array x 1,178,185 ops/sec ±1.95% (83 runs sampled)
2453
- * Uint16Array x 1,008,380 ops/sec ±2.25% (80 runs sampled)
2454
- * Uint8Array x 1,128,040 ops/sec ±2.11% (81 runs sampled)
2455
- * Int32Array x 1,170,119 ops/sec ±2.88% (80 runs sampled)
2456
- * Int16Array x 1,176,348 ops/sec ±5.79% (86 runs sampled)
2457
- * Int8Array x 1,058,707 ops/sec ±4.94% (77 runs sampled)
2458
- * Uint8ClampedArray x 1,110,633 ops/sec ±4.20% (80 runs sampled)
2459
- * Post:
2460
- * Float64Array x 7,105,671 ops/sec ±13.47% (64 runs sampled)
2461
- * Float32Array x 5,887,912 ops/sec ±1.46% (82 runs sampled)
2462
- * Uint32Array x 6,491,661 ops/sec ±1.76% (79 runs sampled)
2463
- * Uint16Array x 6,559,795 ops/sec ±1.67% (82 runs sampled)
2464
- * Uint8Array x 6,463,966 ops/sec ±1.43% (85 runs sampled)
2465
- * Int32Array x 5,641,841 ops/sec ±3.49% (81 runs sampled)
2466
- * Int16Array x 6,583,511 ops/sec ±1.98% (80 runs sampled)
2467
- * Int8Array x 6,606,078 ops/sec ±1.74% (81 runs sampled)
2468
- * Uint8ClampedArray x 6,602,224 ops/sec ±1.77% (83 runs sampled)
2469
- */
2470
- var stringTag = (symbolToStringTagExists && obj[Symbol.toStringTag]);
2471
- if (typeof stringTag === 'string') {
2472
- return stringTag;
2473
- }
2474
-
2475
- var objPrototype = Object.getPrototypeOf(obj);
2476
- /* ! Speed optimisation
2477
- * Pre:
2478
- * regex literal x 1,772,385 ops/sec ±1.85% (77 runs sampled)
2479
- * regex constructor x 2,143,634 ops/sec ±2.46% (78 runs sampled)
2480
- * Post:
2481
- * regex literal x 3,928,009 ops/sec ±0.65% (78 runs sampled)
2482
- * regex constructor x 3,931,108 ops/sec ±0.58% (84 runs sampled)
2483
- */
2484
- if (objPrototype === RegExp.prototype) {
2485
- return 'RegExp';
2486
- }
2487
-
2488
- /* ! Speed optimisation
2489
- * Pre:
2490
- * date x 2,130,074 ops/sec ±4.42% (68 runs sampled)
2491
- * Post:
2492
- * date x 3,953,779 ops/sec ±1.35% (77 runs sampled)
2493
- */
2494
- if (objPrototype === Date.prototype) {
2495
- return 'Date';
2496
- }
2497
-
2498
- /* ! Spec Conformance
2499
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag)
2500
- * ES6$25.4.5.4 - Promise.prototype[@@toStringTag] should be "Promise":
2501
- * Test: `Object.prototype.toString.call(Promise.resolve())``
2502
- * - Chrome <=47 === "[object Object]"
2503
- * - Edge <=20 === "[object Object]"
2504
- * - Firefox 29-Latest === "[object Promise]"
2505
- * - Safari 7.1-Latest === "[object Promise]"
2506
- */
2507
- if (promiseExists && objPrototype === Promise.prototype) {
2508
- return 'Promise';
2509
- }
2510
-
2511
- /* ! Speed optimisation
2512
- * Pre:
2513
- * set x 2,222,186 ops/sec ±1.31% (82 runs sampled)
2514
- * Post:
2515
- * set x 4,545,879 ops/sec ±1.13% (83 runs sampled)
2516
- */
2517
- if (setExists && objPrototype === Set.prototype) {
2518
- return 'Set';
2519
- }
2520
-
2521
- /* ! Speed optimisation
2522
- * Pre:
2523
- * map x 2,396,842 ops/sec ±1.59% (81 runs sampled)
2524
- * Post:
2525
- * map x 4,183,945 ops/sec ±6.59% (82 runs sampled)
2526
- */
2527
- if (mapExists && objPrototype === Map.prototype) {
2528
- return 'Map';
2529
- }
2530
-
2531
- /* ! Speed optimisation
2532
- * Pre:
2533
- * weakset x 1,323,220 ops/sec ±2.17% (76 runs sampled)
2534
- * Post:
2535
- * weakset x 4,237,510 ops/sec ±2.01% (77 runs sampled)
2536
- */
2537
- if (weakSetExists && objPrototype === WeakSet.prototype) {
2538
- return 'WeakSet';
2539
- }
2540
-
2541
- /* ! Speed optimisation
2542
- * Pre:
2543
- * weakmap x 1,500,260 ops/sec ±2.02% (78 runs sampled)
2544
- * Post:
2545
- * weakmap x 3,881,384 ops/sec ±1.45% (82 runs sampled)
2546
- */
2547
- if (weakMapExists && objPrototype === WeakMap.prototype) {
2548
- return 'WeakMap';
2549
- }
2550
-
2551
- /* ! Spec Conformance
2552
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag)
2553
- * ES6$24.2.4.21 - DataView.prototype[@@toStringTag] should be "DataView":
2554
- * Test: `Object.prototype.toString.call(new DataView(new ArrayBuffer(1)))``
2555
- * - Edge <=13 === "[object Object]"
2556
- */
2557
- if (dataViewExists && objPrototype === DataView.prototype) {
2558
- return 'DataView';
2559
- }
2560
-
2561
- /* ! Spec Conformance
2562
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag)
2563
- * ES6$23.1.5.2.2 - %MapIteratorPrototype%[@@toStringTag] should be "Map Iterator":
2564
- * Test: `Object.prototype.toString.call(new Map().entries())``
2565
- * - Edge <=13 === "[object Object]"
2566
- */
2567
- if (mapExists && objPrototype === mapIteratorPrototype) {
2568
- return 'Map Iterator';
2569
- }
2570
-
2571
- /* ! Spec Conformance
2572
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag)
2573
- * ES6$23.2.5.2.2 - %SetIteratorPrototype%[@@toStringTag] should be "Set Iterator":
2574
- * Test: `Object.prototype.toString.call(new Set().entries())``
2575
- * - Edge <=13 === "[object Object]"
2576
- */
2577
- if (setExists && objPrototype === setIteratorPrototype) {
2578
- return 'Set Iterator';
2579
- }
2580
-
2581
- /* ! Spec Conformance
2582
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag)
2583
- * ES6$22.1.5.2.2 - %ArrayIteratorPrototype%[@@toStringTag] should be "Array Iterator":
2584
- * Test: `Object.prototype.toString.call([][Symbol.iterator]())``
2585
- * - Edge <=13 === "[object Object]"
2586
- */
2587
- if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
2588
- return 'Array Iterator';
2589
- }
2590
-
2591
- /* ! Spec Conformance
2592
- * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag)
2593
- * ES6$21.1.5.2.2 - %StringIteratorPrototype%[@@toStringTag] should be "String Iterator":
2594
- * Test: `Object.prototype.toString.call(''[Symbol.iterator]())``
2595
- * - Edge <=13 === "[object Object]"
2596
- */
2597
- if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
2598
- return 'String Iterator';
2599
- }
2600
-
2601
- /* ! Speed optimisation
2602
- * Pre:
2603
- * object from null x 2,424,320 ops/sec ±1.67% (76 runs sampled)
2604
- * Post:
2605
- * object from null x 5,838,000 ops/sec ±0.99% (84 runs sampled)
2606
- */
2607
- if (objPrototype === null) {
2608
- return 'Object';
2609
- }
2610
-
2611
- return Object
2612
- .prototype
2613
- .toString
2614
- .call(obj)
2615
- .slice(toStringLeftSliceLength, toStringRightSliceLength);
2616
- }
2290
+ (function (global, factory) {
2291
+ module.exports = factory() ;
2292
+ }(commonjsGlobal, (function () {
2293
+ /* !
2294
+ * type-detect
2295
+ * Copyright(c) 2013 jake luer <jake@alogicalparadox.com>
2296
+ * MIT Licensed
2297
+ */
2298
+ var promiseExists = typeof Promise === 'function';
2299
+
2300
+ /* eslint-disable no-undef */
2301
+ var globalObject = typeof self === 'object' ? self : commonjsGlobal; // eslint-disable-line id-blacklist
2302
+
2303
+ var symbolExists = typeof Symbol !== 'undefined';
2304
+ var mapExists = typeof Map !== 'undefined';
2305
+ var setExists = typeof Set !== 'undefined';
2306
+ var weakMapExists = typeof WeakMap !== 'undefined';
2307
+ var weakSetExists = typeof WeakSet !== 'undefined';
2308
+ var dataViewExists = typeof DataView !== 'undefined';
2309
+ var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== 'undefined';
2310
+ var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== 'undefined';
2311
+ var setEntriesExists = setExists && typeof Set.prototype.entries === 'function';
2312
+ var mapEntriesExists = mapExists && typeof Map.prototype.entries === 'function';
2313
+ var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf(new Set().entries());
2314
+ var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf(new Map().entries());
2315
+ var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === 'function';
2316
+ var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
2317
+ var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === 'function';
2318
+ var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]());
2319
+ var toStringLeftSliceLength = 8;
2320
+ var toStringRightSliceLength = -1;
2321
+ /**
2322
+ * ### typeOf (obj)
2323
+ *
2324
+ * Uses `Object.prototype.toString` to determine the type of an object,
2325
+ * normalising behaviour across engine versions & well optimised.
2326
+ *
2327
+ * @param {Mixed} object
2328
+ * @return {String} object type
2329
+ * @api public
2330
+ */
2331
+ function typeDetect(obj) {
2332
+ /* ! Speed optimisation
2333
+ * Pre:
2334
+ * string literal x 3,039,035 ops/sec ±1.62% (78 runs sampled)
2335
+ * boolean literal x 1,424,138 ops/sec ±4.54% (75 runs sampled)
2336
+ * number literal x 1,653,153 ops/sec ±1.91% (82 runs sampled)
2337
+ * undefined x 9,978,660 ops/sec ±1.92% (75 runs sampled)
2338
+ * function x 2,556,769 ops/sec ±1.73% (77 runs sampled)
2339
+ * Post:
2340
+ * string literal x 38,564,796 ops/sec ±1.15% (79 runs sampled)
2341
+ * boolean literal x 31,148,940 ops/sec ±1.10% (79 runs sampled)
2342
+ * number literal x 32,679,330 ops/sec ±1.90% (78 runs sampled)
2343
+ * undefined x 32,363,368 ops/sec ±1.07% (82 runs sampled)
2344
+ * function x 31,296,870 ops/sec ±0.96% (83 runs sampled)
2345
+ */
2346
+ var typeofObj = typeof obj;
2347
+ if (typeofObj !== 'object') {
2348
+ return typeofObj;
2349
+ }
2350
+
2351
+ /* ! Speed optimisation
2352
+ * Pre:
2353
+ * null x 28,645,765 ops/sec ±1.17% (82 runs sampled)
2354
+ * Post:
2355
+ * null x 36,428,962 ops/sec ±1.37% (84 runs sampled)
2356
+ */
2357
+ if (obj === null) {
2358
+ return 'null';
2359
+ }
2360
+
2361
+ /* ! Spec Conformance
2362
+ * Test: `Object.prototype.toString.call(window)``
2363
+ * - Node === "[object global]"
2364
+ * - Chrome === "[object global]"
2365
+ * - Firefox === "[object Window]"
2366
+ * - PhantomJS === "[object Window]"
2367
+ * - Safari === "[object Window]"
2368
+ * - IE 11 === "[object Window]"
2369
+ * - IE Edge === "[object Window]"
2370
+ * Test: `Object.prototype.toString.call(this)``
2371
+ * - Chrome Worker === "[object global]"
2372
+ * - Firefox Worker === "[object DedicatedWorkerGlobalScope]"
2373
+ * - Safari Worker === "[object DedicatedWorkerGlobalScope]"
2374
+ * - IE 11 Worker === "[object WorkerGlobalScope]"
2375
+ * - IE Edge Worker === "[object WorkerGlobalScope]"
2376
+ */
2377
+ if (obj === globalObject) {
2378
+ return 'global';
2379
+ }
2380
+
2381
+ /* ! Speed optimisation
2382
+ * Pre:
2383
+ * array literal x 2,888,352 ops/sec ±0.67% (82 runs sampled)
2384
+ * Post:
2385
+ * array literal x 22,479,650 ops/sec ±0.96% (81 runs sampled)
2386
+ */
2387
+ if (
2388
+ Array.isArray(obj) &&
2389
+ (symbolToStringTagExists === false || !(Symbol.toStringTag in obj))
2390
+ ) {
2391
+ return 'Array';
2392
+ }
2393
+
2394
+ // Not caching existence of `window` and related properties due to potential
2395
+ // for `window` to be unset before tests in quasi-browser environments.
2396
+ if (typeof window === 'object' && window !== null) {
2397
+ /* ! Spec Conformance
2398
+ * (https://html.spec.whatwg.org/multipage/browsers.html#location)
2399
+ * WhatWG HTML$7.7.3 - The `Location` interface
2400
+ * Test: `Object.prototype.toString.call(window.location)``
2401
+ * - IE <=11 === "[object Object]"
2402
+ * - IE Edge <=13 === "[object Object]"
2403
+ */
2404
+ if (typeof window.location === 'object' && obj === window.location) {
2405
+ return 'Location';
2406
+ }
2407
+
2408
+ /* ! Spec Conformance
2409
+ * (https://html.spec.whatwg.org/#document)
2410
+ * WhatWG HTML$3.1.1 - The `Document` object
2411
+ * Note: Most browsers currently adher to the W3C DOM Level 2 spec
2412
+ * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-26809268)
2413
+ * which suggests that browsers should use HTMLTableCellElement for
2414
+ * both TD and TH elements. WhatWG separates these.
2415
+ * WhatWG HTML states:
2416
+ * > For historical reasons, Window objects must also have a
2417
+ * > writable, configurable, non-enumerable property named
2418
+ * > HTMLDocument whose value is the Document interface object.
2419
+ * Test: `Object.prototype.toString.call(document)``
2420
+ * - Chrome === "[object HTMLDocument]"
2421
+ * - Firefox === "[object HTMLDocument]"
2422
+ * - Safari === "[object HTMLDocument]"
2423
+ * - IE <=10 === "[object Document]"
2424
+ * - IE 11 === "[object HTMLDocument]"
2425
+ * - IE Edge <=13 === "[object HTMLDocument]"
2426
+ */
2427
+ if (typeof window.document === 'object' && obj === window.document) {
2428
+ return 'Document';
2429
+ }
2430
+
2431
+ if (typeof window.navigator === 'object') {
2432
+ /* ! Spec Conformance
2433
+ * (https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray)
2434
+ * WhatWG HTML$8.6.1.5 - Plugins - Interface MimeTypeArray
2435
+ * Test: `Object.prototype.toString.call(navigator.mimeTypes)``
2436
+ * - IE <=10 === "[object MSMimeTypesCollection]"
2437
+ */
2438
+ if (typeof window.navigator.mimeTypes === 'object' &&
2439
+ obj === window.navigator.mimeTypes) {
2440
+ return 'MimeTypeArray';
2441
+ }
2442
+
2443
+ /* ! Spec Conformance
2444
+ * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
2445
+ * WhatWG HTML$8.6.1.5 - Plugins - Interface PluginArray
2446
+ * Test: `Object.prototype.toString.call(navigator.plugins)``
2447
+ * - IE <=10 === "[object MSPluginsCollection]"
2448
+ */
2449
+ if (typeof window.navigator.plugins === 'object' &&
2450
+ obj === window.navigator.plugins) {
2451
+ return 'PluginArray';
2452
+ }
2453
+ }
2454
+
2455
+ if ((typeof window.HTMLElement === 'function' ||
2456
+ typeof window.HTMLElement === 'object') &&
2457
+ obj instanceof window.HTMLElement) {
2458
+ /* ! Spec Conformance
2459
+ * (https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray)
2460
+ * WhatWG HTML$4.4.4 - The `blockquote` element - Interface `HTMLQuoteElement`
2461
+ * Test: `Object.prototype.toString.call(document.createElement('blockquote'))``
2462
+ * - IE <=10 === "[object HTMLBlockElement]"
2463
+ */
2464
+ if (obj.tagName === 'BLOCKQUOTE') {
2465
+ return 'HTMLQuoteElement';
2466
+ }
2467
+
2468
+ /* ! Spec Conformance
2469
+ * (https://html.spec.whatwg.org/#htmltabledatacellelement)
2470
+ * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableDataCellElement`
2471
+ * Note: Most browsers currently adher to the W3C DOM Level 2 spec
2472
+ * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
2473
+ * which suggests that browsers should use HTMLTableCellElement for
2474
+ * both TD and TH elements. WhatWG separates these.
2475
+ * Test: Object.prototype.toString.call(document.createElement('td'))
2476
+ * - Chrome === "[object HTMLTableCellElement]"
2477
+ * - Firefox === "[object HTMLTableCellElement]"
2478
+ * - Safari === "[object HTMLTableCellElement]"
2479
+ */
2480
+ if (obj.tagName === 'TD') {
2481
+ return 'HTMLTableDataCellElement';
2482
+ }
2483
+
2484
+ /* ! Spec Conformance
2485
+ * (https://html.spec.whatwg.org/#htmltableheadercellelement)
2486
+ * WhatWG HTML$4.9.9 - The `td` element - Interface `HTMLTableHeaderCellElement`
2487
+ * Note: Most browsers currently adher to the W3C DOM Level 2 spec
2488
+ * (https://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-82915075)
2489
+ * which suggests that browsers should use HTMLTableCellElement for
2490
+ * both TD and TH elements. WhatWG separates these.
2491
+ * Test: Object.prototype.toString.call(document.createElement('th'))
2492
+ * - Chrome === "[object HTMLTableCellElement]"
2493
+ * - Firefox === "[object HTMLTableCellElement]"
2494
+ * - Safari === "[object HTMLTableCellElement]"
2495
+ */
2496
+ if (obj.tagName === 'TH') {
2497
+ return 'HTMLTableHeaderCellElement';
2498
+ }
2499
+ }
2500
+ }
2501
+
2502
+ /* ! Speed optimisation
2503
+ * Pre:
2504
+ * Float64Array x 625,644 ops/sec ±1.58% (80 runs sampled)
2505
+ * Float32Array x 1,279,852 ops/sec ±2.91% (77 runs sampled)
2506
+ * Uint32Array x 1,178,185 ops/sec ±1.95% (83 runs sampled)
2507
+ * Uint16Array x 1,008,380 ops/sec ±2.25% (80 runs sampled)
2508
+ * Uint8Array x 1,128,040 ops/sec ±2.11% (81 runs sampled)
2509
+ * Int32Array x 1,170,119 ops/sec ±2.88% (80 runs sampled)
2510
+ * Int16Array x 1,176,348 ops/sec ±5.79% (86 runs sampled)
2511
+ * Int8Array x 1,058,707 ops/sec ±4.94% (77 runs sampled)
2512
+ * Uint8ClampedArray x 1,110,633 ops/sec ±4.20% (80 runs sampled)
2513
+ * Post:
2514
+ * Float64Array x 7,105,671 ops/sec ±13.47% (64 runs sampled)
2515
+ * Float32Array x 5,887,912 ops/sec ±1.46% (82 runs sampled)
2516
+ * Uint32Array x 6,491,661 ops/sec ±1.76% (79 runs sampled)
2517
+ * Uint16Array x 6,559,795 ops/sec ±1.67% (82 runs sampled)
2518
+ * Uint8Array x 6,463,966 ops/sec ±1.43% (85 runs sampled)
2519
+ * Int32Array x 5,641,841 ops/sec ±3.49% (81 runs sampled)
2520
+ * Int16Array x 6,583,511 ops/sec ±1.98% (80 runs sampled)
2521
+ * Int8Array x 6,606,078 ops/sec ±1.74% (81 runs sampled)
2522
+ * Uint8ClampedArray x 6,602,224 ops/sec ±1.77% (83 runs sampled)
2523
+ */
2524
+ var stringTag = (symbolToStringTagExists && obj[Symbol.toStringTag]);
2525
+ if (typeof stringTag === 'string') {
2526
+ return stringTag;
2527
+ }
2528
+
2529
+ var objPrototype = Object.getPrototypeOf(obj);
2530
+ /* ! Speed optimisation
2531
+ * Pre:
2532
+ * regex literal x 1,772,385 ops/sec ±1.85% (77 runs sampled)
2533
+ * regex constructor x 2,143,634 ops/sec ±2.46% (78 runs sampled)
2534
+ * Post:
2535
+ * regex literal x 3,928,009 ops/sec ±0.65% (78 runs sampled)
2536
+ * regex constructor x 3,931,108 ops/sec ±0.58% (84 runs sampled)
2537
+ */
2538
+ if (objPrototype === RegExp.prototype) {
2539
+ return 'RegExp';
2540
+ }
2541
+
2542
+ /* ! Speed optimisation
2543
+ * Pre:
2544
+ * date x 2,130,074 ops/sec ±4.42% (68 runs sampled)
2545
+ * Post:
2546
+ * date x 3,953,779 ops/sec ±1.35% (77 runs sampled)
2547
+ */
2548
+ if (objPrototype === Date.prototype) {
2549
+ return 'Date';
2550
+ }
2551
+
2552
+ /* ! Spec Conformance
2553
+ * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag)
2554
+ * ES6$25.4.5.4 - Promise.prototype[@@toStringTag] should be "Promise":
2555
+ * Test: `Object.prototype.toString.call(Promise.resolve())``
2556
+ * - Chrome <=47 === "[object Object]"
2557
+ * - Edge <=20 === "[object Object]"
2558
+ * - Firefox 29-Latest === "[object Promise]"
2559
+ * - Safari 7.1-Latest === "[object Promise]"
2560
+ */
2561
+ if (promiseExists && objPrototype === Promise.prototype) {
2562
+ return 'Promise';
2563
+ }
2564
+
2565
+ /* ! Speed optimisation
2566
+ * Pre:
2567
+ * set x 2,222,186 ops/sec ±1.31% (82 runs sampled)
2568
+ * Post:
2569
+ * set x 4,545,879 ops/sec ±1.13% (83 runs sampled)
2570
+ */
2571
+ if (setExists && objPrototype === Set.prototype) {
2572
+ return 'Set';
2573
+ }
2574
+
2575
+ /* ! Speed optimisation
2576
+ * Pre:
2577
+ * map x 2,396,842 ops/sec ±1.59% (81 runs sampled)
2578
+ * Post:
2579
+ * map x 4,183,945 ops/sec ±6.59% (82 runs sampled)
2580
+ */
2581
+ if (mapExists && objPrototype === Map.prototype) {
2582
+ return 'Map';
2583
+ }
2584
+
2585
+ /* ! Speed optimisation
2586
+ * Pre:
2587
+ * weakset x 1,323,220 ops/sec ±2.17% (76 runs sampled)
2588
+ * Post:
2589
+ * weakset x 4,237,510 ops/sec ±2.01% (77 runs sampled)
2590
+ */
2591
+ if (weakSetExists && objPrototype === WeakSet.prototype) {
2592
+ return 'WeakSet';
2593
+ }
2594
+
2595
+ /* ! Speed optimisation
2596
+ * Pre:
2597
+ * weakmap x 1,500,260 ops/sec ±2.02% (78 runs sampled)
2598
+ * Post:
2599
+ * weakmap x 3,881,384 ops/sec ±1.45% (82 runs sampled)
2600
+ */
2601
+ if (weakMapExists && objPrototype === WeakMap.prototype) {
2602
+ return 'WeakMap';
2603
+ }
2604
+
2605
+ /* ! Spec Conformance
2606
+ * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag)
2607
+ * ES6$24.2.4.21 - DataView.prototype[@@toStringTag] should be "DataView":
2608
+ * Test: `Object.prototype.toString.call(new DataView(new ArrayBuffer(1)))``
2609
+ * - Edge <=13 === "[object Object]"
2610
+ */
2611
+ if (dataViewExists && objPrototype === DataView.prototype) {
2612
+ return 'DataView';
2613
+ }
2614
+
2615
+ /* ! Spec Conformance
2616
+ * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag)
2617
+ * ES6$23.1.5.2.2 - %MapIteratorPrototype%[@@toStringTag] should be "Map Iterator":
2618
+ * Test: `Object.prototype.toString.call(new Map().entries())``
2619
+ * - Edge <=13 === "[object Object]"
2620
+ */
2621
+ if (mapExists && objPrototype === mapIteratorPrototype) {
2622
+ return 'Map Iterator';
2623
+ }
2624
+
2625
+ /* ! Spec Conformance
2626
+ * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag)
2627
+ * ES6$23.2.5.2.2 - %SetIteratorPrototype%[@@toStringTag] should be "Set Iterator":
2628
+ * Test: `Object.prototype.toString.call(new Set().entries())``
2629
+ * - Edge <=13 === "[object Object]"
2630
+ */
2631
+ if (setExists && objPrototype === setIteratorPrototype) {
2632
+ return 'Set Iterator';
2633
+ }
2634
+
2635
+ /* ! Spec Conformance
2636
+ * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag)
2637
+ * ES6$22.1.5.2.2 - %ArrayIteratorPrototype%[@@toStringTag] should be "Array Iterator":
2638
+ * Test: `Object.prototype.toString.call([][Symbol.iterator]())``
2639
+ * - Edge <=13 === "[object Object]"
2640
+ */
2641
+ if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) {
2642
+ return 'Array Iterator';
2643
+ }
2644
+
2645
+ /* ! Spec Conformance
2646
+ * (http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag)
2647
+ * ES6$21.1.5.2.2 - %StringIteratorPrototype%[@@toStringTag] should be "String Iterator":
2648
+ * Test: `Object.prototype.toString.call(''[Symbol.iterator]())``
2649
+ * - Edge <=13 === "[object Object]"
2650
+ */
2651
+ if (stringIteratorExists && objPrototype === stringIteratorPrototype) {
2652
+ return 'String Iterator';
2653
+ }
2654
+
2655
+ /* ! Speed optimisation
2656
+ * Pre:
2657
+ * object from null x 2,424,320 ops/sec ±1.67% (76 runs sampled)
2658
+ * Post:
2659
+ * object from null x 5,838,000 ops/sec ±0.99% (84 runs sampled)
2660
+ */
2661
+ if (objPrototype === null) {
2662
+ return 'Object';
2663
+ }
2664
+
2665
+ return Object
2666
+ .prototype
2667
+ .toString
2668
+ .call(obj)
2669
+ .slice(toStringLeftSliceLength, toStringRightSliceLength);
2670
+ }
2617
2671
 
2618
- return typeDetect;
2672
+ return typeDetect;
2619
2673
 
2620
- })));
2621
- }(typeDetect));
2674
+ })));
2675
+ } (typeDetect));
2622
2676
 
2623
2677
  var type = typeDetect.exports;
2624
2678
 
@@ -3086,6 +3140,7 @@ function withGlobal(_global) {
3086
3140
  target.parse = source.parse;
3087
3141
  target.UTC = source.UTC;
3088
3142
  target.prototype.toUTCString = source.prototype.toUTCString;
3143
+ target.isFake = true;
3089
3144
 
3090
3145
  return target;
3091
3146
  }
@@ -4296,6 +4351,14 @@ function withGlobal(_global) {
4296
4351
  );
4297
4352
  }
4298
4353
 
4354
+ if (_global.Date.isFake === true) {
4355
+ // Timers are already faked; this is a problem.
4356
+ // Make the user reset timers before continuing.
4357
+ throw new TypeError(
4358
+ "Can't install fake timers twice on the same global object."
4359
+ );
4360
+ }
4361
+
4299
4362
  // eslint-disable-next-line no-param-reassign
4300
4363
  config = typeof config !== "undefined" ? config : {};
4301
4364
  config.shouldAdvanceTime = config.shouldAdvanceTime || false;
@@ -4573,8 +4636,10 @@ class VitestUtils {
4573
4636
  });
4574
4637
  this._mocker = typeof __vitest_mocker__ !== "undefined" ? __vitest_mocker__ : null;
4575
4638
  this._mockedDate = null;
4576
- if (!this._mocker)
4577
- throw new Error("Vitest was initialized with native Node instead of Vite Node");
4639
+ if (!this._mocker) {
4640
+ const errorMsg = 'Vitest was initialized with native Node instead of Vite Node.\n\nOne of the following is possible:\n- "vitest" is imported outside of your tests (in that case, use "vitest/node" or import.meta.vitest)\n- "vitest" is imported inside "globalSetup" (use "setupFiles", because "globalSetup" runs in a different context)\n- Your dependency inside "node_modules" imports "vitest" directly (in that case, inline that dependency, using "deps.inline" config)\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n';
4641
+ throw new Error(errorMsg);
4642
+ }
4578
4643
  }
4579
4644
  useFakeTimers() {
4580
4645
  this._timers.useFakeTimers();
@@ -4686,26 +4751,4 @@ function isWatchMode() {
4686
4751
  return getRunningMode() === "watch";
4687
4752
  }
4688
4753
 
4689
- var index = /*#__PURE__*/Object.freeze({
4690
- __proto__: null,
4691
- suite: suite,
4692
- test: test,
4693
- describe: describe,
4694
- it: it,
4695
- runOnce: runOnce,
4696
- isFirstRun: isFirstRun,
4697
- beforeAll: beforeAll,
4698
- afterAll: afterAll,
4699
- beforeEach: beforeEach,
4700
- afterEach: afterEach,
4701
- assert: assert,
4702
- should: should,
4703
- chai: chai$1,
4704
- expect: expect,
4705
- vitest: vitest,
4706
- vi: vi,
4707
- getRunningMode: getRunningMode,
4708
- isWatchMode: isWatchMode
4709
- });
4710
-
4711
- export { RealDate as R, context as a, getSnapshotClient as b, clearContext as c, defaultSuite as d, setState as e, getFn as f, getHooks as g, getState as h, index as i, suite as j, describe as k, it as l, runOnce as m, isFirstRun as n, beforeAll as o, afterAll as p, beforeEach as q, resetRunOnceCounter as r, setHooks as s, test as t, afterEach as u, vi as v, expect as w, vitest as x, getRunningMode as y, isWatchMode as z };
4754
+ export { getState as A, RealDate as R, isFirstRun as a, beforeAll as b, afterAll as c, describe as d, beforeEach as e, afterEach as f, createExpect as g, expect as h, it as i, vi as j, getRunningMode as k, isWatchMode as l, resetRunOnceCounter as m, clearCollectorContext as n, defaultSuite as o, setHooks as p, getHooks as q, runOnce as r, suite as s, test as t, collectorContext as u, vitest as v, withCallback as w, getSnapshotClient as x, setState as y, getFn as z };