vitest 0.14.1 → 0.15.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 (25) hide show
  1. package/dist/{chunk-api-setup.7945baf8.mjs → chunk-api-setup.ff687d0e.mjs} +44 -37
  2. package/dist/{chunk-constants.41584d81.mjs → chunk-constants.7b9cfc82.mjs} +1 -1
  3. package/dist/{chunk-defaults.a820faeb.mjs → chunk-defaults.dc6dc23d.mjs} +142 -3
  4. package/dist/{chunk-install-pkg.6f5930c3.mjs → chunk-install-pkg.3fa50769.mjs} +1 -1
  5. package/dist/{chunk-integrations-globals.f0c5e97f.mjs → chunk-integrations-globals.df0878f4.mjs} +7 -7
  6. package/dist/{chunk-runtime-chain.6a3c6576.mjs → chunk-runtime-chain.ce7f4b92.mjs} +117 -64
  7. package/dist/{chunk-runtime-mocker.7cf95199.mjs → chunk-runtime-mocker.2f3cbfe5.mjs} +3 -3
  8. package/dist/{chunk-runtime-rpc.44043bb4.mjs → chunk-runtime-rpc.5e78af38.mjs} +1 -1
  9. package/dist/{chunk-utils-global.624991bc.mjs → chunk-utils-global.79a8b1cc.mjs} +15 -8
  10. package/dist/{chunk-utils-source-map.4408ba82.mjs → chunk-utils-source-map.2556cba8.mjs} +29 -14
  11. package/dist/{chunk-vite-node-externalize.d492e389.mjs → chunk-vite-node-externalize.105bc106.mjs} +105 -165
  12. package/dist/{chunk-vite-node-utils.d6687931.mjs → chunk-vite-node-utils.c0a0e1b3.mjs} +4 -4
  13. package/dist/cli.mjs +11 -10
  14. package/dist/config.cjs +5 -1
  15. package/dist/config.d.ts +4 -0
  16. package/dist/config.mjs +5 -1
  17. package/dist/entry.mjs +6 -6
  18. package/dist/index.d.ts +36 -4
  19. package/dist/index.mjs +4 -4
  20. package/dist/node.d.ts +32 -1
  21. package/dist/node.mjs +10 -9
  22. package/dist/{vendor-entry.93b045ee.mjs → vendor-entry.7ec02ea2.mjs} +41 -27
  23. package/dist/{vendor-index.a2a385d8.mjs → vendor-index.e5dc6622.mjs} +0 -0
  24. package/dist/worker.mjs +8 -7
  25. package/package.json +9 -8
@@ -1,5 +1,5 @@
1
1
  import { promises } from 'fs';
2
- import { c as createBirpc } from './chunk-vite-node-utils.d6687931.mjs';
2
+ import { c as createBirpc } from './chunk-vite-node-utils.c0a0e1b3.mjs';
3
3
  import require$$0$1 from 'stream';
4
4
  import require$$0 from 'zlib';
5
5
  import require$$3 from 'net';
@@ -9,11 +9,11 @@ import require$$2 from 'events';
9
9
  import require$$1 from 'https';
10
10
  import require$$2$1 from 'http';
11
11
  import url from 'url';
12
- import { A as API_PATH } from './chunk-constants.41584d81.mjs';
13
- import { j as interpretSourcePos, b as parseStacktrace } from './chunk-utils-source-map.4408ba82.mjs';
12
+ import { A as API_PATH } from './chunk-constants.7b9cfc82.mjs';
13
+ import { j as interpretSourcePos, b as parseStacktrace } from './chunk-utils-source-map.2556cba8.mjs';
14
14
  import 'module';
15
15
  import 'vm';
16
- import './chunk-utils-global.624991bc.mjs';
16
+ import './chunk-utils-global.79a8b1cc.mjs';
17
17
  import 'tty';
18
18
  import 'local-pkg';
19
19
  import 'path';
@@ -126,6 +126,9 @@ var constants = {
126
126
  NOOP: () => {}
127
127
  };
128
128
 
129
+ var unmask$1;
130
+ var mask;
131
+
129
132
  const { EMPTY_BUFFER: EMPTY_BUFFER$3 } = constants;
