vitest 4.0.0-beta.11 → 4.0.0-beta.13

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 (55) hide show
  1. package/LICENSE.md +4 -101
  2. package/dist/browser.d.ts +3 -3
  3. package/dist/browser.js +2 -2
  4. package/dist/chunks/{benchmark.LXhJ0F0X.js → benchmark.DHKMYAts.js} +1 -1
  5. package/dist/chunks/{browser.d.Dx7DO_Ce.d.ts → browser.d.D9YV3JvA.d.ts} +1 -1
  6. package/dist/chunks/{cac.elvK37c9.js → cac.BBtYKH7y.js} +16 -9
  7. package/dist/chunks/{cli-api.C7plPyhs.js → cli-api.CeakdBUN.js} +95 -148
  8. package/dist/chunks/{config.d.B_LthbQq.d.ts → config.d.DGazh2r6.d.ts} +3 -1
  9. package/dist/chunks/{console.CiTi59Jy.js → console.CTJL2nuH.js} +3 -5
  10. package/dist/chunks/{coverage.CG6Uhorw.js → coverage.DabP7UTQ.js} +69 -80
  11. package/dist/chunks/{creator.08Gi-vCA.js → creator.DfXDsUyL.js} +6 -8
  12. package/dist/chunks/{global.d.BK3X7FW1.d.ts → global.d.BcFPD2LN.d.ts} +0 -13
  13. package/dist/chunks/{globals.BjvYA-AD.js → globals.DC4ntO86.js} +5 -5
  14. package/dist/chunks/{index.DIWhzsUh.js → index.Bt-upxGS.js} +6 -12
  15. package/dist/chunks/{index.BwBttQPf.js → index.CHrBLuEH.js} +33 -38
  16. package/dist/chunks/{index.X0nbfr6-.js → index.Dc3xnDvT.js} +48 -289
  17. package/dist/chunks/{index.AZOjjqWP.js → index.Dnl38iQ_.js} +2 -2
  18. package/dist/chunks/{index.BhY64fF0.js → index.uLUz1RDt.js} +1 -1
  19. package/dist/chunks/{inspector.CvQD-Nie.js → inspector.Br76Q2Mb.js} +1 -4
  20. package/dist/chunks/{moduleRunner.d.BNa-CL9e.d.ts → moduleRunner.d.CeYc7nZ0.d.ts} +1 -1
  21. package/dist/chunks/{node.BsdMi6DV.js → node.BwAWWjHZ.js} +2 -3
  22. package/dist/chunks/{plugin.d.C5phQR6o.d.ts → plugin.d.COyglhiI.d.ts} +1 -1
  23. package/dist/chunks/{reporters.d.CVzhsTvK.d.ts → reporters.d.xGvTJYG3.d.ts} +41 -4
  24. package/dist/chunks/{resolveSnapshotEnvironment.DQVamkje.js → resolveSnapshotEnvironment.BsJpmVZR.js} +7 -8
  25. package/dist/chunks/{rpc.jKGRSXIH.js → rpc.cD77ENhU.js} +12 -13
  26. package/dist/chunks/{setup-common.NAWRuMRP.js → setup-common.BewgbkTd.js} +5 -5
  27. package/dist/chunks/{startModuleRunner.oAuCu1yL.js → startModuleRunner.DPBo3mme.js} +40 -48
  28. package/dist/chunks/{test.KC5tH8hC.js → test.CTuWuHYH.js} +5 -5
  29. package/dist/chunks/{typechecker.gXq-5P3n.js → typechecker.BfOQ86_a.js} +54 -77
  30. package/dist/chunks/{utils.DGKhod2J.js → utils.CG9h5ccR.js} +1 -4
  31. package/dist/chunks/{vi.CiJ0Laa6.js → vi.B2--mG9U.js} +35 -144
  32. package/dist/chunks/{worker.rPGLlbkW.js → worker.DVTUM2IW.js} +11 -15
  33. package/dist/chunks/{worker.d.B_Fd9M_w.d.ts → worker.d.buwuBpBt.d.ts} +1 -1
  34. package/dist/cli.js +3 -3
  35. package/dist/config.d.ts +6 -6
  36. package/dist/coverage.d.ts +5 -5
  37. package/dist/coverage.js +3 -3
  38. package/dist/environments.js +1 -1
  39. package/dist/index.d.ts +8 -8
  40. package/dist/index.js +5 -5
  41. package/dist/module-evaluator.d.ts +3 -3
  42. package/dist/module-evaluator.js +10 -12
  43. package/dist/module-runner.js +2 -2
  44. package/dist/node.d.ts +8 -8
  45. package/dist/node.js +10 -10
  46. package/dist/reporters.d.ts +5 -5
  47. package/dist/reporters.js +3 -3
  48. package/dist/runners.d.ts +1 -1
  49. package/dist/runners.js +6 -6
  50. package/dist/snapshot.js +2 -2
  51. package/dist/suite.js +2 -2
  52. package/dist/worker-base.js +30 -32
  53. package/dist/worker-vm.js +19 -30
  54. package/dist/workers/runVmTests.js +10 -10
  55. package/package.json +18 -19
@@ -30,9 +30,7 @@ function wrapSerializableConfig(config) {
30
30
  };
31
31
  }
