vitest 1.5.2 → 1.6.0

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 (53) hide show
  1. package/dist/browser.d.ts +1 -1
  2. package/dist/browser.js +1 -1
  3. package/dist/chunks/environments-node.vcoXCoKs.js +19 -0
  4. package/dist/chunks/{integrations-globals.k0N5-dd1.js → integrations-globals.kw4co3rx.js} +7 -6
  5. package/dist/chunks/{runtime-console.kbFEN7E-.js → runtime-console.EO5ha7qv.js} +3 -3
  6. package/dist/chunks/{runtime-runBaseTests.-x-nNuJ_.js → runtime-runBaseTests.oAvMKtQC.js} +16 -16
  7. package/dist/cli.js +2 -2
  8. package/dist/config.cjs +3 -2
  9. package/dist/config.d.ts +1 -1
  10. package/dist/config.js +3 -2
  11. package/dist/coverage.d.ts +1 -1
  12. package/dist/environments.d.ts +1 -1
  13. package/dist/execute.d.ts +6 -4
  14. package/dist/execute.js +3 -3
  15. package/dist/index.d.ts +4 -3
  16. package/dist/index.js +8 -7
  17. package/dist/node.d.ts +2 -2
  18. package/dist/node.js +12 -11
  19. package/dist/{reporters-xEmem8D4.d.ts → reporters-yx5ZTtEV.d.ts} +101 -26
  20. package/dist/reporters.d.ts +1 -1
  21. package/dist/reporters.js +11 -10
  22. package/dist/runners.d.ts +1 -1
  23. package/dist/runners.js +8 -7
  24. package/dist/snapshot.d.ts +9 -0
  25. package/dist/snapshot.js +8 -0
  26. package/dist/{suite-HPAKvIxA.d.ts → suite-IbNSsUWN.d.ts} +1 -1
  27. package/dist/suite.d.ts +3 -3
  28. package/dist/suite.js +5 -4
  29. package/dist/vendor/{base.Xt0Omgh7.js → base.5NT-gWu5.js} +9 -1
  30. package/dist/vendor/{base.gAwDs8Jc.js → base.Ybri3C14.js} +2 -2
  31. package/dist/vendor/{benchmark.eeqk2rd8.js → benchmark.yGkUTKnC.js} +1 -1
  32. package/dist/vendor/{cac.8mXc9Oj6.js → cac.EdDItJD-.js} +38 -15
  33. package/dist/vendor/{cli-api._n4_Wp_j.js → cli-api.E07AF1Yq.js} +155 -46
  34. package/dist/vendor/env.AtSIuHFg.js +7 -0
  35. package/dist/vendor/{execute.2_yoIC01.js → execute.fL3szUAI.js} +8 -3
  36. package/dist/vendor/{index.gHZzsRJQ.js → index.DpVgvm2P.js} +17 -18
  37. package/dist/vendor/{index.GlXSU9xI.js → index.Q04MCqDO.js} +690 -645
  38. package/dist/vendor/{index.ir9i0ywP.js → index.SMVOaj7F.js} +2 -6
  39. package/dist/vendor/{index.0RrMQKD8.js → index.dI9lHwVn.js} +2 -2
  40. package/dist/vendor/{setup-common.7SXMSI--.js → setup-common.8nJLd4ay.js} +1 -1
  41. package/dist/vendor/{utils.VYmeMh-u.js → utils.dEtNIEgr.js} +1 -1
  42. package/dist/vendor/{vi.Y_w82WR8.js → vi.YFlodzP_.js} +1 -1
  43. package/dist/vendor/{vm.I_IsyNig.js → vm.QEE48c0T.js} +135 -43
  44. package/dist/worker.js +8 -2
  45. package/dist/workers/forks.js +4 -4
  46. package/dist/workers/runVmTests.js +13 -10
  47. package/dist/workers/threads.js +4 -4
  48. package/dist/workers/vmForks.js +7 -7
  49. package/dist/workers/vmThreads.js +7 -7
  50. package/dist/workers.d.ts +1 -1
  51. package/dist/workers.js +8 -8
  52. package/package.json +13 -9
  53. package/snapshot.d.ts +1 -0
@@ -1,13 +1,9 @@
1
1
  import { relative } from 'pathe';
2
- import 'std-env';
3
2
  import '@vitest/runner/utils';
4
3
  import '@vitest/utils';
5
4
  import { g as getWorkerState } from './global.CkGT_TMy.js';
5
+ import './env.AtSIuHFg.js';
6
6
 