130
133
 
131
134
  /**
@@ -225,30 +228,31 @@ function toBuffer$2(data) {
225
228
  return buf;
226
229
  }
227
230
 
228
- try {
229
- const bufferUtil = require('bufferutil');
231
+ bufferUtil$1.exports = {
232
+ concat: concat$1,
233
+ mask: _mask,
234
+ toArrayBuffer: toArrayBuffer$1,
235
+ toBuffer: toBuffer$2,
236
+ unmask: _unmask
237
+ };
238
+
239
+ /* istanbul ignore else */
240
+ if (!process.env.WS_NO_BUFFER_UTIL) {
241
+ try {
242
+ const bufferUtil = require('bufferutil');
230
243
 
231
- bufferUtil$1.exports = {
232
- concat: concat$1,
233
- mask(source, mask, output, offset, length) {
244
+ mask = bufferUtil$1.exports.mask = function (source, mask, output, offset, length) {
234
245
  if (length < 48) _mask(source, mask, output, offset, length);
235
246
  else bufferUtil.mask(source, mask, output, offset, length);
236
- },
237
- toArrayBuffer: toArrayBuffer$1,
238
- toBuffer: toBuffer$2,
239
- unmask(buffer, mask) {
247
+ };
248
+
249
+ unmask$1 = bufferUtil$1.exports.unmask = function (buffer, mask) {
240
250
  if (buffer.length < 32) _unmask(buffer, mask);
241
251
  else bufferUtil.unmask(buffer, mask);
242
- }
243
- };
244
- } catch (e) /* istanbul ignore next */ {
245
- bufferUtil$1.exports = {
246
- concat: concat$1,
247
- mask: _mask,
248
- toArrayBuffer: toArrayBuffer$1,
249
- toBuffer: toBuffer$2,
250
- unmask: _unmask
251
- };
252
+ };
253
+ } catch (e) {
254
+ // Continue regardless of the error.
255
+ }
252
256
  }
253
257
 
254
258
  const kDone = Symbol('kDone');