32
32
  function createDefinesScript(define) {
33
- if (!define) return "";
34
- const serializedDefine = serializeDefine(define);
35
- return serializedDefine === "{}" ? "" : `
33
+ return !define || serializeDefine(define) === "{}" ? "" : `
36
34
  const defines = ${serializeDefine(define)}
37
35
  Object.keys(defines).forEach((key) => {
38
36
  const segments = key.split('.')
@@ -244,16 +242,6 @@ const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#
244
242
  * 4. Hash, including "#", optional.
245
243
  */
246
244
  const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
247
- var UrlType;
248
- (function (UrlType) {
249
- UrlType[UrlType["Empty"] = 1] = "Empty";
250
- UrlType[UrlType["Hash"] = 2] = "Hash";
251
- UrlType[UrlType["Query"] = 3] = "Query";
252
- UrlType[UrlType["RelativePath"] = 4] = "RelativePath";
253
- UrlType[UrlType["AbsolutePath"] = 5] = "AbsolutePath";
254
- UrlType[UrlType["SchemeRelative"] = 6] = "SchemeRelative";
255
- UrlType[UrlType["Absolute"] = 7] = "Absolute";
256
- })(UrlType || (UrlType = {}));
257
245
  function isAbsoluteUrl(input) {
258
246
  return schemeRegex.test(input);
259
247
  }
@@ -287,21 +275,21 @@ function makeUrl(scheme, user, host, port, path, query, hash) {
287
275
  path,
288
276
  query,
289
277
  hash,
290
- type: UrlType.Absolute,
278
+ type: 7 /* Absolute */,
291
279
  };
292
280
  }
293
281
  function parseUrl(input) {
294
282
  if (isSchemeRelativeUrl(input)) {
295
283
  const url = parseAbsoluteUrl('http:' + input);
296
284
  url.scheme = '';
297
- url.type = UrlType.SchemeRelative;
285
+ url.type = 6 /* SchemeRelative */;
298
286
  return url;
299
287
  }
300
288
  if (isAbsolutePath(input)) {
301
289
  const url = parseAbsoluteUrl('http://foo.com' + input);
302
290
  url.scheme = '';
303
291
  url.host = '';
304
- url.type = UrlType.AbsolutePath;
292
+ url.type = 5 /* AbsolutePath */;
305
293
  return url;
306
294
  }
307
295
  if (isFileUrl(input))
@@ -313,11 +301,11 @@ function parseUrl(input) {
313
301
  url.host = '';
314
302
  url.type = input
315
303
  ? input.startsWith('?')
316
- ? UrlType.Query
304
+ ? 3 /* Query */
317
305
  : input.startsWith('#')
318
- ? UrlType.Hash
319
- : UrlType.RelativePath
320
- : UrlType.Empty;
306
+ ? 2 /* Hash */
307
+ : 4 /* RelativePath */
308
+ : 1 /* Empty */;
321
309
  return url;
322
310
  }
323
311
  function stripPathFilename(path) {
@@ -345,7 +333,7 @@ function mergePaths(url, base) {
345
333
  * "foo/.". We need to normalize to a standard representation.
346
334
  */
347
335
  function normalizePath(url, type) {
348
- const rel = type <= UrlType.RelativePath;
336
+ const rel = type <= 4 /* RelativePath */;
349
337
  const pieces = url.path.split('/');
350
338
  // We need to preserve the first piece always, so that we output a leading slash. The item at
351
339
  // pieces[0] is an empty string.
@@ -406,27 +394,27 @@ function resolve(input, base) {
406
394
  return '';
407
395
  const url = parseUrl(input);
408
396
  let inputType = url.type;
409
- if (base && inputType !== UrlType.Absolute) {
397
+ if (base && inputType !== 7 /* Absolute */) {
410
398
  const baseUrl = parseUrl(base);
411
399
  const baseType = baseUrl.type;
412
400
  switch (inputType) {
413
- case UrlType.Empty:
401
+ case 1 /* Empty */:
414
402
  url.hash = baseUrl.hash;
415
403
  // fall through
416
- case UrlType.Hash:
404
+ case 2 /* Hash */:
417
405
  url.query = baseUrl.query;
418
406
  // fall through
419
- case UrlType.Query:
420
- case UrlType.RelativePath:
407
+ case 3 /* Query */:
408
+ case 4 /* RelativePath */:
421
409
  mergePaths(url, baseUrl);
422
410
  // fall through
423
- case UrlType.AbsolutePath:
411
+ case 5 /* AbsolutePath */:
424
412
  // The host, user, and port are joined, you can't copy one without the others.
425
413
  url.user = baseUrl.user;
426
414
  url.host = baseUrl.host;
427
415
  url.port = baseUrl.port;
428
416
  // fall through
429
- case UrlType.SchemeRelative:
417
+ case 6 /* SchemeRelative */:
430
418
  // The input doesn't have a schema at least, so we need to copy at least that over.
431
419
  url.scheme = baseUrl.scheme;
432
420
  }
@@ -438,10 +426,10 @@ function resolve(input, base) {
438
426
  switch (inputType) {
439
427
  // This is impossible, because of the empty checks at the start of the function.
440
428
  // case UrlType.Empty:
441
- case UrlType.Hash:
442
- case UrlType.Query:
429
+ case 2 /* Hash */:
430
+ case 3 /* Query */:
443
431
  return queryHash;
444
- case UrlType.RelativePath: {
432
+ case 4 /* RelativePath */: {
445
433
  // The first char is always a "/", and we need it to be relative.
446
434
  const path = url.path.slice(1);
447
435
  if (!path)
@@ -454,7 +442,7 @@ function resolve(input, base) {
454
442
  }
455
443
  return path + queryHash;
456
444
  }
457
- case UrlType.AbsolutePath:
445
+ case 5 /* AbsolutePath */:
458
446
  return url.path + queryHash;
459
447
  default:
460
448
  return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;
@@ -518,6 +506,32 @@ function sortComparator(a, b) {
518
506
  return a[COLUMN] - b[COLUMN];
519
507
  }
520
508
 
509
+ // src/by-source.ts
510
+ function buildBySources(decoded, memos) {
511
+ const sources = memos.map(() => []);
512
+ for (let i = 0; i < decoded.length; i++) {
513
+ const line = decoded[i];
514
+ for (let j = 0; j < line.length; j++) {
515
+ const seg = line[j];
516
+ if (seg.length === 1) continue;
517
+ const sourceIndex2 = seg[SOURCES_INDEX];
518
+ const sourceLine = seg[SOURCE_LINE];
519
+ const sourceColumn = seg[SOURCE_COLUMN];
520
+ const source = sources[sourceIndex2];
521
+ const segs = source[sourceLine] || (source[sourceLine] = []);
522
+ segs.push([sourceColumn, i, seg[COLUMN]]);
523
+ }
524
+ }
525
+ for (let i = 0; i < sources.length; i++) {
526
+ const source = sources[i];
527
+ for (let j = 0; j < source.length; j++) {
528
+ const line = source[j];
529
+ if (line) line.sort(sortComparator);
530
+ }
531
+ }
532
+ return sources;
533
+ }
534
+
521
535
  // src/binary-search.ts
522
536
  var found = false;
523
537
  function binarySearch(haystack, needle, low, high) {
@@ -576,41 +590,6 @@ function memoizedBinarySearch(haystack, needle, state, key) {
576
590
  return state.lastIndex = binarySearch(haystack, needle, low, high);
577
591
  }
578
592
 
579
- // src/by-source.ts
580
- function buildBySources(decoded, memos) {
581
- const sources = memos.map(buildNullArray);
582
- for (let i = 0; i < decoded.length; i++) {
583
- const line = decoded[i];
584
- for (let j = 0; j < line.length; j++) {
585
- const seg = line[j];
586
- if (seg.length === 1) continue;
587
- const sourceIndex2 = seg[SOURCES_INDEX];
588
- const sourceLine = seg[SOURCE_LINE];
589
- const sourceColumn = seg[SOURCE_COLUMN];
590
- const originalSource = sources[sourceIndex2];
591
- const originalLine = originalSource[sourceLine] || (originalSource[sourceLine] = []);
592
- const memo = memos[sourceIndex2];
593
- let index = upperBound(
594
- originalLine,
595
- sourceColumn,
596
- memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine)
597
- );
598
- memo.lastIndex = ++index;
599
- insert(originalLine, index, [sourceColumn, i, seg[COLUMN]]);
600
- }
601
- }
602
- return sources;
603
- }
604
- function insert(array, index, value) {
605
- for (let i = array.length; i > index; i--) {
606
- array[i] = array[i - 1];
607
- }
608
- array[index] = value;
609
- }
610
- function buildNullArray() {
611
- return { __proto__: null };
612
- }
613
-
614
593
  // src/types.ts
615
594
  function parse(map) {
616
595
  return typeof map === "string" ? JSON.parse(map) : map;
@@ -735,7 +714,7 @@ function traceSegmentInternal(segments, memo, line, column, bias) {
735
714
  return index;
736
715
  }
737
716
  function generatedPosition(map, source, line, column, bias, all) {
738
- var _a;
717
+ var _a, _b;
739
718
  line--;
740
719
  if (line < 0) throw new Error(LINE_GTR_ZERO);
741
720
  if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
@@ -743,13 +722,11 @@ function generatedPosition(map, source, line, column, bias, all) {
743
722
  let sourceIndex2 = sources.indexOf(source);
744
723
  if (sourceIndex2 === -1) sourceIndex2 = resolvedSources.indexOf(source);
745
724
  if (sourceIndex2 === -1) return all ? [] : GMapping(null, null);
746
- const generated = (_a = cast(map))._bySources || (_a._bySources = buildBySources(
747
- decodedMappings(map),
748
- cast(map)._bySourceMemos = sources.map(memoizedState)
749
- ));
725
+ const bySourceMemos = (_a = cast(map))._bySourceMemos || (_a._bySourceMemos = sources.map(memoizedState));
726
+ const generated = (_b = cast(map))._bySources || (_b._bySources = buildBySources(decodedMappings(map), bySourceMemos));
750
727
  const segments = generated[sourceIndex2][line];
751
728
  if (segments == null) return all ? [] : GMapping(null, null);
752
- const memo = cast(map)._bySourceMemos[sourceIndex2];
729
+ const memo = bySourceMemos[sourceIndex2];
753
730
  const index = traceSegmentInternal(segments, memo, line, column, bias);
754
731
  if (index === -1) return GMapping(null, null);
755
732
  const segment = segments[index];
@@ -1092,7 +1069,7 @@ async function collectTests(ctx, filepath) {
1092
1069
  if (callee.type === "CallExpression") start = callee.end;
1093
1070
  else if (callee.type === "TaggedTemplateExpression") start = callee.end + 1;
1094
1071
  else start = node.start;
1095
- const { arguments: [messageNode] } = node, isQuoted = messageNode?.type === "Literal" || messageNode?.type === "TemplateLiteral", message = isQuoted ? request.code.slice(messageNode.start + 1, messageNode.end - 1) : request.code.slice(messageNode.start, messageNode.end);
1072
+ const { arguments: [messageNode] } = node, message = messageNode?.type === "Literal" || messageNode?.type === "TemplateLiteral" ? request.code.slice(messageNode.start + 1, messageNode.end - 1) : request.code.slice(messageNode.start, messageNode.end);
1096
1073
  // cannot statically analyze, so we always skip it
1097
1074
  if (mode === "skipIf" || mode === "runIf") mode = "skip";
1098
1075
  definitions.push({
@@ -1180,13 +1157,13 @@ async function makeTscErrorInfo(errInfo) {
1180
1157
  }];
1181
1158
  }
1182
1159
  async function getRawErrsMapFromTsCompile(tscErrorStdout) {
1183
- const rawErrsMap = /* @__PURE__ */ new Map(), infos = await Promise.all(tscErrorStdout.split(newLineRegExp).reduce((prev, next) => {
1160
+ const rawErrsMap = /* @__PURE__ */ new Map();
1161
+ return (await Promise.all(tscErrorStdout.split(newLineRegExp).reduce((prev, next) => {
1184
1162
  if (!next) return prev;
1185
1163
  if (next[0] !== " ") prev.push(next);
1186
1164
  else prev[prev.length - 1] += `\n${next}`;
1187
1165
  return prev;
1188
- }, []).map((errInfoLine) => makeTscErrorInfo(errInfoLine)));
1189
- return infos.forEach(([errFilePath, errInfo]) => {
1166
+ }, []).map((errInfoLine) => makeTscErrorInfo(errInfoLine)))).forEach(([errFilePath, errInfo]) => {
1190
1167
  if (errInfo) if (!rawErrsMap.has(errFilePath)) rawErrsMap.set(errFilePath, [errInfo]);
1191
1168
  else rawErrsMap.get(errFilePath)?.push(errInfo);
1192
1169
  }), rawErrsMap;
@@ -4,10 +4,7 @@ const NAME_WORKER_STATE = "__vitest_worker__";
4
4
  function getWorkerState() {
5
5
  // @ts-expect-error untyped global
6
6
  const workerState = globalThis[NAME_WORKER_STATE];
7
- if (!workerState) {
8
- const errorMsg = "Vitest failed to access its internal state.\n\nOne of the following is possible:\n- \"vitest\" is imported directly without running \"vitest\" command\n- \"vitest\" is imported inside \"globalSetup\" (to fix this, use \"setupFiles\" instead, because \"globalSetup\" runs in a different context)\n- \"vitest\" is imported inside Vite / Vitest config file\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n";
9
- throw new Error(errorMsg);
10
- }
7
+ if (!workerState) throw new Error("Vitest failed to access its internal state.\n\nOne of the following is possible:\n- \"vitest\" is imported directly without running \"vitest\" command\n- \"vitest\" is imported inside \"globalSetup\" (to fix this, use \"setupFiles\" instead, because \"globalSetup\" runs in a different context)\n- \"vitest\" is imported inside Vite / Vitest config file\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n");
11
8
  return workerState;
12
9
  }
13
10
  function provideWorkerState(context, state) {
@@ -1,15 +1,15 @@
1
- import { chai as chai$1, equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters, customMatchers } from '@vitest/expect';
1
+ import { chai, equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters, customMatchers } from '@vitest/expect';
2
2
  import { getCurrentTest } from '@vitest/runner';
3
3
  import { getNames, getTestName } from '@vitest/runner/utils';
4
- import { g as getWorkerState, i as isChildProcess, w as waitForImportsToResolve, r as resetModules } from './utils.DGKhod2J.js';
4
+ import { g as getWorkerState, i as isChildProcess, w as waitForImportsToResolve, r as resetModules } from './utils.CG9h5ccR.js';
5
5
  import { getSafeTimers } from '@vitest/utils/timers';
6
- import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './_commonjsHelpers.BFTU3MAI.js';
7
6
  import { stripSnapshotIndentation, addSerializer, SnapshotClient } from '@vitest/snapshot';
8
7
  import '@vitest/utils/error';
9
8
  import { assertTypes, createSimpleStackTrace } from '@vitest/utils/helpers';
10
9
  import { fn, spyOn, restoreAllMocks, resetAllMocks, clearAllMocks, isMockFunction } from '@vitest/spy';
11
10
  import '@vitest/utils/offset';
12
11
  import { parseSingleStack } from '@vitest/utils/source-map';
12
+ import { c as commonjsGlobal } from './_commonjsHelpers.BFTU3MAI.js';
13
13
  import { R as RealDate, r as resetDate, m as mockDate } from './date.-jtEtIeV.js';
14
14
 
15
15
  // these matchers are not supported because they don't make sense with poll
@@ -27,13 +27,13 @@ const unsupported = [
27
27
  ];
28
28
  function createExpectPoll(expect) {
29
29
  return function poll(fn, options = {}) {
30
- const state = getWorkerState(), defaults = state.config.expect?.poll ?? {}, { interval = defaults.interval ?? 50, timeout = defaults.timeout ?? 1e3, message } = options, assertion = expect(null, message).withContext({ poll: true });
30
+ const defaults = getWorkerState().config.expect?.poll ?? {}, { interval = defaults.interval ?? 50, timeout = defaults.timeout ?? 1e3, message } = options, assertion = expect(null, message).withContext({ poll: true });
31
31
  fn = fn.bind(assertion);
32
- const test = chai$1.util.flag(assertion, "vitest-test");
32
+ const test = chai.util.flag(assertion, "vitest-test");
33
33
  if (!test) throw new Error("expect.poll() must be called inside a test");
34
34
  const proxy = new Proxy(assertion, { get(target, key, receiver) {
35
35
  const assertionFunction = Reflect.get(target, key, receiver);
36
- if (typeof assertionFunction !== "function") return assertionFunction instanceof chai$1.Assertion ? proxy : assertionFunction;
36
+ if (typeof assertionFunction !== "function") return assertionFunction instanceof chai.Assertion ? proxy : assertionFunction;
37
37
  if (key === "assert") return assertionFunction;
38
38
  if (typeof key === "string" && unsupported.includes(key)) throw new SyntaxError(`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`);
39
39
  return function(...args) {
@@ -41,15 +41,15 @@ function createExpectPoll(expect) {
41
41
  let intervalId, timeoutId, lastError;
42
42
  const { setTimeout, clearTimeout } = getSafeTimers(), check = async () => {
43
43
  try {
44
- chai$1.util.flag(assertion, "_name", key);
44
+ chai.util.flag(assertion, "_name", key);
45
45
  const obj = await fn();
46
- chai$1.util.flag(assertion, "object", obj), resolve(await assertionFunction.call(assertion, ...args)), clearTimeout(intervalId), clearTimeout(timeoutId);
46
+ chai.util.flag(assertion, "object", obj), resolve(await assertionFunction.call(assertion, ...args)), clearTimeout(intervalId), clearTimeout(timeoutId);
47
47
  } catch (err) {
48
- if (lastError = err, !chai$1.util.flag(assertion, "_isLastPollAttempt")) intervalId = setTimeout(check, interval);
48
+ if (lastError = err, !chai.util.flag(assertion, "_isLastPollAttempt")) intervalId = setTimeout(check, interval);
49
49
  }
50
50
  };
51
51
  timeoutId = setTimeout(() => {
52
- clearTimeout(intervalId), chai$1.util.flag(assertion, "_isLastPollAttempt", true);
52
+ clearTimeout(intervalId), chai.util.flag(assertion, "_isLastPollAttempt", true);
53
53
  const rejectWithCause = (error) => {
54
54
  if (error.cause == null) error.cause = /* @__PURE__ */ new Error("Matcher did not succeed in time.");
55
55
  reject(copyStackTrace$1(error, STACK_TRACE_ERROR));
@@ -60,7 +60,7 @@ function createExpectPoll(expect) {
60
60
  let awaited = false;
61
61
  test.onFinished ??= [], test.onFinished.push(() => {
62
62
  if (!awaited) {
63
- const negated = chai$1.util.flag(assertion, "negate") ? "not." : "", name = chai$1.util.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)", assertionString = `expect.${name}.${negated}${String(key)}()`, error = /* @__PURE__ */ new Error(`${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:\n\nawait ${assertionString}\n`);
63
+ const negated = chai.util.flag(assertion, "negate") ? "not." : "", assertionString = `expect.${chai.util.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)"}.${negated}${String(key)}()`, error = /* @__PURE__ */ new Error(`${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:\n\nawait ${assertionString}\n`);
64
64
  throw copyStackTrace$1(error, STACK_TRACE_ERROR);
65
65
  }
66
66
  });
@@ -89,108 +89,9 @@ function copyStackTrace$1(target, source) {
89
89
  return target;
90
90
  }
91
91
 
92
- function commonjsRequire(path) {
93
- 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.');
94
- }
95
-
96
- var chaiSubset$1 = {exports: {}};
97
-
98
- var chaiSubset = chaiSubset$1.exports;
99
-
100
- var hasRequiredChaiSubset;
101
-
102
- function requireChaiSubset () {
103
- if (hasRequiredChaiSubset) return chaiSubset$1.exports;
104
- hasRequiredChaiSubset = 1;
105
- (function (module, exports) {
106
- (function() {
107
- (function(chaiSubset) {
108
- if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') {
109
- return module.exports = chaiSubset;
110
- } else {
111
- return chai.use(chaiSubset);
112
- }
113
- })(function(chai, utils) {
114
- var Assertion = chai.Assertion;
115
- var assertionPrototype = Assertion.prototype;
116
-
117
- Assertion.addMethod('containSubset', function (expected) {
118
- var actual = utils.flag(this, 'object');
119
- var showDiff = chai.config.showDiff;
120
-
121
- assertionPrototype.assert.call(this,
122
- compare(expected, actual),
123
- 'expected #{act} to contain subset #{exp}',
124
- 'expected #{act} to not contain subset #{exp}',
125
- expected,
126
- actual,
127
- showDiff
128
- );
129
- });
130
-
131
- chai.assert.containSubset = function(val, exp, msg) {
132
- new chai.Assertion(val, msg).to.be.containSubset(exp);
133
- };
134
-
135
- function compare(expected, actual) {
136
- if (expected === actual) {
137
- return true;
138
- }
139
- if (typeof(actual) !== typeof(expected)) {
140
- return false;
141
- }
142
- if (typeof(expected) !== 'object' || expected === null) {
143
- return expected === actual;
144
- }
145
- if (!!expected && !actual) {
146
- return false;
147
- }
148
-
149
- if (Array.isArray(expected)) {
150
- if (typeof(actual.length) !== 'number') {
151
- return false;
152
- }
153
- var aa = Array.prototype.slice.call(actual);
154
- return expected.every(function (exp) {
155
- return aa.some(function (act) {
156
- return compare(exp, act);
157
- });
158
- });
159
- }
160
-
161
- if (expected instanceof Date) {
162
- if (actual instanceof Date) {
163
- return expected.getTime() === actual.getTime();
164
- } else {
165
- return false;
166
- }
167
- }
168
-
169
- return Object.keys(expected).every(function (key) {
170
- var eo = expected[key];
171
- var ao = actual[key];
172
- if (typeof(eo) === 'object' && eo !== null && ao !== null) {
173
- return compare(eo, ao);
174
- }
175
- if (typeof(eo) === 'function') {
176
- return eo(ao);
177
- }
178
- return ao === eo;
179
- });
180
- }
181
- });
182
-
183
- }).call(chaiSubset);
184
- } (chaiSubset$1));
185
- return chaiSubset$1.exports;
186
- }
187
-
188
- var chaiSubsetExports = requireChaiSubset();
189
- var Subset = /*@__PURE__*/getDefaultExportFromCjs(chaiSubsetExports);
190
-
191
92
  function createAssertionMessage(util, assertion, hasArgs) {
192
- const not = util.flag(assertion, "negate") ? "not." : "", name = `${util.flag(assertion, "_name")}(${"expected" })`, promiseName = util.flag(assertion, "promise"), promise = promiseName ? `.${promiseName}` : "";
193
- return `expect(actual)${promise}.${not}${name}`;
93
+ const not = util.flag(assertion, "negate") ? "not." : "", name = `${util.flag(assertion, "_name")}(${"expected" })`, promiseName = util.flag(assertion, "promise");
94
+ return `expect(actual)${promiseName ? `.${promiseName}` : ""}.${not}${name}`;
194
95
  }
195
96
  function recordAsyncExpect(_test, promise, assertion, error) {
196
97
  const test = _test;
@@ -206,7 +107,7 @@ function recordAsyncExpect(_test, promise, assertion, error) {
206
107
  let resolved = false;
207
108
  return test.onFinished ??= [], test.onFinished.push(() => {
208
109
  if (!resolved) {
209
- const processor = globalThis.__vitest_worker__?.onFilterStackTrace || ((s) => s || ""), stack = processor(error.stack);
110
+ const stack = (globalThis.__vitest_worker__?.onFilterStackTrace || ((s) => s || ""))(error.stack);
210
111
  console.warn([
211
112
  `Promise returned by \`${assertion}\` was not awaited. `,
212
113
  "Vitest currently auto-awaits hanging assertions at the end of the test, but this will cause the test to fail in Vitest 3. ",
@@ -264,9 +165,7 @@ const SnapshotPlugin = (chai, utils) => {
264
165
  return test;
265
166
  }
266
167
  for (const key of ["matchSnapshot", "toMatchSnapshot"]) utils.addMethod(chai.Assertion.prototype, key, function(properties, message) {
267
- utils.flag(this, "_name", key);
268
- const isNot = utils.flag(this, "negate");
269
- if (isNot) throw new Error(`${key} cannot be used with "not"`);
168
+ if (utils.flag(this, "_name", key), utils.flag(this, "negate")) throw new Error(`${key} cannot be used with "not"`);
270
169
  const expected = utils.flag(this, "object"), test = getTest(key, this);
271
170
  if (typeof properties === "string" && typeof message === "undefined") message = properties, properties = void 0;
272
171
  const errorMessage = utils.flag(this, "message");
@@ -280,9 +179,7 @@ const SnapshotPlugin = (chai, utils) => {
280
179
  });
281
180
  });
282
181
  utils.addMethod(chai.Assertion.prototype, "toMatchFileSnapshot", function(file, message) {
283
- utils.flag(this, "_name", "toMatchFileSnapshot");
284
- const isNot = utils.flag(this, "negate");
285
- if (isNot) throw new Error("toMatchFileSnapshot cannot be used with \"not\"");
182
+ if (utils.flag(this, "_name", "toMatchFileSnapshot"), utils.flag(this, "negate")) throw new Error("toMatchFileSnapshot cannot be used with \"not\"");
286
183
  const error = /* @__PURE__ */ new Error("resolves"), expected = utils.flag(this, "object"), test = getTest("toMatchFileSnapshot", this), errorMessage = utils.flag(this, "message"), promise = getSnapshotClient().assertRaw({
287
184
  received: expected,
288
185
  message,
@@ -293,11 +190,9 @@ const SnapshotPlugin = (chai, utils) => {
293
190
  });
294
191
  return recordAsyncExpect(test, promise, createAssertionMessage(utils, this), error);
295
192
  }), utils.addMethod(chai.Assertion.prototype, "toMatchInlineSnapshot", function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
296
- utils.flag(this, "_name", "toMatchInlineSnapshot");
297
- const isNot = utils.flag(this, "negate");
298
- if (isNot) throw new Error("toMatchInlineSnapshot cannot be used with \"not\"");
299
- const test = getTest("toMatchInlineSnapshot", this), isInsideEach = test.each || test.suite?.each;
300
- if (isInsideEach) throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
193
+ if (utils.flag(this, "_name", "toMatchInlineSnapshot"), utils.flag(this, "negate")) throw new Error("toMatchInlineSnapshot cannot be used with \"not\"");
194
+ const test = getTest("toMatchInlineSnapshot", this);
195
+ if (test.each || test.suite?.each) throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
301
196
  const expected = utils.flag(this, "object"), error = utils.flag(this, "error");
302
197
  if (typeof properties === "string") message = inlineSnapshot, inlineSnapshot = properties, properties = void 0;
303
198
  if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
@@ -313,9 +208,7 @@ const SnapshotPlugin = (chai, utils) => {
313
208
  ...getTestNames(test)
314
209
  });
315
210
  }), utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingSnapshot", function(message) {
316
- utils.flag(this, "_name", "toThrowErrorMatchingSnapshot");
317
- const isNot = utils.flag(this, "negate");
318
- if (isNot) throw new Error("toThrowErrorMatchingSnapshot cannot be used with \"not\"");
211
+ if (utils.flag(this, "_name", "toThrowErrorMatchingSnapshot"), utils.flag(this, "negate")) throw new Error("toThrowErrorMatchingSnapshot cannot be used with \"not\"");
319
212
  const expected = utils.flag(this, "object"), test = getTest("toThrowErrorMatchingSnapshot", this), promise = utils.flag(this, "promise"), errorMessage = utils.flag(this, "message");
320
213
  getSnapshotClient().assert({
321
214
  received: getError(expected, promise),
@@ -324,10 +217,9 @@ const SnapshotPlugin = (chai, utils) => {
324
217
  ...getTestNames(test)
325
218
  });
326
219
  }), utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", function __INLINE_SNAPSHOT__(inlineSnapshot, message) {
327
- const isNot = utils.flag(this, "negate");
328
- if (isNot) throw new Error("toThrowErrorMatchingInlineSnapshot cannot be used with \"not\"");
329
- const test = getTest("toThrowErrorMatchingInlineSnapshot", this), isInsideEach = test.each || test.suite?.each;
330
- if (isInsideEach) throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
220
+ if (utils.flag(this, "negate")) throw new Error("toThrowErrorMatchingInlineSnapshot cannot be used with \"not\"");
221
+ const test = getTest("toThrowErrorMatchingInlineSnapshot", this);
222
+ if (test.each || test.suite?.each) throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
331
223
  const expected = utils.flag(this, "object"), error = utils.flag(this, "error"), promise = utils.flag(this, "promise"), errorMessage = utils.flag(this, "message");
332
224
  if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
333
225
  getSnapshotClient().assert({
@@ -342,16 +234,16 @@ const SnapshotPlugin = (chai, utils) => {
342
234
  }), utils.addMethod(chai.expect, "addSnapshotSerializer", addSerializer);
343
235
  };
344
236
 
345
- chai$1.use(JestExtend), chai$1.use(JestChaiExpect), chai$1.use(Subset), chai$1.use(SnapshotPlugin), chai$1.use(JestAsymmetricMatchers);
237
+ chai.use(JestExtend), chai.use(JestChaiExpect), chai.use(SnapshotPlugin), chai.use(JestAsymmetricMatchers);
346
238
 
347
239
  function createExpect(test) {
348
240
  const expect = ((value, message) => {
349
241
  const { assertionCalls } = getState(expect);
350
242
  setState({ assertionCalls: assertionCalls + 1 }, expect);
351
- const assert = chai$1.expect(value, message), _test = test || getCurrentTest();
243
+ const assert = chai.expect(value, message), _test = test || getCurrentTest();
352
244
  return _test ? assert.withTest(_test) : assert;
353
245
  });
354
- Object.assign(expect, chai$1.expect), Object.assign(expect, globalThis[ASYMMETRIC_MATCHERS_OBJECT]), expect.getState = () => getState(expect), expect.setState = (state) => setState(state, expect);
246
+ Object.assign(expect, chai.expect), Object.assign(expect, globalThis[ASYMMETRIC_MATCHERS_OBJECT]), expect.getState = () => getState(expect), expect.setState = (state) => setState(state, expect);
355
247
  // @ts-expect-error global is not typed
356
248
  const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
357
249
  setState({
@@ -365,11 +257,11 @@ function createExpect(test) {
365
257
  return getWorkerState().filepath;
366
258
  },
367
259
  currentTestName: test ? getTestName(test) : globalState.currentTestName
368
- }, expect), expect.extend = (matchers) => chai$1.expect.extend(expect, matchers), expect.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters), expect.soft = (...args) => {
260
+ }, expect), expect.extend = (matchers) => chai.expect.extend(expect, matchers), expect.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters), expect.soft = (...args) => {
369
261
  // @ts-expect-error private soft access
370
262
  return expect(...args).withContext({ soft: true });
371
263
  }, expect.poll = createExpectPoll(expect), expect.unreachable = (message) => {
372
- chai$1.assert.fail(`expected${message ? ` "${message}" ` : " "}not to be reached`);
264
+ chai.assert.fail(`expected${message ? ` "${message}" ` : " "}not to be reached`);
373
265
  };
374
266
  function assertions(expected) {
375
267
  const errorGen = () => /* @__PURE__ */ new Error(`expected number of assertions to be ${expected}, but got ${expect.getState().assertionCalls}`);
@@ -387,7 +279,7 @@ function createExpect(test) {
387
279
  isExpectingAssertionsError: error
388
280
  });
389
281
  }
390
- return chai$1.util.addMethod(expect, "assertions", assertions), chai$1.util.addMethod(expect, "hasAssertions", hasAssertions), expect.extend(customMatchers), expect;
282
+ return chai.util.addMethod(expect, "assertions", assertions), chai.util.addMethod(expect, "hasAssertions", hasAssertions), expect.extend(customMatchers), expect;
391
283
  }
392
284
  const globalExpect = createExpect();
393
285
  Object.defineProperty(globalThis, GLOBAL_EXPECT, {
@@ -395,16 +287,15 @@ Object.defineProperty(globalThis, GLOBAL_EXPECT, {
395
287
  writable: true,
396
288
  configurable: true
397
289
  });
398
- const assert = chai$1.assert;
399
- const should = chai$1.should;
290
+ const assert = chai.assert;
291
+ const should = chai.should;
400
292
 
401
293
  /**
402
294
  * Gives access to injected context provided from the main thread.
403
295
  * This usually returns a value provided by `globalSetup` or an external library.
404
296
  */
405
297
  function inject(key) {
406
- const workerState = getWorkerState();
407
- return workerState.providedContext[key];
298
+ return getWorkerState().providedContext[key];
408
299
  }
409
300
 
410
301
  var fakeTimersSrc = {};
@@ -3859,10 +3750,10 @@ function _mocker() {
3859
3750
  } });
3860
3751
  }
3861
3752
  function getImporter(name) {
3862
- const stackTrace = createSimpleStackTrace({ stackTraceLimit: 5 }), stackArray = stackTrace.split("\n"), importerStackIndex = stackArray.findLastIndex((stack) => {
3753
+ const stackArray = createSimpleStackTrace({ stackTraceLimit: 5 }).split("\n"), importerStackIndex = stackArray.findLastIndex((stack) => {
3863
3754
  return stack.includes(` at Object.${name}`) || stack.includes(`${name}@`);
3864
- }), stack = parseSingleStack(stackArray[importerStackIndex + 1]);
3865
- return stack?.file || "";
3755
+ });
3756
+ return parseSingleStack(stackArray[importerStackIndex + 1])?.file || "";
3866
3757
  }
3867
3758
 
3868
3759
  export { getSnapshotClient as a, assert as b, createExpect as c, vitest as d, globalExpect as g, inject as i, should as s, vi as v };
@@ -4,11 +4,11 @@ import { readFileSync } from 'node:fs';
4
4
  import { isBuiltin } from 'node:module';
5
5
  import { pathToFileURL } from 'node:url';
6
6
  import { resolve } from 'pathe';
7
- import { b as VitestTransport } from './startModuleRunner.oAuCu1yL.js';
8
- import { e as environments } from './index.DIWhzsUh.js';
9
- import { s as setupInspect } from './inspector.CvQD-Nie.js';
10
- import { c as createRuntimeRpc, a as rpcDone } from './rpc.jKGRSXIH.js';
11
- import { i as isChildProcess } from './utils.DGKhod2J.js';
7
+ import { b as VitestTransport } from './startModuleRunner.DPBo3mme.js';
8
+ import { e as environments } from './index.Bt-upxGS.js';
9
+ import { s as setupInspect } from './inspector.Br76Q2Mb.js';
10
+ import { c as createRuntimeRpc, a as rpcDone } from './rpc.cD77ENhU.js';
11
+ import { i as isChildProcess } from './utils.CG9h5ccR.js';
12
12
 
13
13
  function isBuiltinEnvironment(env) {
14
14
  return env in environments;
@@ -24,13 +24,10 @@ async function createEnvironmentLoader(root, rpc) {
24
24
  transport: new VitestTransport({
25
25
  async fetchModule(id, importer, options) {
26
26
  const result = await rpc.fetch(id, importer, "__vitest__", options);
27
- if ("cached" in result) {
28
- const code = readFileSync(result.tmp, "utf-8");
29
- return {
30
- code,
31
- ...result
32
- };
33
- }
27
+ if ("cached" in result) return {
28
+ code: readFileSync(result.tmp, "utf-8"),
29
+ ...result
30
+ };
34
31
  if (isWindows && "externalize" in result)
35
32
  // TODO: vitest returns paths for external modules, but Vite returns file://
36
33
  // https://github.com/vitejs/vite/pull/20449
@@ -119,8 +116,7 @@ function parseRegexp(input) {
119
116
  }
120
117
 
121
118
  if (isChildProcess()) {
122
- const isProfiling = process.execArgv.some((execArg) => execArg.startsWith("--prof") || execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof") || execArg.startsWith("--diagnostic-dir"));
123
- if (isProfiling)
119
+ if (process.execArgv.some((execArg) => execArg.startsWith("--prof") || execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof") || execArg.startsWith("--diagnostic-dir")))
124
120
  // Work-around for nodejs/node#55094
125
121
  process.on("SIGTERM", () => {
126
122
  process.exit();
@@ -186,7 +182,7 @@ function createImportMetaEnvProxy() {
186
182
  ];
187
183
  return new Proxy(process.env, {
188
184
  get(_, key) {
189
- return typeof key === "string" ? booleanKeys.includes(key) ? !!process.env[key] : process.env[key] : void 0;
185
+ if (typeof key === "string") return booleanKeys.includes(key) ? !!process.env[key] : process.env[key];
190
186
  },
191
187
  set(_, key, value) {
192
188
  if (typeof key !== "string") return true;
@@ -1,6 +1,6 @@
1
1
  import { CancelReason, File, TestAnnotation, TaskResultPack, TaskEventPack, FileSpecification, Task } from '@vitest/runner';
2
2
  import { FetchFunctionOptions, FetchResult, EvaluatedModules } from 'vite/module-runner';
3
- import { a as SerializedConfig } from './config.d.B_LthbQq.js';
3
+ import { a as SerializedConfig } from './config.d.DGazh2r6.js';
4
4
  import { F as FetchCachedFileSystemResult, R as ResolveFunctionResult, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.d.BsToaxti.js';
5
5
  import { SnapshotResult } from '@vitest/snapshot';
6
6