7
- var _a;
8
- const isNode = typeof process < "u" && typeof process.stdout < "u" && !((_a = process.versions) == null ? void 0 : _a.deno) && !globalThis.window;
9
-
10
- const isWindows = isNode && process.platform === "win32";
11
7
  function getRunMode() {
12
8
  return getWorkerState().config.mode;
13
9
  }
@@ -23,4 +19,4 @@ function removeUndefinedValues(obj) {
23
19
  return obj;
24
20
  }
25
21
 
26
- export { isNode as a, removeUndefinedValues as b, isWindows as c, isRunningInBenchmark as i, relativePath as r };
22
+ export { removeUndefinedValues as a, isRunningInBenchmark as i, relativePath as r };
@@ -1,7 +1,7 @@
1
1
  import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
2
- import { b as bench } from './benchmark.eeqk2rd8.js';
2
+ import { b as bench } from './benchmark.yGkUTKnC.js';
3
3
  import { i as isFirstRun, a as runOnce } from './run-once.Olz_Zkd8.js';
4
- import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.Y_w82WR8.js';
4
+ import { c as createExpect, a as globalExpect, v as vi, b as vitest } from './vi.YFlodzP_.js';
5
5
  import { g as getWorkerState } from './global.CkGT_TMy.js';
6
6
  import * as chai from 'chai';
7
7
  import { assert, should } from 'chai';
@@ -12,7 +12,7 @@ async function setupCommonEnv(config) {
12
12
  globalSetup = true;
13
13
  setSafeTimers();
14
14
  if (config.globals)
15
- (await import('../chunks/integrations-globals.k0N5-dd1.js')).registerApiGlobally();
15
+ (await import('../chunks/integrations-globals.kw4co3rx.js')).registerApiGlobally();
16
16
  }