@@ -817,6 +821,8 @@ function inflateOnError(err) {
817
821
 
818
822
  var validation = {exports: {}};
819
823
 
824
+ var isValidUTF8_1;
825
+
820
826
  //
821
827
  // Allowed token characters:
822
828
  //
@@ -922,22 +928,23 @@ function _isValidUTF8(buf) {
922
928
  return true;
923
929
  }
924
930
 
925
- try {
926
- const isValidUTF8 = require('utf-8-validate');
931
+ validation.exports = {
932
+ isValidStatusCode: isValidStatusCode$2,
933
+ isValidUTF8: _isValidUTF8,
934
+ tokenChars: tokenChars$2
935
+ };
927
936
 
928
- validation.exports = {
929
- isValidStatusCode: isValidStatusCode$2,
930
- isValidUTF8(buf) {
937
+ /* istanbul ignore else */
938
+ if (!process.env.WS_NO_UTF_8_VALIDATE) {
939
+ try {
940
+ const isValidUTF8 = require('utf-8-validate');
941
+
942
+ isValidUTF8_1 = validation.exports.isValidUTF8 = function (buf) {
931
943
  return buf.length < 150 ? _isValidUTF8(buf) : isValidUTF8(buf);
932
- },
933
- tokenChars: tokenChars$2
934
- };
935
- } catch (e) /* istanbul ignore next */ {
936
- validation.exports = {
937
- isValidStatusCode: isValidStatusCode$2,
938
- isValidUTF8: _isValidUTF8,
939
- tokenChars: tokenChars$2
940
- };
944
+ };
945
+ } catch (e) {
946
+ // Continue regardless of the error.
947
+ }
941
948
  }
942
949
 
943
950
  const { Writable } = require$$0$1;
@@ -1,5 +1,5 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { l as resolve } from './chunk-utils-global.624991bc.mjs';
2
+ import { m as resolve } from './chunk-utils-global.79a8b1cc.mjs';
3
3
 
4
4
  const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
5
5
  const defaultPort = 51204;
@@ -1,7 +1,142 @@
1
1
  import { existsSync, promises } from 'fs';
2
2
  import { createRequire } from 'module';
3
3
  import { pathToFileURL } from 'url';
4
- import { t as toArray, l as resolve } from './chunk-utils-global.624991bc.mjs';
4
+ import { C as toArray, m as resolve } from './chunk-utils-global.79a8b1cc.mjs';
5
+
6
+ /*
7
+ How it works:
8
+ `this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.
9
+ */
10
+
11
+ class Node {
12
+ value;
13
+ next;
14
+
15
+ constructor(value) {
16
+ this.value = value;
17
+ }
18
+ }
19
+
20
+ class Queue {
21
+ #head;
22
+ #tail;
23
+ #size;
24
+
25
+ constructor() {
26
+ this.clear();
27
+ }
28
+
29
+ enqueue(value) {
30
+ const node = new Node(value);
31
+
32
+ if (this.#head) {
33
+ this.#tail.next = node;
34
+ this.#tail = node;
35
+ } else {
36
+ this.#head = node;
37
+ this.#tail = node;
38
+ }
39
+
40
+ this.#size++;
41
+ }
42
+
43
+ dequeue() {
44
+ const current = this.#head;
45
+ if (!current) {
46
+ return;
47
+ }
48
+
49
+ this.#head = this.#head.next;
50
+ this.#size--;
51
+ return current.value;
52
+ }
53
+
54
+ clear() {
55
+ this.#head = undefined;
56
+ this.#tail = undefined;
57
+ this.#size = 0;
58
+ }
59
+
60
+ get size() {
61
+ return this.#size;
62
+ }
63
+
64
+ * [Symbol.iterator]() {
65
+ let current = this.#head;
66
+
67
+ while (current) {
68
+ yield current.value;
69
+ current = current.next;
70
+ }
71
+ }
72
+ }
73
+
74
+ function pLimit(concurrency) {
75
+ if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
76
+ throw new TypeError('Expected `concurrency` to be a number from 1 and up');
77
+ }
78
+
79
+ const queue = new Queue();
80
+ let activeCount = 0;
81
+
82
+ const next = () => {
83
+ activeCount--;
84
+
85
+ if (queue.size > 0) {
86
+ queue.dequeue()();
87
+ }
88
+ };
89
+
90
+ const run = async (fn, resolve, args) => {
91
+ activeCount++;
92
+
93
+ const result = (async () => fn(...args))();
94
+
95
+ resolve(result);
96
+
97
+ try {
98
+ await result;
99
+ } catch {}
100
+
101
+ next();
102
+ };
103
+
104
+ const enqueue = (fn, resolve, args) => {
105
+ queue.enqueue(run.bind(undefined, fn, resolve, args));
106
+
107
+ (async () => {
108
+ // This function needs to wait until the next microtask before comparing
109
+ // `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
110
+ // when the run function is dequeued and called. The comparison in the if-statement
111
+ // needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
112
+ await Promise.resolve();
113
+
114
+ if (activeCount < concurrency && queue.size > 0) {
115
+ queue.dequeue()();
116
+ }
117
+ })();
118
+ };
119
+
120
+ const generator = (fn, ...args) => new Promise(resolve => {
121
+ enqueue(fn, resolve, args);
122
+ });
123
+
124
+ Object.defineProperties(generator, {
125
+ activeCount: {
126
+ get: () => activeCount,
127
+ },
128
+ pendingCount: {
129
+ get: () => queue.size,
130
+ },
131
+ clearQueue: {
132
+ value: () => {
133
+ queue.clear();
134
+ },
135
+ },
136
+ });
137
+
138
+ return generator;
139
+ }
5
140
 
6
141
  const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
7
142
  const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**"];
@@ -64,8 +199,12 @@ const config = {
64
199
  ui: false,
65
200
  uiBase: "/__vitest__/",
66
201
  open: true,
202
+ css: {
203
+ include: [/\.module\./]
204
+ },
67
205
  coverage: coverageConfigDefaults,
68
- fakeTimers: fakeTimersDefaults
206
+ fakeTimers: fakeTimersDefaults,
207
+ maxConcurrency: 5
69
208
  };
70
209
  const configDefaults = Object.freeze(config);
71
210
 
@@ -160,4 +299,4 @@ async function reportCoverage(ctx) {
160
299
  }
161
300
  }
162
301
 
163
- export { cleanCoverage as a, reportCoverage as b, configDefaults as c, resolveC8Options as r, takeCoverage as t };
302
+ export { cleanCoverage as a, reportCoverage as b, configDefaults as c, pLimit as p, resolveC8Options as r, takeCoverage as t };
@@ -2,7 +2,7 @@ import path$2 from 'path';
2
2
  import fs$2 from 'fs';
3
3
  import require$$0 from 'util';
4
4
  import childProcess$1 from 'child_process';
5
- import { p as pathKey, s as signalExit, m as mergeStream$1, g as getStream$1, c as crossSpawn$1, o as onetime$1 } from './vendor-index.a2a385d8.mjs';
5
+ import { p as pathKey, s as signalExit, m as mergeStream$1, g as getStream$1, c as crossSpawn$1, o as onetime$1 } from './vendor-index.e5dc6622.mjs';
6
6
  import require$$0$1 from 'os';
7
7
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
8
8
  import 'assert';
@@ -1,20 +1,20 @@
1
- import { g as globalApis } from './chunk-constants.41584d81.mjs';
2
- import { i as index } from './vendor-entry.93b045ee.mjs';
1
+ import { g as globalApis } from './chunk-constants.7b9cfc82.mjs';
2
+ import { i as index } from './vendor-entry.7ec02ea2.mjs';
3
3
  import 'url';
4
- import './chunk-utils-global.624991bc.mjs';
4
+ import './chunk-utils-global.79a8b1cc.mjs';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
8
8
  import 'fs';
9
- import './chunk-runtime-chain.6a3c6576.mjs';
9
+ import './chunk-runtime-chain.ce7f4b92.mjs';
10
10
  import 'chai';
11
11
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
12
- import './chunk-runtime-rpc.44043bb4.mjs';
13
- import './chunk-utils-source-map.4408ba82.mjs';
12
+ import './chunk-runtime-rpc.5e78af38.mjs';
13
+ import './chunk-utils-source-map.2556cba8.mjs';
14
14
  import './chunk-integrations-spy.674b628e.mjs';
15
15
  import 'tinyspy';
16
16
  import 'util';
17
- import './chunk-defaults.a820faeb.mjs';
17
+ import './chunk-defaults.dc6dc23d.mjs';
18
18
  import 'module';
19
19
 
20
20
  function registerApiGlobally() {
@@ -1,9 +1,9 @@
1
- import chai$1, { expect as expect$1, AssertionError, util } from 'chai';
1
+ import chai$1, { expect, AssertionError, util } from 'chai';
2
2
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
3
- import { r as rpc } from './chunk-runtime-rpc.44043bb4.mjs';
4
- import { i as isObject, j as join, d as dirname, g as getCallLastIndex, s as slash, a as getWorkerState, b as getNames, c as assertTypes, p as picocolors, e as safeSetTimeout, f as safeClearTimeout, n as noop, t as toArray, r as resetModules } from './chunk-utils-global.624991bc.mjs';
3
+ import { r as rpc } from './chunk-runtime-rpc.5e78af38.mjs';
4
+ import { i as isObject, j as join, d as dirname, g as getCallLastIndex, s as slash, a as getWorkerState, b as getNames, c as assertTypes, p as picocolors, e as getFullName, f as safeSetTimeout, h as safeClearTimeout, n as noop, r as resetModules } from './chunk-utils-global.79a8b1cc.mjs';
5
5
  import fs, { promises } from 'fs';
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 } from './chunk-utils-source-map.4408ba82.mjs';
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 } from './chunk-utils-source-map.2556cba8.mjs';
7
7
  import { i as isMockFunction, s as spyOn, f as fn, a as spies } from './chunk-integrations-spy.674b628e.mjs';
8
8
  import require$$0, { format } from 'util';
9
9
 
@@ -375,6 +375,18 @@ const sparseArrayEquality = (a, b) => {
375
375
  const bKeys = Object.keys(b);
376
376
  return equals(a, b, [iterableEquality, typeEquality], true) && equals(aKeys, bKeys);
377
377
  };