17
17
  function setupDefines(defines) {
18
18
  for (const key in defines)
@@ -1,6 +1,6 @@
1
1
  import { isAbsolute, relative, dirname, basename } from 'pathe';
2
2
  import c from 'picocolors';
3
- import { a as slash } from './base.Xt0Omgh7.js';
3
+ import { a as slash } from './base.5NT-gWu5.js';
4
4
 
5
5
  const F_RIGHT = "\u2192";
6
6
  const F_DOWN = "\u2193";
@@ -9,7 +9,7 @@ import { g as getFullName } from './tasks.IknbGB2n.js';
9
9
  import { g as getWorkerState, a as getCurrentEnvironment } from './global.CkGT_TMy.js';
10
10
  import { getSafeTimers, assertTypes, createSimpleStackTrace } from '@vitest/utils';
11
11
  import { parseSingleStack } from '@vitest/utils/source-map';
12
- import { i as isChildProcess } from './base.Xt0Omgh7.js';
12
+ import { i as isChildProcess } from './base.5NT-gWu5.js';
13
13
  import { R as RealDate, r as resetDate, m as mockDate } from './date.Ns1pGd_X.js';
14
14
  import { spyOn, fn, isMockFunction, mocks } from '@vitest/spy';
15
15
 
@@ -1,16 +1,18 @@
1
1
  import vm, { isContext } from 'node:vm';
2
2
  import { fileURLToPath, pathToFileURL } from 'node:url';
3
3
  import { dirname, basename, extname, normalize, join, resolve } from 'pathe';
4
- import { createCustomConsole } from '../chunks/runtime-console.kbFEN7E-.js';
5
- import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.2_yoIC01.js';
4
+ import { createCustomConsole } from '../chunks/runtime-console.EO5ha7qv.js';
5
+ import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.fL3szUAI.js';
6
6
  import { distDir } from '../path.js';
7
7
  import { dirname as dirname$1 } from 'node:path';
8
8
  import { statSync, existsSync, readFileSync } from 'node:fs';
9
9
  import { isNodeBuiltin, isPrimitive, toArray, getCachedData, setCacheData } from 'vite-node/utils';
10
10
  import { createRequire, Module } from 'node:module';
11
11
  import { CSS_LANGS_RE, KNOWN_ASSET_RE } from 'vite-node/constants';
12
- import './index.ir9i0ywP.js';
12
+ import '@vitest/runner/utils';
13
+ import '@vitest/utils';
13
14
  import { p as provideWorkerState } from './global.CkGT_TMy.js';
15
+ import './env.AtSIuHFg.js';
14
16
 
15
17
  const _require = createRequire(import.meta.url);
16
18
  const requiresCache = /* @__PURE__ */ new WeakMap();
@@ -242,15 +244,36 @@ function interopCommonJsModule(interopDefault, mod) {
242
244
  const SyntheticModule$1 = vm.SyntheticModule;
243
245
  const SourceTextModule = vm.SourceTextModule;
244
246
 
247
+ var __defProp$1 = Object.defineProperty;
248
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
249
+ var __publicField$1 = (obj, key, value) => {
250
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
251
+ return value;
252
+ };
253
+ var __accessCheck$1 = (obj, member, msg) => {
254
+ if (!member.has(obj))
255
+ throw TypeError("Cannot " + msg);
256
+ };
257
+ var __privateGet$1 = (obj, member, getter) => {
258
+ __accessCheck$1(obj, member, "read from private field");
259
+ return getter ? getter.call(obj) : member.get(obj);
260
+ };
261
+ var __privateAdd$1 = (obj, member, value) => {
262
+ if (member.has(obj))
263
+ throw TypeError("Cannot add the same private member more than once");
264
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
265
+ };
266
+ var _httpIp;
245
267
  const dataURIRegex = /^data:(?<mime>text\/javascript|application\/json|application\/wasm)(?:;(?<encoding>charset=utf-8|base64))?,(?<code>.*)$/;
246
268
  class EsmExecutor {
247
269
  constructor(executor, options) {
248
270
  this.executor = executor;
271
+ __publicField$1(this, "moduleCache", /* @__PURE__ */ new Map());
272
+ __publicField$1(this, "esmLinkMap", /* @__PURE__ */ new WeakMap());
273
+ __publicField$1(this, "context");
274
+ __privateAdd$1(this, _httpIp, IPnumber("127.0.0.0"));
249
275
  this.context = options.context;
250
276
  }
251
- moduleCache = /* @__PURE__ */ new Map();
252
- esmLinkMap = /* @__PURE__ */ new WeakMap();
253
- context;
254
277
  async evaluateModule(m) {
255
278
  if (m.status === "unlinked") {
256
279
  this.esmLinkMap.set(
@@ -263,10 +286,11 @@ class EsmExecutor {
263
286
  await m.evaluate();
264
287
  return m;
265
288
  }
266
- async createEsModule(fileUrl, code) {
289
+ async createEsModule(fileUrl, getCode) {
267
290
  const cached = this.moduleCache.get(fileUrl);
268
291
  if (cached)
269
292
  return cached;
293
+ const code = await getCode();
270
294
  if (fileUrl.endsWith(".json")) {
271
295
  const m2 = new SyntheticModule$1(
272
296
  ["default"],
@@ -300,14 +324,26 @@ class EsmExecutor {
300
324
  this.moduleCache.set(fileUrl, m);
301
325
  return m;
302
326
  }
303
- async createWebAssemblyModule(fileUrl, code) {
327
+ async createWebAssemblyModule(fileUrl, getCode) {
304
328
  const cached = this.moduleCache.get(fileUrl);
305
329
  if (cached)
306
330
  return cached;
307
- const m = this.loadWebAssemblyModule(code, fileUrl);
331
+ const m = this.loadWebAssemblyModule(getCode(), fileUrl);
308
332
  this.moduleCache.set(fileUrl, m);
309
333
  return m;
310
334
  }
335
+ async createNetworkModule(fileUrl) {
336
+ if (fileUrl.startsWith("http:")) {
337
+ const url = new URL(fileUrl);
338
+ if (url.hostname !== "localhost" && url.hostname !== "::1" && (IPnumber(url.hostname) & IPmask(8)) !== __privateGet$1(this, _httpIp)) {
339
+ throw new Error(
340
+ // we don't know the importer, so it's undefined (the same happens in --pool=threads)
341
+ `import of '${fileUrl}' by undefined is not supported: http can only be used to load local resources (use https instead).`
342
+ );
343
+ }
344
+ }
345
+ return this.createEsModule(fileUrl, () => fetch(fileUrl).then((r) => r.text()));
346
+ }
311
347
  async loadWebAssemblyModule(source, identifier) {
312
348
  const cached = this.moduleCache.get(identifier);
313
349
  if (cached)
@@ -391,9 +427,19 @@ class EsmExecutor {
391
427
  this.moduleCache.set(identifier, module);
392
428
  return module;
393
429
  }
394
- return this.createEsModule(identifier, code);
430
+ return this.createEsModule(identifier, () => code);
395
431
  }
396
432
  }
433
+ _httpIp = new WeakMap();
434
+ function IPnumber(address) {
435
+ const ip = address.match(/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/);
436
+ if (ip)
437
+ return (+ip[1] << 24) + (+ip[2] << 16) + (+ip[3] << 8) + +ip[4];
438
+ throw new Error(`Expected IP address, received ${address}`);
439
+ }
440
+ function IPmask(maskSize) {
441
+ return -1 << 32 - maskSize;
442
+ }
397
443
 
398
444
  const CLIENT_ID = "/@vite/client";
399
445
  const CLIENT_FILE = pathToFileURL(CLIENT_ID).href;
@@ -431,10 +477,12 @@ class ViteExecutor {
431
477
  const cached = this.esm.resolveCachedModule(fileUrl);
432
478
  if (cached)
433
479
  return cached;
434
- const result = await this.options.transform(fileUrl, "web");
435
- if (!result.code)
436
- throw new Error(`[vitest] Failed to transform ${fileUrl}. Does the file exist?`);
437
- return this.esm.createEsModule(fileUrl, result.code);
480
+ return this.esm.createEsModule(fileUrl, async () => {
481
+ const result = await this.options.transform(fileUrl, "web");
482
+ if (!result.code)
483
+ throw new Error(`[vitest] Failed to transform ${fileUrl}. Does the file exist?`);
484
+ return result.code;
485
+ });
438
486
  }
439
487
  createViteClientModule() {
440
488
  const identifier = CLIENT_ID;
@@ -474,11 +522,54 @@ class ViteExecutor {
474
522
  };
475
523
  }
476
524
 
525
+ var __defProp = Object.defineProperty;
526
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
527
+ var __publicField = (obj, key, value) => {
528
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
529
+ return value;
530
+ };
531
+ var __accessCheck = (obj, member, msg) => {
532
+ if (!member.has(obj))
533
+ throw TypeError("Cannot " + msg);
534
+ };
535
+ var __privateGet = (obj, member, getter) => {
536
+ __accessCheck(obj, member, "read from private field");
537
+ return getter ? getter.call(obj) : member.get(obj);
538
+ };
539
+ var __privateAdd = (obj, member, value) => {
540
+ if (member.has(obj))
541
+ throw TypeError("Cannot add the same private member more than once");
542
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
543
+ };
544
+ var __privateSet = (obj, member, value, setter) => {
545
+ __accessCheck(obj, member, "write to private field");
546
+ setter ? setter.call(obj, value) : member.set(obj, value);
547
+ return value;
548
+ };
549
+ var _networkSupported;
477
550
  const SyntheticModule = vm.SyntheticModule;
478
551
  const nativeResolve = import.meta.resolve;
479
552
  class ExternalModulesExecutor {
480
553
  constructor(options) {
481
554
  this.options = options;
555
+ __publicField(this, "cjs");
556
+ __publicField(this, "esm");
557
+ __publicField(this, "vite");
558
+ __publicField(this, "context");
559
+ __publicField(this, "fs");
560
+ __publicField(this, "resolvers", []);
561
+ __privateAdd(this, _networkSupported, null);
562
+ // dynamic import can be used in both ESM and CJS, so we have it in the executor
563
+ __publicField(this, "importModuleDynamically", async (specifier, referencer) => {
564
+ const module = await this.resolveModule(specifier, referencer.identifier);
565
+ return this.esm.evaluateModule(module);
566
+ });
567
+ __publicField(this, "resolveModule", async (specifier, referencer) => {
568
+ let identifier = this.resolve(specifier, referencer);
569
+ if (identifier instanceof Promise)
570
+ identifier = await identifier;
571
+ return await this.createModule(identifier);
572
+ });
482
573
  this.context = options.context;
483
574
  this.fs = options.fileMap;
484
575
  this.esm = new EsmExecutor(this, {
@@ -497,23 +588,17 @@ class ExternalModulesExecutor {
497
588
  });
498
589
  this.resolvers = [this.vite.resolve];
499
590
  }
500
- cjs;
501
- esm;
502
- vite;
503
- context;
504
- fs;
505
- resolvers = [];
506
- // dynamic import can be used in both ESM and CJS, so we have it in the executor
507
- importModuleDynamically = async (specifier, referencer) => {
508
- const module = await this.resolveModule(specifier, referencer.identifier);
509
- return this.esm.evaluateModule(module);
510
- };
511
- resolveModule = async (specifier, referencer) => {
512
- let identifier = this.resolve(specifier, referencer);
513
- if (identifier instanceof Promise)
514
- identifier = await identifier;
515
- return await this.createModule(identifier);
516
- };
591
+ async import(identifier) {
592
+ const module = await this.createModule(identifier);
593
+ await this.esm.evaluateModule(module);
594
+ return module.namespace;
595
+ }
596
+ require(identifier) {
597
+ return this.cjs.require(identifier);
598
+ }
599
+ createRequire(identifier) {
600
+ return this.cjs.createRequire(identifier);
601
+ }
517
602
  resolve(specifier, parent) {
518
603
  for (const resolver of this.resolvers) {
519
604
  const id = resolver(specifier, parent);
@@ -585,6 +670,8 @@ class ExternalModulesExecutor {
585
670
  const extension = extname(identifier);
586
671
  if (extension === ".node" || isNodeBuiltin(identifier))
587
672
  return { type: "builtin", url: identifier, path: identifier };
673
+ if (this.isNetworkSupported && (identifier.startsWith("http:") || identifier.startsWith("https:")))
674
+ return { type: "network", url: identifier, path: identifier };
588
675
  const isFileUrl = identifier.startsWith("file://");
589
676
  const pathUrl = isFileUrl ? fileURLToPath(identifier.split("?")[0]) : identifier;
590
677
  const fileUrl = isFileUrl ? identifier : pathToFileURL(pathUrl).toString();
@@ -620,31 +707,36 @@ class ExternalModulesExecutor {
620
707
  case "vite":
621
708
  return await this.vite.createViteModule(url);
622
709
  case "wasm":
623
- return await this.esm.createWebAssemblyModule(url, this.fs.readBuffer(path));
710
+ return await this.esm.createWebAssemblyModule(url, () => this.fs.readBuffer(path));
624
711
  case "module":
625
- return await this.esm.createEsModule(url, this.fs.readFile(path));
712
+ return await this.esm.createEsModule(url, () => this.fs.readFile(path));
626
713
  case "commonjs": {
627
714
  const exports = this.require(path);
628
715
  return this.wrapCommonJsSynteticModule(identifier, exports);
629
716
  }
717
+ case "network": {
718
+ return this.esm.createNetworkModule(url);
719
+ }
630
720
  default: {
631
721
  const _deadend = type;
632
722
  return _deadend;
633
723
  }
634
724
  }
635
725
  }
636
- async import(identifier) {
637
- const module = await this.createModule(identifier);
638
- await this.esm.evaluateModule(module);
639
- return module.namespace;
640
- }
641
- require(identifier) {
642
- return this.cjs.require(identifier);
643
- }
644
- createRequire(identifier) {
645
- return this.cjs.createRequire(identifier);
726
+ get isNetworkSupported() {
727
+ var _a;
728
+ if (__privateGet(this, _networkSupported) == null) {
729
+ if (process.execArgv.includes("--experimental-network-imports"))
730
+ __privateSet(this, _networkSupported, true);
731
+ else if ((_a = process.env.NODE_OPTIONS) == null ? void 0 : _a.includes("--experimental-network-imports"))
732
+ __privateSet(this, _networkSupported, true);
733
+ else
734
+ __privateSet(this, _networkSupported, false);
735
+ }
736
+ return __privateGet(this, _networkSupported);
646
737
  }
647
738
  }
739
+ _networkSupported = new WeakMap();
648
740
 
649
741
  class FileMap {
650
742
  fsCache = /* @__PURE__ */ new Map();
package/dist/worker.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { pathToFileURL } from 'node:url';
2
2
  import { workerId } from 'tinypool';
3
3
  import { ViteNodeRunner, ModuleCacheMap } from 'vite-node/client';
4
+ import { readFileSync } from 'node:fs';
4
5
  import { resolve, normalize } from 'pathe';
5
6
  import { e as environments } from './vendor/index.GVFv9dZ0.js';
6
- import { i as isChildProcess, s as setProcessTitle } from './vendor/base.Xt0Omgh7.js';
7
+ import { i as isChildProcess, s as setProcessTitle } from './vendor/base.5NT-gWu5.js';
7
8
  import { s as setupInspect } from './vendor/inspector.IgLX3ur5.js';
8
9
  import { c as createRuntimeRpc, a as rpcDone } from './vendor/rpc.joBhAkyK.js';
9
10
  import 'node:console';
@@ -31,7 +32,12 @@ async function loadEnvironment(ctx, rpc) {
31
32
  return environments[name];
32
33
  const loader = await createEnvironmentLoader({
33
34
  root: ctx.config.root,
34
- fetchModule: (id) => rpc.fetch(id, "ssr"),
35
+ fetchModule: async (id) => {
36
+ const result = await rpc.fetch(id, "ssr");
37
+ if (result.id)
38
+ return { code: readFileSync(result.id, "utf-8") };
39
+ return result;
40
+ },
35
41
  resolveId: (id, importer) => rpc.resolveId(id, importer, "ssr")
36
42
  });
37
43
  const root = loader.root;
@@ -1,18 +1,18 @@
1
1
  import v8 from 'node:v8';
2
2
  import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../vendor/utils.0uYuCbzo.js';
3
- import { r as runBaseTests } from '../vendor/base.gAwDs8Jc.js';
3
+ import { r as runBaseTests } from '../vendor/base.Ybri3C14.js';
4
4
  import '@vitest/utils';
5
5
  import 'vite-node/client';
6
6
  import '../vendor/global.CkGT_TMy.js';
7
- import '../vendor/execute.2_yoIC01.js';
7
+ import '../vendor/execute.fL3szUAI.js';
8
8
  import 'node:vm';
9
9
  import 'node:url';
10
+ import 'node:fs';
10
11
  import 'vite-node/utils';
11
12
  import 'pathe';
12
13
  import '@vitest/utils/error';
13
14
  import '../path.js';
14
- import 'node:fs';
15
- import '../vendor/base.Xt0Omgh7.js';
15
+ import '../vendor/base.5NT-gWu5.js';
16
16
 
17
17
  class ForksBaseWorker {
18
18
  getRpcOptions() {
@@ -6,32 +6,32 @@ import { performance } from 'node:perf_hooks';
6
6
  import { startTests } from '@vitest/runner';
7
7
  import { setupColors, createColors } from '@vitest/utils';
8
8
  import { installSourcemapsSupport } from 'vite-node/source-map';
9
- import { V as VitestSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from '../vendor/index.gHZzsRJQ.js';
9
+ import { s as setupChaiConfig, r as resolveTestRunner, a as resolveSnapshotEnvironment } from '../vendor/index.DpVgvm2P.js';
10
10
  import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from '../vendor/coverage.E7sG1b3r.js';
11
11
  import { g as getWorkerState } from '../vendor/global.CkGT_TMy.js';
12
- import { V as VitestIndex } from '../vendor/index.0RrMQKD8.js';
13
- import { s as setupCommonEnv } from '../vendor/setup-common.7SXMSI--.js';
12
+ import { V as VitestIndex } from '../vendor/index.dI9lHwVn.js';
13
+ import { s as setupCommonEnv } from '../vendor/setup-common.8nJLd4ay.js';
14
14
  import { c as closeInspector } from '../vendor/inspector.IgLX3ur5.js';
15
15
  import 'chai';
16
- import '@vitest/snapshot/environment';
17
16
  import 'pathe';
18
17
  import '../path.js';
19
18
  import 'node:url';
20
19
  import '../vendor/rpc.joBhAkyK.js';
21
20
  import '../vendor/index.8bPxjt7g.js';
22
- import '../vendor/benchmark.eeqk2rd8.js';
21
+ import '../vendor/benchmark.yGkUTKnC.js';
23
22
  import '@vitest/runner/utils';
24
- import '../vendor/index.ir9i0ywP.js';
23
+ import '../vendor/index.SMVOaj7F.js';
24
+ import '../vendor/env.AtSIuHFg.js';
25
25
  import 'std-env';
26
26
  import '../vendor/run-once.Olz_Zkd8.js';
27
- import '../vendor/vi.Y_w82WR8.js';
27
+ import '../vendor/vi.YFlodzP_.js';
28
28
  import '../vendor/_commonjsHelpers.jjO7Zipk.js';
29
29
  import '@vitest/expect';
30
30
  import '@vitest/snapshot';
31
31
  import '@vitest/utils/error';
32
32
  import '../vendor/tasks.IknbGB2n.js';
33
33
  import '@vitest/utils/source-map';
34
- import '../vendor/base.Xt0Omgh7.js';
34
+ import '../vendor/base.5NT-gWu5.js';
35
35
  import '../vendor/date.Ns1pGd_X.js';
36
36
  import '@vitest/spy';
37
37
 
@@ -42,7 +42,6 @@ async function run(files, config, executor) {
42
42
  value: VitestIndex,
43
43
  enumerable: false
44
44
  });
45
- config.snapshotOptions.snapshotEnvironment = new VitestSnapshotEnvironment(workerState.rpc);
46
45
  setupColors(createColors(isatty(1)));
47
46
  if (workerState.environment.transformMode === "web") {
48
47
  const _require = createRequire(import.meta.url);
@@ -61,7 +60,11 @@ async function run(files, config, executor) {
61
60
  await startCoverageInsideWorker(config.coverage, executor);
62
61
  if (config.chaiConfig)
63
62
  setupChaiConfig(config.chaiConfig);
64
- const runner = await resolveTestRunner(config, executor);
63
+ const [runner, snapshotEnvironment] = await Promise.all([
64
+ resolveTestRunner(config, executor),
65
+ resolveSnapshotEnvironment(config, executor)
66
+ ]);
67
+ config.snapshotOptions.snapshotEnvironment = snapshotEnvironment;
65
68
  workerState.onCancel.then((reason) => {
66
69
  var _a;
67
70
  closeInspector(config);
@@ -1,17 +1,17 @@
1
- import { r as runBaseTests } from '../vendor/base.gAwDs8Jc.js';
1
+ import { r as runBaseTests } from '../vendor/base.Ybri3C14.js';
2
2
  import { a as createThreadsRpcOptions } from '../vendor/utils.0uYuCbzo.js';
3
3
  import 'vite-node/client';
4
4
  import '../vendor/global.CkGT_TMy.js';
5
- import '../vendor/execute.2_yoIC01.js';
5
+ import '../vendor/execute.fL3szUAI.js';
6
6
  import 'node:vm';
7
7
  import 'node:url';
8
+ import 'node:fs';
8
9
  import 'vite-node/utils';
9
10
  import 'pathe';
10
11
  import '@vitest/utils/error';
11
12
  import '../path.js';
12
- import 'node:fs';
13
13
  import '@vitest/utils';
14
- import '../vendor/base.Xt0Omgh7.js';
14
+ import '../vendor/base.5NT-gWu5.js';
15
15
 
16
16
  class ThreadsBaseWorker {
17
17
  getRpcOptions(ctx) {
@@ -1,26 +1,26 @@
1
1
  import v8 from 'node:v8';
2
2
  import { c as createForksRpcOptions, u as unwrapSerializableConfig } from '../vendor/utils.0uYuCbzo.js';
3
- import { r as runVmTests } from '../vendor/vm.I_IsyNig.js';
3
+ import { r as runVmTests } from '../vendor/vm.QEE48c0T.js';
4
4
  import '@vitest/utils';
5
5
  import 'node:vm';
6
6
  import 'node:url';
7
7
  import 'pathe';
8
- import '../chunks/runtime-console.kbFEN7E-.js';
8
+ import '../chunks/runtime-console.EO5ha7qv.js';
9
9
  import 'node:stream';
10
10
  import 'node:console';
11
11
  import 'node:path';
12
12
  import '../vendor/date.Ns1pGd_X.js';
13
- import '../vendor/index.ir9i0ywP.js';
14
- import 'std-env';
15
13
  import '@vitest/runner/utils';
16
14
  import '../vendor/global.CkGT_TMy.js';
17
- import '../vendor/execute.2_yoIC01.js';
15
+ import '../vendor/env.AtSIuHFg.js';
16
+ import 'std-env';
17
+ import '../vendor/execute.fL3szUAI.js';
18
+ import 'node:fs';
18
19
  import 'vite-node/client';
19
20
  import 'vite-node/utils';
20
21
  import '@vitest/utils/error';
21
22
  import '../path.js';
22
- import 'node:fs';
23
- import '../vendor/base.Xt0Omgh7.js';
23
+ import '../vendor/base.5NT-gWu5.js';
24
24
  import 'node:module';
25
25
  import 'vite-node/constants';
26
26
 
@@ -1,25 +1,25 @@
1
1
  import { a as createThreadsRpcOptions } from '../vendor/utils.0uYuCbzo.js';
2
- import { r as runVmTests } from '../vendor/vm.I_IsyNig.js';
2
+ import { r as runVmTests } from '../vendor/vm.QEE48c0T.js';
3
3
  import '@vitest/utils';
4
4
  import 'node:vm';
5
5
  import 'node:url';
6
6
  import 'pathe';
7
- import '../chunks/runtime-console.kbFEN7E-.js';
7
+ import '../chunks/runtime-console.EO5ha7qv.js';
8
8
  import 'node:stream';
9
9
  import 'node:console';
10
10
  import 'node:path';
11
11
  import '../vendor/date.Ns1pGd_X.js';
12
- import '../vendor/index.ir9i0ywP.js';
13
- import 'std-env';
14
12
  import '@vitest/runner/utils';
15
13
  import '../vendor/global.CkGT_TMy.js';
16
- import '../vendor/execute.2_yoIC01.js';
14
+ import '../vendor/env.AtSIuHFg.js';
15
+ import 'std-env';
16
+ import '../vendor/execute.fL3szUAI.js';
17
+ import 'node:fs';
17
18
  import 'vite-node/client';
18
19
  import 'vite-node/utils';
19
20
  import '@vitest/utils/error';
20
21
  import '../path.js';
21
- import 'node:fs';
22
- import '../vendor/base.Xt0Omgh7.js';
22
+ import '../vendor/base.5NT-gWu5.js';
23
23
  import 'node:module';
24
24
  import 'vite-node/constants';
25
25
 
package/dist/workers.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as v8 from 'v8';
2
- import { d as BirpcOptions, e as RuntimeRPC, f as ContextRPC, W as WorkerGlobalState, g as WorkerContext, R as ResolvedConfig } from './reporters-xEmem8D4.js';
2
+ import { d as BirpcOptions, e as RuntimeRPC, f as ContextRPC, W as WorkerGlobalState, g as WorkerContext, R as ResolvedConfig } from './reporters-yx5ZTtEV.js';
3
3
  import { Awaitable } from '@vitest/utils';
4
4
  import 'vite';
5
5
  import '@vitest/runner';
package/dist/workers.js CHANGED
@@ -1,31 +1,31 @@
1
1
  export { c as createForksRpcOptions, a as createThreadsRpcOptions, u as unwrapSerializableConfig } from './vendor/utils.0uYuCbzo.js';
2
2
  export { p as provideWorkerState } from './vendor/global.CkGT_TMy.js';
3
3
  export { run as runVitestWorker } from './worker.js';
4
- export { r as runVmTests } from './vendor/vm.I_IsyNig.js';
5
- export { r as runBaseTests } from './vendor/base.gAwDs8Jc.js';
4
+ export { r as runVmTests } from './vendor/vm.QEE48c0T.js';
5
+ export { r as runBaseTests } from './vendor/base.Ybri3C14.js';
6
6
  import '@vitest/utils';
7
7
  import 'node:url';
8
8
  import 'tinypool';
9
9
  import 'vite-node/client';
10
+ import 'node:fs';
10
11
  import 'pathe';
11
12
  import './vendor/index.GVFv9dZ0.js';
12
13
  import 'node:console';
13
- import './vendor/base.Xt0Omgh7.js';
14
+ import './vendor/base.5NT-gWu5.js';
14
15
  import './vendor/inspector.IgLX3ur5.js';
15
16
  import 'node:module';
16
17
  import './vendor/rpc.joBhAkyK.js';
17
18
  import './vendor/index.8bPxjt7g.js';
18
19
  import 'node:vm';
19
- import './chunks/runtime-console.kbFEN7E-.js';
20
+ import './chunks/runtime-console.EO5ha7qv.js';
20
21
  import 'node:stream';
21
22
  import 'node:path';
22
23
  import './vendor/date.Ns1pGd_X.js';
23
- import './vendor/index.ir9i0ywP.js';
24
- import 'std-env';
25
24
  import '@vitest/runner/utils';
26
- import './vendor/execute.2_yoIC01.js';
25
+ import './vendor/env.AtSIuHFg.js';
26
+ import 'std-env';
27
+ import './vendor/execute.fL3szUAI.js';
27
28
  import 'vite-node/utils';
28
29
  import '@vitest/utils/error';
29
30
  import './path.js';
30
- import 'node:fs';
31
31
  import 'vite-node/constants';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "1.5.2",
4
+ "version": "1.6.0",
5
5
  "description": "Next generation testing framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -91,6 +91,10 @@
91
91
  "./reporters": {
92
92
  "types": "./dist/reporters.d.ts",
93
93
  "default": "./dist/reporters.js"
94
+ },
95
+ "./snapshot": {
96
+ "types": "./dist/snapshot.d.ts",
97
+ "default": "./dist/snapshot.js"
94
98
  }
95
99
  },
96
100
  "main": "./dist/index.js",
@@ -115,8 +119,8 @@
115
119
  "@types/node": "^18.0.0 || >=20.0.0",
116
120
  "happy-dom": "*",
117
121
  "jsdom": "*",
118
- "@vitest/browser": "1.5.2",
119
- "@vitest/ui": "1.5.2"
122
+ "@vitest/browser": "1.6.0",
123
+ "@vitest/ui": "1.6.0"
120
124
  },
121
125
  "peerDependenciesMeta": {
122
126
  "@edge-runtime/vm": {
@@ -153,12 +157,12 @@
153
157
  "tinypool": "^0.8.3",
154
158
  "vite": "^5.0.0",
155
159
  "why-is-node-running": "^2.2.2",
156
- "@vitest/expect": "1.5.2",
157
- "@vitest/runner": "1.5.2",
158
- "@vitest/spy": "1.5.2",
159
- "@vitest/utils": "1.5.2",
160
- "vite-node": "1.5.2",
161
- "@vitest/snapshot": "1.5.2"
160
+ "@vitest/expect": "1.6.0",
161
+ "@vitest/runner": "1.6.0",
162
+ "@vitest/snapshot": "1.6.0",
163
+ "@vitest/spy": "1.6.0",
164
+ "vite-node": "1.6.0",
165
+ "@vitest/utils": "1.6.0"
162
166
  },
163
167
  "devDependencies": {
164
168
  "@ampproject/remapping": "^2.2.1",
package/snapshot.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/snapshot.js'