378
+ const generateToBeMessage = (deepEqualityName, expected = "#{this}", actual = "#{exp}") => {
379
+ const toBeMessage = `expected ${expected} to be ${actual} // Object.is equality`;
380
+ if (["toStrictEqual", "toEqual"].includes(deepEqualityName))
381
+ return `${toBeMessage}
382
+
383
+ If it should pass with deep equality, replace "toBe" with "${deepEqualityName}"
384
+
385
+ Expected: ${expected}
386
+ Received: serializes to the same string
387
+ `;
388
+ return toBeMessage;
389
+ };
378
390
 
379
391
  var naturalCompare$1 = {exports: {}};
380
392
 
@@ -526,11 +538,15 @@ function normalizeNewlines(string) {
526
538
  }
527
539
  async function saveSnapshotFile(snapshotData, snapshotPath) {
528
540
  const snapshots = Object.keys(snapshotData).sort(naturalCompare$1.exports).map((key) => `exports[${printBacktickString(key)}] = ${printBacktickString(normalizeNewlines(snapshotData[key]))};`);
529
- ensureDirectoryExists(snapshotPath);
530
- await promises.writeFile(snapshotPath, `${writeSnapshotVersion()}
541
+ const content = `${writeSnapshotVersion()}
531
542
 
532
543
  ${snapshots.join("\n\n")}
533
- `, "utf-8");
544
+ `;
545
+ const skipWriting = fs.existsSync(snapshotPath) && await promises.readFile(snapshotPath, "utf8") === content;
546
+ if (skipWriting)
547
+ return;
548
+ ensureDirectoryExists(snapshotPath);
549
+ await promises.writeFile(snapshotPath, content, "utf-8");
534
550
  }
535
551
  function prepareExpected(expected) {
536
552
  function findStartIndent() {
@@ -924,7 +940,7 @@ class SnapshotClient {
924
940
  try {
925
941
  const pass2 = equals(received, properties, [iterableEquality, subsetEquality]);
926
942
  if (!pass2)
927
- expect$1(received).equals(properties);
943
+ expect(received).equals(properties);
928
944
  else
929
945
  received = deepMergeSnapshot(received, properties);
930
946
  } catch (err) {
@@ -946,7 +962,7 @@ class SnapshotClient {
946
962
  });
947
963
  if (!pass) {
948
964
  try {
949
- expect$1(actual.trim()).equals(expected ? expected.trim() : "");
965
+ expect(actual.trim()).equals(expected ? expected.trim() : "");
950
966
  } catch (error2) {
951
967
  error2.message = errorMessage || `Snapshot \`${key || "unknown"}\` mismatched`;
952
968
  throw error2;
@@ -1052,24 +1068,20 @@ const SnapshotPlugin = (chai, utils) => {
1052
1068
  });
1053
1069
  };
1054
1070
 
1071
+ const GLOBAL_EXPECT = Symbol.for("expect-global");
1055
1072
  const MATCHERS_OBJECT = Symbol.for("matchers-object");
1056
- if (!Object.prototype.hasOwnProperty.call(global, MATCHERS_OBJECT)) {
1057
- const defaultState = {
1058
- assertionCalls: 0,
1059
- isExpectingAssertions: false,
1060
- isExpectingAssertionsError: null,
1061
- expectedAssertionsNumber: null,
1062
- expectedAssertionsNumberErrorGen: null
1063
- };
1073
+
1074
+ if (!Object.prototype.hasOwnProperty.call(globalThis, MATCHERS_OBJECT)) {
1064
1075
  Object.defineProperty(globalThis, MATCHERS_OBJECT, {
1065
- value: {
1066
- state: defaultState
1067
- }
1076
+ value: /* @__PURE__ */ new WeakMap()
1068
1077
  });
1069
1078
  }
1070
- const getState = () => globalThis[MATCHERS_OBJECT].state;
1071
- const setState = (state) => {
1072
- Object.assign(globalThis[MATCHERS_OBJECT].state, state);
1079
+ const getState = (expect) => globalThis[MATCHERS_OBJECT].get(expect);
1080
+ const setState = (state, expect) => {
1081
+ const map = globalThis[MATCHERS_OBJECT];
1082
+ const current = map.get(expect) || {};
1083
+ Object.assign(current, state);
1084
+ map.set(expect, current);
1073
1085
  };
1074
1086
  const JestChaiExpect = (chai, utils) => {
1075
1087
  function def(name, fn) {
@@ -1127,7 +1139,24 @@ const JestChaiExpect = (chai, utils) => {
1127
1139
  });
1128
1140
  def("toBe", function(expected) {
1129
1141
  const actual = this._obj;
1130
- return this.assert(Object.is(actual, expected), "expected #{this} to be #{exp} // Object.is equality", "expected #{this} not to be #{exp} // Object.is equality", expected, actual);
1142
+ const pass = Object.is(actual, expected);
1143
+ let deepEqualityName = "";
1144
+ if (!pass) {
1145
+ const toStrictEqualPass = equals(actual, expected, [
1146
+ iterableEquality,
1147
+ typeEquality,
1148
+ sparseArrayEquality,
1149
+ arrayBufferEquality
1150
+ ], true);
1151
+ if (toStrictEqualPass) {
1152
+ deepEqualityName = "toStrictEqual";
1153
+ } else {
1154
+ const toEqualPass = equals(actual, expected, [iterableEquality]);
1155
+ if (toEqualPass)
1156
+ deepEqualityName = "toEqual";
1157
+ }
1158
+ }
1159
+ return this.assert(pass, generateToBeMessage(deepEqualityName), "expected #{this} not to be #{exp} // Object.is equality", expected, actual);
1131
1160
  });
1132
1161
  def("toMatchObject", function(expected) {
1133
1162
  const actual = this._obj;
@@ -1456,24 +1485,6 @@ Number of calls: ${picocolors.exports.bold(spy.mock.calls.length)}
1456
1485
  });
1457
1486
  return proxy;
1458
1487
  });
1459
- utils.addMethod(chai.expect, "assertions", function assertions(expected) {
1460
- const errorGen = () => new Error(`expected number of assertions to be ${expected}, but got ${getState().assertionCalls}`);
1461
- if (Error.captureStackTrace)
1462
- Error.captureStackTrace(errorGen(), assertions);
1463
- setState({
1464
- expectedAssertionsNumber: expected,
1465
- expectedAssertionsNumberErrorGen: errorGen
1466
- });
1467
- });
1468
- utils.addMethod(chai.expect, "hasAssertions", function hasAssertions() {
1469
- const error = new Error("expected any number of assertion, but got none");
1470
- if (Error.captureStackTrace)
1471
- Error.captureStackTrace(error, hasAssertions);
1472
- setState({
1473
- isExpectingAssertions: true,
1474
- isExpectingAssertionsError: error
1475
- });
1476
- });
1477
1488
  utils.addMethod(chai.expect, "addSnapshotSerializer", addSerializer);
1478
1489
  };
1479
1490
  function toString(value) {
@@ -1509,8 +1520,8 @@ class AsymmetricMatcher {
1509
1520
  this.inverse = inverse;
1510
1521
  this.$$typeof = Symbol.for("jest.asymmetricMatcher");
1511
1522
  }
1512
- getMatcherContext() {
1513
- return __spreadProps$1(__spreadValues$2({}, getState()), {
1523
+ getMatcherContext(expect) {
1524
+ return __spreadProps$1(__spreadValues$2({}, getState(expect || globalThis[GLOBAL_EXPECT])), {
1514
1525
  equals,
1515
1526
  isNot: this.inverse,
1516
1527
  utils: matcherUtils
@@ -1704,7 +1715,7 @@ var __spreadValues$1 = (a, b) => {
1704
1715
  };
1705
1716
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1706
1717
  const isAsyncFunction = (fn) => typeof fn === "function" && fn[Symbol.toStringTag] === "AsyncFunction";
1707
- const getMatcherState = (assertion) => {
1718
+ const getMatcherState = (assertion, expect) => {
1708
1719
  const obj = assertion._obj;
1709
1720
  const isNot = util.flag(assertion, "negate");
1710
1721
  const promise = util.flag(assertion, "promise") || "";
@@ -1712,7 +1723,7 @@ const getMatcherState = (assertion) => {
1712
1723
  iterableEquality,
1713
1724
  subsetEquality
1714
1725
  });
1715
- const matcherState = __spreadProps(__spreadValues$1({}, getState()), {
1726
+ const matcherState = __spreadProps(__spreadValues$1({}, getState(expect)), {
1716
1727
  isNot,
1717
1728
  utils: jestUtils,
1718
1729
  promise,
@@ -1737,13 +1748,13 @@ function JestExtendPlugin(expect, matchers) {
1737
1748
  return (c, utils) => {
1738
1749
  Object.entries(matchers).forEach(([expectAssertionName, expectAssertion]) => {
1739
1750
  function expectSyncWrapper(...args) {
1740
- const { state, isNot, obj } = getMatcherState(this);
1751
+ const { state, isNot, obj } = getMatcherState(this, expect);
1741
1752
  const { pass, message, actual, expected } = expectAssertion.call(state, obj, ...args);
1742
1753
  if (pass && isNot || !pass && !isNot)
1743
1754
  throw new JestExtendError(message(), actual, expected);
1744
1755
  }
1745
1756
  async function expectAsyncWrapper(...args) {
1746
- const { state, isNot, obj } = getMatcherState(this);
1757
+ const { state, isNot, obj } = getMatcherState(this, expect);
1747
1758
  const { pass, message, actual, expected } = await expectAssertion.call(state, obj, ...args);
1748
1759
  if (pass && isNot || !pass && !isNot)
1749
1760
  throw new JestExtendError(message(), actual, expected);
@@ -1755,7 +1766,7 @@ function JestExtendPlugin(expect, matchers) {
1755
1766
  super(sample, inverse);
1756
1767
  }
1757
1768
  asymmetricMatch(other) {
1758
- const { pass } = expectAssertion.call(this.getMatcherContext(), other, ...this.sample);
1769
+ const { pass } = expectAssertion.call(this.getMatcherContext(expect), other, ...this.sample);
1759
1770
  return this.inverse ? !pass : pass;
1760
1771
  }
1761
1772
  toString() {
@@ -1796,22 +1807,55 @@ chai$1.use(SnapshotPlugin);
1796
1807
  chai$1.use(JestAsymmetricMatchers);
1797
1808
 
1798
1809
  function createExpect(test) {
1799
- const expect2 = (value, message) => {
1800
- const { assertionCalls } = getState();
1801
- setState({ assertionCalls: assertionCalls + 1 });
1810
+ var _a;
1811
+ const expect = (value, message) => {
1812
+ const { assertionCalls } = getState(expect);
1813
+ setState({ assertionCalls: assertionCalls + 1 }, expect);
1802
1814
  const assert2 = chai$1.expect(value, message);
1803
1815
  if (test)
1804
1816
  return assert2.withTest(test);
1805
1817
  else
1806
1818
  return assert2;
1807
1819
  };
1808
- Object.assign(expect2, chai$1.expect);
1809
- expect2.getState = getState;
1810
- expect2.setState = setState;
1811
- expect2.extend = (matchers) => chai$1.expect.extend(expect2, matchers);
1812
- return expect2;
1820
+ Object.assign(expect, chai$1.expect);
1821
+ expect.getState = () => getState(expect);
1822
+ expect.setState = (state) => setState(state, expect);
1823
+ setState({
1824
+ assertionCalls: 0,
1825
+ isExpectingAssertions: false,
1826
+ isExpectingAssertionsError: null,
1827
+ expectedAssertionsNumber: null,
1828
+ expectedAssertionsNumberErrorGen: null,
1829
+ testPath: (_a = test == null ? void 0 : test.suite.file) == null ? void 0 : _a.filepath,
1830
+ currentTestName: test ? getFullName(test) : void 0
1831
+ }, expect);
1832
+ expect.extend = (matchers) => chai$1.expect.extend(expect, matchers);
1833
+ function assertions(expected) {
1834
+ const errorGen = () => new Error(`expected number of assertions to be ${expected}, but got ${expect.getState().assertionCalls}`);
1835
+ if (Error.captureStackTrace)
1836
+ Error.captureStackTrace(errorGen(), assertions);
1837
+ expect.setState({
1838
+ expectedAssertionsNumber: expected,
1839
+ expectedAssertionsNumberErrorGen: errorGen
1840
+ });
1841
+ }
1842
+ function hasAssertions() {
1843
+ const error = new Error("expected any number of assertion, but got none");
1844
+ if (Error.captureStackTrace)
1845
+ Error.captureStackTrace(error, hasAssertions);
1846
+ expect.setState({
1847
+ isExpectingAssertions: true,
1848
+ isExpectingAssertionsError: error
1849
+ });
1850
+ }
1851
+ util.addMethod(expect, "assertions", assertions);
1852
+ util.addMethod(expect, "hasAssertions", hasAssertions);
1853
+ return expect;
1813
1854
  }
1814
- const expect = createExpect();
1855
+ const globalExpect = createExpect();
1856
+ Object.defineProperty(globalThis, GLOBAL_EXPECT, {
1857
+ value: globalExpect
1858
+ });
1815
1859
 
1816
1860
  const collectorContext = {
1817
1861
  tasks: [],
@@ -1860,6 +1904,11 @@ function createTestContext(test) {
1860
1904
  return _expect;
1861
1905
  }
1862
1906
  });
1907
+ Object.defineProperty(context, "_local", {
1908
+ get() {
1909
+ return _expect != null;
1910
+ }
1911
+ });
1863
1912
  return context;
1864
1913
  }
1865
1914
  function makeTimeoutMsg(isHook, timeout) {
@@ -1999,7 +2048,7 @@ function createSuite() {
1999
2048
  suite2.each = (cases) => {
2000
2049
  return (name, fn) => {
2001
2050
  cases.forEach((i, idx) => {
2002
- const items = toArray(i);
2051
+ const items = Array.isArray(i) ? i : [i];
2003
2052
  suite2(formatTitle(name, items, idx), () => fn(...items));
2004
2053
  });
2005
2054
  };
@@ -2013,7 +2062,7 @@ function createTest(fn) {
2013
2062
  test2.each = (cases) => {
2014
2063
  return (name, fn2) => {
2015
2064
  cases.forEach((i, idx) => {
2016
- const items = toArray(i);
2065
+ const items = Array.isArray(i) ? i : [i];
2017
2066
  test2(formatTitle(name, items, idx), () => fn2(...items));
2018
2067
  });
2019
2068
  };
@@ -2080,7 +2129,7 @@ if (typeof commonjsGlobal !== "undefined") {
2080
2129
  globalObject$1 = self;
2081
2130
  }
2082
2131
 
2083
- var global$1 = globalObject$1;
2132
+ var global = globalObject$1;
2084
2133
 
2085
2134
  var call = Function.call;
2086
2135
 
@@ -2788,7 +2837,7 @@ function valueToString(value) {
2788
2837
  var valueToString_1 = valueToString;
2789
2838
 
2790
2839
  var lib = {
2791
- global: global$1,
2840
+ global: global,
2792
2841
  calledInOrder: calledInOrder_1,
2793
2842
  className: className_1,
2794
2843
  deprecated: deprecated,
@@ -4558,7 +4607,11 @@ function withGlobal(_global) {
4558
4607
  /* eslint-enable complexity */
4559
4608
 
4560
4609
  /** @type {FakeTimers} */
4561
- withGlobal(globalObject);
4610
+ const defaultImplementation = withGlobal(globalObject);
4611
+
4612
+ defaultImplementation.timers;
4613
+ defaultImplementation.createClock;
4614
+ defaultImplementation.install;
4562
4615
  var withGlobal_1 = withGlobal;
4563
4616
 
4564
4617
  const RealDate = Date;
@@ -4872,4 +4925,4 @@ function isWatchMode() {
4872
4925
  return getRunningMode() === "watch";
4873
4926
  }
4874
4927
 
4875
- 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 };
4928
+ export { getState as A, GLOBAL_EXPECT as G, RealDate as R, isFirstRun as a, beforeAll as b, afterAll as c, describe as d, beforeEach as e, afterEach as f, createExpect as g, globalExpect 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 };