vitest 0.12.0 → 0.12.3

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.
@@ -1,5 +1,5 @@
1
1
  import { promises } from 'fs';
2
- import { c as createBirpc } from './chunk-vite-node-utils.20782527.js';
2
+ import { c as createBirpc } from './chunk-vite-node-utils.1536f168.js';
3
3
  import require$$0$1 from 'stream';
4
4
  import require$$0 from 'zlib';
5
5
  import require$$3 from 'net';
@@ -28,6 +28,19 @@ const coverageConfigDefaults = {
28
28
  allowExternal: false,
29
29
  extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
30
30
  };
31
+ const fakeTimersDefaults = {
32
+ loopLimit: 1e4,
33
+ shouldClearNativeTimers: true,
34
+ toFake: [
35
+ "setTimeout",
36
+ "clearTimeout",
37
+ "setInterval",
38
+ "clearInterval",
39
+ "setImmediate",
40
+ "clearImmediate",
41
+ "Date"
42
+ ]
43
+ };
31
44
  const config = {
32
45
  allowOnly: !process.env.CI,
33
46
  watch: !process.env.CI,
@@ -50,7 +63,8 @@ const config = {
50
63
  ui: false,
51
64
  uiBase: "/__vitest__/",
52
65
  open: true,
53
- coverage: coverageConfigDefaults
66
+ coverage: coverageConfigDefaults,
67
+ fakeTimers: fakeTimersDefaults
54
68
  };
55
69
  const configDefaults = Object.freeze(config);
56
70
 
@@ -1,5 +1,5 @@
1
1
  import { g as globalApis } from './chunk-constants.0567483c.js';
2
- import { i as index } from './vendor-entry.b20b007c.js';
2
+ import { i as index } from './vendor-entry.3adaf0b2.js';
3
3
  import 'url';
4
4
  import './chunk-utils-global.a5a8641f.js';
5
5
  import 'tty';
@@ -8,7 +8,7 @@ import 'path';
8
8
  import 'fs';
9
9
  import 'console';
10
10
  import 'stream';
11
- import './chunk-runtime-chain.37b69607.js';
11
+ import './chunk-runtime-chain.221b8dcb.js';
12
12
  import 'chai';
13
13
  import './vendor-_commonjsHelpers.addc3445.js';
14
14
  import './chunk-runtime-rpc.63398738.js';
@@ -16,7 +16,7 @@ import './chunk-utils-timers.f25e8f44.js';
16
16
  import './chunk-integrations-spy.bee66426.js';
17
17
  import 'tinyspy';
18
18
  import 'util';
19
- import './chunk-defaults.23b3ae8a.js';
19
+ import './chunk-defaults.ecb46baf.js';
20
20
  import 'module';
21
21
  import 'crypto';
22
22
 
@@ -7,21 +7,21 @@ import { p as plugins_1, f as format_1, g as getOriginalPos, a as posToNumber, n
7
7
  import { i as isMockFunction, s as spyOn, f as fn, a as spies } from './chunk-integrations-spy.bee66426.js';
8
8
  import require$$0, { format } from 'util';
9
9
 
10
- var __defProp$4 = Object.defineProperty;
10
+ var __defProp$5 = Object.defineProperty;
11
11
  var __defProps$2 = Object.defineProperties;
12
12
  var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
13
- var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
14
- var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
15
- var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
16
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17
- var __spreadValues$4 = (a, b) => {
13
+ var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
14
+ var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
15
+ var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
16
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
17
+ var __spreadValues$5 = (a, b) => {
18
18
  for (var prop in b || (b = {}))
19
- if (__hasOwnProp$4.call(b, prop))
20
- __defNormalProp$4(a, prop, b[prop]);
21
- if (__getOwnPropSymbols$4)
22
- for (var prop of __getOwnPropSymbols$4(b)) {
23
- if (__propIsEnum$4.call(b, prop))
24
- __defNormalProp$4(a, prop, b[prop]);
19
+ if (__hasOwnProp$5.call(b, prop))
20
+ __defNormalProp$5(a, prop, b[prop]);
21
+ if (__getOwnPropSymbols$5)
22
+ for (var prop of __getOwnPropSymbols$5(b)) {
23
+ if (__propIsEnum$5.call(b, prop))
24
+ __defNormalProp$5(a, prop, b[prop]);
25
25
  }
26
26
  return a;
27
27
  };
@@ -34,7 +34,7 @@ function createChainable(keys, fn) {
34
34
  for (const key of keys) {
35
35
  Object.defineProperty(chain2, key, {
36
36
  get() {
37
- return create(__spreadProps$2(__spreadValues$4({}, obj), { [key]: true }));
37
+ return create(__spreadProps$2(__spreadValues$5({}, obj), { [key]: true }));
38
38
  }
39
39
  });
40
40
  }
@@ -454,19 +454,19 @@ const addSerializer = (plugin) => {
454
454
  };
455
455
  const getSerializers = () => PLUGINS;
456
456
 
457
- var __defProp$3 = Object.defineProperty;
458
- var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
459
- var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
460
- var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
461
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
462
- var __spreadValues$3 = (a, b) => {
457
+ var __defProp$4 = Object.defineProperty;
458
+ var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
459
+ var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
460
+ var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
461
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
462
+ var __spreadValues$4 = (a, b) => {
463
463
  for (var prop in b || (b = {}))
464
- if (__hasOwnProp$3.call(b, prop))
465
- __defNormalProp$3(a, prop, b[prop]);
466
- if (__getOwnPropSymbols$3)
467
- for (var prop of __getOwnPropSymbols$3(b)) {
468
- if (__propIsEnum$3.call(b, prop))
469
- __defNormalProp$3(a, prop, b[prop]);
464
+ if (__hasOwnProp$4.call(b, prop))
465
+ __defNormalProp$4(a, prop, b[prop]);
466
+ if (__getOwnPropSymbols$4)
467
+ for (var prop of __getOwnPropSymbols$4(b)) {
468
+ if (__propIsEnum$4.call(b, prop))
469
+ __defNormalProp$4(a, prop, b[prop]);
470
470
  }
471
471
  return a;
472
472
  };
@@ -502,7 +502,7 @@ const removeExtraLineBreaks = (string) => string.length > 2 && string.startsWith
502
502
  const escapeRegex = true;
503
503
  const printFunctionName = false;
504
504
  function serialize(val, indent = 2, formatOverrides = {}) {
505
- return normalizeNewlines(format_1(val, __spreadValues$3({
505
+ return normalizeNewlines(format_1(val, __spreadValues$4({
506
506
  escapeRegex,
507
507
  indent,
508
508
  plugins: getSerializers(),
@@ -565,7 +565,7 @@ function deepMergeArray(target = [], source = []) {
565
565
  }
566
566
  function deepMergeSnapshot(target, source) {
567
567
  if (isObject(target) && isObject(source)) {
568
- const mergedOutput = __spreadValues$3({}, target);
568
+ const mergedOutput = __spreadValues$4({}, target);
569
569
  Object.keys(source).forEach((key) => {
570
570
  if (isObject(source[key]) && !source[key].$$typeof) {
571
571
  if (!(key in target))
@@ -675,19 +675,19 @@ function stripSnapshotIndentation(inlineSnapshot) {
675
675
  return inlineSnapshot;
676
676
  }
677
677
 
678
- var __defProp$2 = Object.defineProperty;
679
- var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
680
- var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
681
- var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
682
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
683
- var __spreadValues$2 = (a, b) => {
678
+ var __defProp$3 = Object.defineProperty;
679
+ var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
680
+ var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
681
+ var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
682
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
683
+ var __spreadValues$3 = (a, b) => {
684
684
  for (var prop in b || (b = {}))
685
- if (__hasOwnProp$2.call(b, prop))
686
- __defNormalProp$2(a, prop, b[prop]);
687
- if (__getOwnPropSymbols$2)
688
- for (var prop of __getOwnPropSymbols$2(b)) {
689
- if (__propIsEnum$2.call(b, prop))
690
- __defNormalProp$2(a, prop, b[prop]);
685
+ if (__hasOwnProp$3.call(b, prop))
686
+ __defNormalProp$3(a, prop, b[prop]);
687
+ if (__getOwnPropSymbols$3)
688
+ for (var prop of __getOwnPropSymbols$3(b)) {
689
+ if (__propIsEnum$3.call(b, prop))
690
+ __defNormalProp$3(a, prop, b[prop]);
691
691
  }
692
692
  return a;
693
693
  };
@@ -708,7 +708,7 @@ class SnapshotState {
708
708
  this.unmatched = 0;
709
709
  this._updateSnapshot = options.updateSnapshot;
710
710
  this.updated = 0;
711
- this._snapshotFormat = __spreadValues$2({
711
+ this._snapshotFormat = __spreadValues$3({
712
712
  printBasicPrototype: false
713
713
  }, options.snapshotFormat);
714
714
  }
@@ -736,7 +736,7 @@ class SnapshotState {
736
736
  throw new Error(`Vitest: Couldn't infer stack frame for inline snapshot.
737
737
  ${JSON.stringify(stacks)}`);
738
738
  }
739
- this._inlineSnapshots.push(__spreadValues$2({
739
+ this._inlineSnapshots.push(__spreadValues$3({
740
740
  snapshot: receivedSerialized
741
741
  }, stack));
742
742
  } else {
@@ -1448,21 +1448,21 @@ Number of calls: ${picocolors.exports.bold(spy.mock.calls.length)}
1448
1448
  utils.addMethod(chai.expect, "addSnapshotSerializer", addSerializer);
1449
1449
  };
1450
1450
 
1451
- var __defProp$1 = Object.defineProperty;
1451
+ var __defProp$2 = Object.defineProperty;
1452
1452
  var __defProps$1 = Object.defineProperties;
1453
1453
  var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
1454
- var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1455
- var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1456
- var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1457
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1458
- var __spreadValues$1 = (a, b) => {
1454
+ var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
1455
+ var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
1456
+ var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
1457
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1458
+ var __spreadValues$2 = (a, b) => {
1459
1459
  for (var prop in b || (b = {}))
1460
- if (__hasOwnProp$1.call(b, prop))
1461
- __defNormalProp$1(a, prop, b[prop]);
1462
- if (__getOwnPropSymbols$1)
1463
- for (var prop of __getOwnPropSymbols$1(b)) {
1464
- if (__propIsEnum$1.call(b, prop))
1465
- __defNormalProp$1(a, prop, b[prop]);
1460
+ if (__hasOwnProp$2.call(b, prop))
1461
+ __defNormalProp$2(a, prop, b[prop]);
1462
+ if (__getOwnPropSymbols$2)
1463
+ for (var prop of __getOwnPropSymbols$2(b)) {
1464
+ if (__propIsEnum$2.call(b, prop))
1465
+ __defNormalProp$2(a, prop, b[prop]);
1466
1466
  }
1467
1467
  return a;
1468
1468
  };
@@ -1474,7 +1474,7 @@ class AsymmetricMatcher {
1474
1474
  this.$$typeof = Symbol.for("jest.asymmetricMatcher");
1475
1475
  }
1476
1476
  getMatcherContext() {
1477
- return __spreadProps$1(__spreadValues$1({}, getState()), {
1477
+ return __spreadProps$1(__spreadValues$2({}, getState()), {
1478
1478
  equals,
1479
1479
  isNot: this.inverse,
1480
1480
  utils: matcherUtils
@@ -1648,21 +1648,21 @@ const JestAsymmetricMatchers = (chai, utils) => {
1648
1648
  };
1649
1649
  };
1650
1650
 
1651
- var __defProp = Object.defineProperty;
1651
+ var __defProp$1 = Object.defineProperty;
1652
1652
  var __defProps = Object.defineProperties;
1653
1653
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
1654
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
1655
- var __hasOwnProp = Object.prototype.hasOwnProperty;
1656
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
1657
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1658
- var __spreadValues = (a, b) => {
1654
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
1655
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
1656
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
1657
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1658
+ var __spreadValues$1 = (a, b) => {
1659
1659
  for (var prop in b || (b = {}))
1660
- if (__hasOwnProp.call(b, prop))
1661
- __defNormalProp(a, prop, b[prop]);
1662
- if (__getOwnPropSymbols)
1663
- for (var prop of __getOwnPropSymbols(b)) {
1664
- if (__propIsEnum.call(b, prop))
1665
- __defNormalProp(a, prop, b[prop]);
1660
+ if (__hasOwnProp$1.call(b, prop))
1661
+ __defNormalProp$1(a, prop, b[prop]);
1662
+ if (__getOwnPropSymbols$1)
1663
+ for (var prop of __getOwnPropSymbols$1(b)) {
1664
+ if (__propIsEnum$1.call(b, prop))
1665
+ __defNormalProp$1(a, prop, b[prop]);
1666
1666
  }
1667
1667
  return a;
1668
1668
  };
@@ -1672,11 +1672,11 @@ const getMatcherState = (assertion) => {
1672
1672
  const obj = assertion._obj;
1673
1673
  const isNot = util.flag(assertion, "negate");
1674
1674
  const promise = util.flag(assertion, "promise") || "";
1675
- const jestUtils = __spreadProps(__spreadValues({}, matcherUtils), {
1675
+ const jestUtils = __spreadProps(__spreadValues$1({}, matcherUtils), {
1676
1676
  iterableEquality,
1677
1677
  subsetEquality
1678
1678
  });
1679
- const matcherState = __spreadProps(__spreadValues({}, getState()), {
1679
+ const matcherState = __spreadProps(__spreadValues$1({}, getState()), {
1680
1680
  isNot,
1681
1681
  utils: jestUtils,
1682
1682
  promise,
@@ -4572,13 +4572,29 @@ function resetDate() {
4572
4572
  globalThis.Date = RealDate;
4573
4573
  }
4574
4574
 
4575
+ var __defProp = Object.defineProperty;
4576
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4577
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4578
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
4579
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4580
+ var __spreadValues = (a, b) => {
4581
+ for (var prop in b || (b = {}))
4582
+ if (__hasOwnProp.call(b, prop))
4583
+ __defNormalProp(a, prop, b[prop]);
4584
+ if (__getOwnPropSymbols)
4585
+ for (var prop of __getOwnPropSymbols(b)) {
4586
+ if (__propIsEnum.call(b, prop))
4587
+ __defNormalProp(a, prop, b[prop]);
4588
+ }
4589
+ return a;
4590
+ };
4575
4591
  class FakeTimers {
4576
4592
  constructor({
4577
4593
  global,
4578
- maxLoops = 1e4
4594
+ config
4579
4595
  }) {
4580
4596
  this._now = RealDate.now;
4581
- this._maxLoops = maxLoops;
4597
+ this._userConfig = config;
4582
4598
  this._fakingDate = false;
4583
4599
  this._fakingTime = false;
4584
4600
  this._fakeTimers = withGlobal_1(global);
@@ -4633,12 +4649,10 @@ class FakeTimers {
4633
4649
  }
4634
4650
  if (!this._fakingTime) {
4635
4651
  const toFake = Object.keys(this._fakeTimers.timers);
4636
- this._clock = this._fakeTimers.install({
4637
- loopLimit: this._maxLoops,
4652
+ this._clock = this._fakeTimers.install(__spreadValues({
4638
4653
  now: Date.now(),
4639
- toFake,
4640
- shouldClearNativeTimers: true
4641
- });
4654
+ toFake
4655
+ }, this._userConfig));
4642
4656
  this._fakingTime = true;
4643
4657
  }
4644
4658
  }
@@ -4665,6 +4679,9 @@ class FakeTimers {
4665
4679
  return this._clock.countTimers();
4666
4680
  return 0;
4667
4681
  }
4682
+ configure(config) {
4683
+ this._userConfig = config;
4684
+ }
4668
4685
  _checkFakeTimers() {
4669
4686
  if (!this._fakingTime) {
4670
4687
  throw new Error('Timers are not mocked. Try calling "vi.useFakeTimers()" first.');
@@ -4677,18 +4694,25 @@ class VitestUtils {
4677
4694
  constructor() {
4678
4695
  this.spyOn = spyOn;
4679
4696
  this.fn = fn;
4680
- this._timers = new FakeTimers({
4681
- global: globalThis,
4682
- maxLoops: 1e4
4683
- });
4684
4697
  this._mocker = typeof __vitest_mocker__ !== "undefined" ? __vitest_mocker__ : null;
4685
4698
  this._mockedDate = null;
4686
4699
  if (!this._mocker) {
4687
4700
  const errorMsg = 'Vitest was initialized with native Node instead of Vite Node.\n\nOne of the following is possible:\n- "vitest" is imported outside of your tests (in that case, use "vitest/node" or import.meta.vitest)\n- "vitest" is imported inside "globalSetup" (use "setupFiles", because "globalSetup" runs in a different context)\n- Your dependency inside "node_modules" imports "vitest" directly (in that case, inline that dependency, using "deps.inline" config)\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n';
4688
4701
  throw new Error(errorMsg);
4689
4702
  }
4703
+ const workerState = getWorkerState();
4704
+ this._timers = new FakeTimers({
4705
+ global: globalThis,
4706
+ config: workerState.config.fakeTimers
4707
+ });
4690
4708
  }
4691
- useFakeTimers() {
4709
+ useFakeTimers(config) {
4710
+ if (config) {
4711
+ this._timers.configure(config);
4712
+ } else {
4713
+ const workerState = getWorkerState();
4714
+ this._timers.configure(workerState.config.fakeTimers);
4715
+ }
4692
4716
  this._timers.useFakeTimers();
4693
4717
  return this;
4694
4718
  }
@@ -1,4 +1,4 @@
1
- import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.20782527.js';
1
+ import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.1536f168.js';
2
2
  import { normalizePath } from 'vite';
3
3
  import { a as getWorkerState, C as isWindows, D as mergeSlashes, d as dirname, f as basename, h as resolve, E as getType, F as getAllProperties, s as slash } from './chunk-utils-global.a5a8641f.js';
4
4
  import { existsSync, readdirSync } from 'fs';
@@ -191,7 +191,10 @@ const _VitestMocker = class {
191
191
  }
192
192
  if (typeof mock === "function" && !callstack.includes(`mock:${dep}`)) {
193
193
  callstack.push(`mock:${dep}`);
194
- return this.callFunctionMock(dep, mock);
194
+ const result = await this.callFunctionMock(dep, mock);
195
+ const indexMock = callstack.indexOf(`mock:${dep}`);
196
+ callstack.splice(indexMock, 1);
197
+ return result;
195
198
  }
196
199
  if (typeof mock === "string" && !callstack.includes(mock))
197
200
  dep = mock;
@@ -14,8 +14,8 @@ import require$$0$1 from 'util';
14
14
  import require$$0$2 from 'stream';
15
15
  import require$$2 from 'events';
16
16
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
17
- import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.20782527.js';
18
- import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.23b3ae8a.js';
17
+ import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.1536f168.js';
18
+ import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.ecb46baf.js';
19
19
  import { MessageChannel } from 'worker_threads';
20
20
  import { Tinypool } from 'tinypool';
21
21
  import { performance } from 'perf_hooks';
@@ -23,7 +23,7 @@ import { e as stripAnsi, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as
23
23
  import MagicString from './chunk-magic-string.d5e0e473.js';
24
24
  import { p as prompts } from './vendor-index.405e58ef.js';
25
25
 
26
- var version = "0.12.0";
26
+ var version = "0.12.3";
27
27
 
28
28
  function stripFinalNewline(input) {
29
29
  const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
@@ -8201,7 +8201,6 @@ function createFakePool(ctx) {
8201
8201
  };
8202
8202
  return {
8203
8203
  runTests: runWithFiles("run"),
8204
- collectTests: runWithFiles("collect"),
8205
8204
  close: async () => {
8206
8205
  }
8207
8206
  };
@@ -8210,7 +8209,7 @@ function createWorkerPool(ctx) {
8210
8209
  const threadsCount = ctx.config.watch ? Math.max(cpus().length / 2, 1) : Math.max(cpus().length - 1, 1);
8211
8210
  const options = {
8212
8211
  filename: workerPath,
8213
- useAtomics: typeof process.versions.webcontainer !== "string",
8212
+ useAtomics: false,
8214
8213
  maxThreads: ctx.config.maxThreads ?? threadsCount,
8215
8214
  minThreads: ctx.config.minThreads ?? threadsCount
8216
8215
  };
@@ -8239,7 +8238,6 @@ function createWorkerPool(ctx) {
8239
8238
  };
8240
8239
  return {
8241
8240
  runTests: runWithFiles("run"),
8242
- collectTests: runWithFiles("collect"),
8243
8241
  close: async () => {
8244
8242
  }
8245
8243
  };
@@ -10938,7 +10936,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
10938
10936
  await ctx.setServer(options, server);
10939
10937
  haveStarted = true;
10940
10938
  if (options.api && options.watch)
10941
- (await import('./chunk-api-setup.87a943bf.js')).setup(ctx);
10939
+ (await import('./chunk-api-setup.ed61899f.js')).setup(ctx);
10942
10940
  if (!options.watch)
10943
10941
  await server.watcher.close();
10944
10942
  }
@@ -11048,6 +11046,8 @@ async function startVitest(cliFilters, options, viteOverrides) {
11048
11046
  options.coverage = { enabled: options.coverage };
11049
11047
  const ctx = await createVitest(options, viteOverrides);
11050
11048
  process.env.VITEST_MODE = ctx.config.watch ? "WATCH" : "RUN";
11049
+ if (ctx.config.env)
11050
+ Object.assign(process.env, ctx.config.env);
11051
11051
  if (ctx.config.coverage.enabled) {
11052
11052
  if (!await ensurePackageInstalled("c8")) {
11053
11053
  process.exitCode = 1;
@@ -9003,10 +9003,9 @@ ${getStack()}`), 2e3);
9003
9003
  exports.default = value;
9004
9004
  },
9005
9005
  get exports() {
9006
- return exports.default;
9006
+ return exports;
9007
9007
  }
9008
9008
  };
9009
- let require;
9010
9009
  const context = this.prepareContext({
9011
9010
  __vite_ssr_import__: request,
9012
9011
  __vite_ssr_dynamic_import__: request,
@@ -9014,11 +9013,7 @@ ${getStack()}`), 2e3);
9014
9013
  __vite_ssr_exportAll__: (obj) => exportAll(exports, obj),
9015
9014
  __vite_ssr_import_meta__: { url },
9016
9015
  __vitest_resolve_id__: resolveId,
9017
- require: (path) => {
9018
- if (!require)
9019
- require = createRequire(url);
9020
- return require(path);
9021
- },
9016
+ require: createRequire(url),
9022
9017
  exports,
9023
9018
  module: moduleProxy,
9024
9019
  __filename,
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import { p as picocolors } from './chunk-utils-global.a5a8641f.js';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.25eaf4e5.js';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.6124d286.js';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
@@ -18,10 +18,10 @@ import 'os';
18
18
  import 'vite';
19
19
  import './chunk-constants.0567483c.js';
20
20
  import 'readline';
21
- import './chunk-vite-node-utils.20782527.js';
21
+ import './chunk-vite-node-utils.1536f168.js';
22
22
  import 'module';
23
23
  import 'vm';
24
- import './chunk-defaults.23b3ae8a.js';
24
+ import './chunk-defaults.ecb46baf.js';
25
25
  import 'worker_threads';
26
26
  import 'tinypool';
27
27
  import 'perf_hooks';
package/dist/config.cjs CHANGED
@@ -27,6 +27,19 @@ const coverageConfigDefaults = {
27
27
  allowExternal: false,
28
28
  extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
29
29
  };
30
+ const fakeTimersDefaults = {
31
+ loopLimit: 1e4,
32
+ shouldClearNativeTimers: true,
33
+ toFake: [
34
+ "setTimeout",
35
+ "clearTimeout",
36
+ "setInterval",
37
+ "clearInterval",
38
+ "setImmediate",
39
+ "clearImmediate",
40
+ "Date"
41
+ ]
42
+ };
30
43
  const config = {
31
44
  allowOnly: !process.env.CI,
32
45
  watch: !process.env.CI,
@@ -49,7 +62,8 @@ const config = {
49
62
  ui: false,
50
63
  uiBase: "/__vitest__/",
51
64
  open: true,
52
- coverage: coverageConfigDefaults
65
+ coverage: coverageConfigDefaults,
66
+ fakeTimers: fakeTimersDefaults
53
67
  };
54
68
  const configDefaults = Object.freeze(config);
55
69
 
package/dist/config.d.ts CHANGED
@@ -1,6 +1,72 @@
1
1
  import { UserConfig as UserConfig$2 } from 'vite';
2
2
  import { UserConfig as UserConfig$1, ResolvedC8Options } from 'vitest';
3
3
 
4
+ // Type definitions for @sinonjs/fake-timers 8.1
5
+ // Project: https://github.com/sinonjs/fake-timers
6
+ // Definitions by: Wim Looman <https://github.com/Nemo157>
7
+ // Rogier Schouten <https://github.com/rogierschouten>
8
+ // Yishai Zehavi <https://github.com/zyishai>
9
+ // Remco Haszing <https://github.com/remcohaszing>
10
+ // Jaden Simon <https://github.com/JadenSimon>
11
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
12
+ // TypeScript Version: 2.3
13
+
14
+ /**
15
+ * Names of clock methods that may be faked by install.
16
+ */
17
+ type FakeMethod =
18
+ | 'setTimeout'
19
+ | 'clearTimeout'
20
+ | 'setImmediate'
21
+ | 'clearImmediate'
22
+ | 'setInterval'
23
+ | 'clearInterval'
24
+ | 'Date'
25
+ | 'nextTick'
26
+ | 'hrtime'
27
+ | 'requestAnimationFrame'
28
+ | 'cancelAnimationFrame'
29
+ | 'requestIdleCallback'
30
+ | 'cancelIdleCallback'
31
+ | 'performance'
32
+ | 'queueMicrotask';
33
+
34
+ interface FakeTimerInstallOpts {
35
+ /**
36
+ * Installs fake timers with the specified unix epoch (default: 0)
37
+ */
38
+ now?: number | Date | undefined;
39
+
40
+ /**
41
+ * An array with names of global methods and APIs to fake. By default, `@sinonjs/fake-timers` does not replace `nextTick()` and `queueMicrotask()`.
42
+ * For instance, `FakeTimers.install({ toFake: ['setTimeout', 'nextTick'] })` will fake only `setTimeout()` and `nextTick()`
43
+ */
44
+ toFake?: FakeMethod[] | undefined;
45
+
46
+ /**
47
+ * The maximum number of timers that will be run when calling runAll() (default: 1000)
48
+ */
49
+ loopLimit?: number | undefined;
50
+
51
+ /**
52
+ * Tells @sinonjs/fake-timers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by
53
+ * 20ms for every 20ms change in the real system time) (default: false)
54
+ */
55
+ shouldAdvanceTime?: boolean | undefined;
56
+
57
+ /**
58
+ * Relevant only when using with shouldAdvanceTime: true. increment mocked time by advanceTimeDelta ms every advanceTimeDelta ms change
59
+ * in the real system time (default: 20)
60
+ */
61
+ advanceTimeDelta?: number | undefined;
62
+
63
+ /**
64
+ * Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers. These are not cleared by
65
+ * default, leading to potentially unexpected behavior if timers existed prior to installing FakeTimers. (default: false)
66
+ */
67
+ shouldClearNativeTimers?: boolean | undefined;
68
+ }
69
+
4
70
  declare const config: {
5
71
  allowOnly: boolean;
6
72
  watch: boolean;
@@ -24,6 +90,7 @@ declare const config: {
24
90
  uiBase: string;
25
91
  open: boolean;
26
92
  coverage: ResolvedC8Options;
93
+ fakeTimers: FakeTimerInstallOpts;
27
94
  };
28
95
  declare const configDefaults: Required<Pick<UserConfig$1, keyof typeof config>>;
29
96
 
package/dist/config.js CHANGED
@@ -23,6 +23,19 @@ const coverageConfigDefaults = {
23
23
  allowExternal: false,
24
24
  extension: [".js", ".cjs", ".mjs", ".ts", ".tsx", ".jsx", ".vue", ".svelte"]
25
25
  };
26
+ const fakeTimersDefaults = {
27
+ loopLimit: 1e4,
28
+ shouldClearNativeTimers: true,
29
+ toFake: [
30
+ "setTimeout",
31
+ "clearTimeout",
32
+ "setInterval",
33
+ "clearInterval",
34
+ "setImmediate",
35
+ "clearImmediate",
36
+ "Date"
37
+ ]
38
+ };
26
39
  const config = {
27
40
  allowOnly: !process.env.CI,
28
41
  watch: !process.env.CI,
@@ -45,7 +58,8 @@ const config = {
45
58
  ui: false,
46
59
  uiBase: "/__vitest__/",
47
60
  open: true,
48
- coverage: coverageConfigDefaults
61
+ coverage: coverageConfigDefaults,
62
+ fakeTimers: fakeTimersDefaults
49
63
  };
50
64
  const configDefaults = Object.freeze(config);
51
65
 
package/dist/entry.js CHANGED
@@ -1,4 +1,4 @@
1
- export { r as run } from './vendor-entry.b20b007c.js';
1
+ export { r as run } from './vendor-entry.3adaf0b2.js';
2
2
  import 'fs';
3
3
  import './chunk-utils-global.a5a8641f.js';
4
4
  import 'tty';
@@ -6,7 +6,7 @@ import 'local-pkg';
6
6
  import 'path';
7
7
  import 'console';
8
8
  import 'stream';
9
- import './chunk-runtime-chain.37b69607.js';
9
+ import './chunk-runtime-chain.221b8dcb.js';
10
10
  import 'chai';
11
11
  import './vendor-_commonjsHelpers.addc3445.js';
12
12
  import './chunk-runtime-rpc.63398738.js';
@@ -14,7 +14,7 @@ import './chunk-utils-timers.f25e8f44.js';
14
14
  import './chunk-integrations-spy.bee66426.js';
15
15
  import 'tinyspy';
16
16
  import 'util';
17
- import './chunk-defaults.23b3ae8a.js';
17
+ import './chunk-defaults.ecb46baf.js';
18
18
  import 'module';
19
19
  import 'url';
20
20
  import 'crypto';
package/dist/index.d.ts CHANGED
@@ -196,6 +196,72 @@ interface RawMatcherFn<T extends MatcherState = MatcherState> {
196
196
  }
197
197
  declare type MatchersObject<T extends MatcherState = MatcherState> = Record<string, RawMatcherFn<T>>;
198
198
 
199
+ // Type definitions for @sinonjs/fake-timers 8.1
200
+ // Project: https://github.com/sinonjs/fake-timers
201
+ // Definitions by: Wim Looman <https://github.com/Nemo157>
202
+ // Rogier Schouten <https://github.com/rogierschouten>
203
+ // Yishai Zehavi <https://github.com/zyishai>
204
+ // Remco Haszing <https://github.com/remcohaszing>
205
+ // Jaden Simon <https://github.com/JadenSimon>
206
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
207
+ // TypeScript Version: 2.3
208
+
209
+ /**
210
+ * Names of clock methods that may be faked by install.
211
+ */
212
+ type FakeMethod =
213
+ | 'setTimeout'
214
+ | 'clearTimeout'
215
+ | 'setImmediate'
216
+ | 'clearImmediate'
217
+ | 'setInterval'
218
+ | 'clearInterval'
219
+ | 'Date'
220
+ | 'nextTick'
221
+ | 'hrtime'
222
+ | 'requestAnimationFrame'
223
+ | 'cancelAnimationFrame'
224
+ | 'requestIdleCallback'
225
+ | 'cancelIdleCallback'
226
+ | 'performance'
227
+ | 'queueMicrotask';
228
+
229
+ interface FakeTimerInstallOpts {
230
+ /**
231
+ * Installs fake timers with the specified unix epoch (default: 0)
232
+ */
233
+ now?: number | Date | undefined;
234
+
235
+ /**
236
+ * An array with names of global methods and APIs to fake. By default, `@sinonjs/fake-timers` does not replace `nextTick()` and `queueMicrotask()`.
237
+ * For instance, `FakeTimers.install({ toFake: ['setTimeout', 'nextTick'] })` will fake only `setTimeout()` and `nextTick()`
238
+ */
239
+ toFake?: FakeMethod[] | undefined;
240
+
241
+ /**
242
+ * The maximum number of timers that will be run when calling runAll() (default: 1000)
243
+ */
244
+ loopLimit?: number | undefined;
245
+
246
+ /**
247
+ * Tells @sinonjs/fake-timers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by
248
+ * 20ms for every 20ms change in the real system time) (default: false)
249
+ */
250
+ shouldAdvanceTime?: boolean | undefined;
251
+
252
+ /**
253
+ * Relevant only when using with shouldAdvanceTime: true. increment mocked time by advanceTimeDelta ms every advanceTimeDelta ms change
254
+ * in the real system time (default: 20)
255
+ */
256
+ advanceTimeDelta?: number | undefined;
257
+
258
+ /**
259
+ * Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers. These are not cleared by
260
+ * default, leading to potentially unexpected behavior if timers existed prior to installing FakeTimers. (default: false)
261
+ */
262
+ shouldClearNativeTimers?: boolean | undefined;
263
+ }
264
+
199
265
  declare class ModuleCacheMap extends Map<string, ModuleCache$1> {
200
266
  normalizePath(fsPath: string): string;
201
267
  set(fsPath: string, mod: Partial<ModuleCache$1>): this;
@@ -333,7 +399,6 @@ declare class SnapshotManager {
333
399
  declare type RunWithFiles = (files: string[], invalidates?: string[]) => Promise<void>;
334
400
  interface WorkerPool {
335
401
  runTests: RunWithFiles;
336
- collectTests: RunWithFiles;
337
402
  close: () => Promise<void>;
338
403
  }
339
404
 
@@ -758,6 +823,7 @@ declare type TaskResultPack = [id: string, result: TaskResult | undefined];
758
823
  interface Suite extends TaskBase {
759
824
  type: 'suite';
760
825
  tasks: Task[];
826
+ filepath?: string;
761
827
  }
762
828
  interface File extends Suite {
763
829
  filepath: string;
@@ -810,8 +876,8 @@ declare type SuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'onl
810
876
  };
811
877
  declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return | void>;
812
878
  interface SuiteHooks {
813
- beforeAll: HookListener<[Suite], () => Awaitable<void>>[];
814
- afterAll: HookListener<[Suite]>[];
879
+ beforeAll: HookListener<[Suite | File], () => Awaitable<void>>[];
880
+ afterAll: HookListener<[Suite | File]>[];
815
881
  beforeEach: HookListener<[TestContext, Suite], () => Awaitable<void>>[];
816
882
  afterEach: HookListener<[TestContext, Suite]>[];
817
883
  }
@@ -1069,7 +1135,7 @@ interface InlineConfig {
1069
1135
  /**
1070
1136
  * Pattern of file paths to be ignore from triggering watch rerun
1071
1137
  *
1072
- * @default ['**\/node_modules\/**', '**\/dist/**']
1138
+ * @default [/\/node_modules\//, /\/dist\//]
1073
1139
  */
1074
1140
  watchIgnore?: (string | RegExp)[];
1075
1141
  /**
@@ -1166,6 +1232,14 @@ interface InlineConfig {
1166
1232
  * Show heap usage after each test. Usefull for debugging memory leaks.
1167
1233
  */
1168
1234
  logHeapUsage?: boolean;
1235
+ /**
1236
+ * Custom environment variables assigned to `process.env` before running tests.
1237
+ */
1238
+ env?: Record<string, string>;
1239
+ /**
1240
+ * Options for @sinon/fake-timers
1241
+ */
1242
+ fakeTimers?: FakeTimerInstallOpts;
1169
1243
  }
1170
1244
  interface UserConfig extends InlineConfig {
1171
1245
  /**
@@ -1380,7 +1454,7 @@ declare class VitestUtils {
1380
1454
  private _mockedDate;
1381
1455
  private _mocker;
1382
1456
  constructor();
1383
- useFakeTimers(): this;
1457
+ useFakeTimers(config?: FakeTimerInstallOpts): this;
1384
1458
  useRealTimers(): this;
1385
1459
  runOnlyPendingTimers(): this;
1386
1460
  runAllTimers(): this;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.37b69607.js';
1
+ export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.221b8dcb.js';
2
2
  export { assert, default as chai, should } from 'chai';
3
3
  import './vendor-_commonjsHelpers.addc3445.js';
4
4
  import './chunk-runtime-rpc.63398738.js';
package/dist/node.d.ts CHANGED
@@ -211,6 +211,72 @@ declare type OldPlugin = {
211
211
  declare type Plugin = NewPlugin | OldPlugin;
212
212
  declare type Plugins = Array<Plugin>;
213
213
 
214
+ // Type definitions for @sinonjs/fake-timers 8.1
215
+ // Project: https://github.com/sinonjs/fake-timers
216
+ // Definitions by: Wim Looman <https://github.com/Nemo157>
217
+ // Rogier Schouten <https://github.com/rogierschouten>
218
+ // Yishai Zehavi <https://github.com/zyishai>
219
+ // Remco Haszing <https://github.com/remcohaszing>
220
+ // Jaden Simon <https://github.com/JadenSimon>
221
+ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
222
+ // TypeScript Version: 2.3
223
+
224
+ /**
225
+ * Names of clock methods that may be faked by install.
226
+ */
227
+ type FakeMethod =
228
+ | 'setTimeout'
229
+ | 'clearTimeout'
230
+ | 'setImmediate'
231
+ | 'clearImmediate'
232
+ | 'setInterval'
233
+ | 'clearInterval'
234
+ | 'Date'
235
+ | 'nextTick'
236
+ | 'hrtime'
237
+ | 'requestAnimationFrame'
238
+ | 'cancelAnimationFrame'
239
+ | 'requestIdleCallback'
240
+ | 'cancelIdleCallback'
241
+ | 'performance'
242
+ | 'queueMicrotask';
243
+
244
+ interface FakeTimerInstallOpts {
245
+ /**
246
+ * Installs fake timers with the specified unix epoch (default: 0)
247
+ */
248
+ now?: number | Date | undefined;
249
+
250
+ /**
251
+ * An array with names of global methods and APIs to fake. By default, `@sinonjs/fake-timers` does not replace `nextTick()` and `queueMicrotask()`.
252
+ * For instance, `FakeTimers.install({ toFake: ['setTimeout', 'nextTick'] })` will fake only `setTimeout()` and `nextTick()`
253
+ */
254
+ toFake?: FakeMethod[] | undefined;
255
+
256
+ /**
257
+ * The maximum number of timers that will be run when calling runAll() (default: 1000)
258
+ */
259
+ loopLimit?: number | undefined;
260
+
261
+ /**
262
+ * Tells @sinonjs/fake-timers to increment mocked time automatically based on the real system time shift (e.g. the mocked time will be incremented by
263
+ * 20ms for every 20ms change in the real system time) (default: false)
264
+ */
265
+ shouldAdvanceTime?: boolean | undefined;
266
+
267
+ /**
268
+ * Relevant only when using with shouldAdvanceTime: true. increment mocked time by advanceTimeDelta ms every advanceTimeDelta ms change
269
+ * in the real system time (default: 20)
270
+ */
271
+ advanceTimeDelta?: number | undefined;
272
+
273
+ /**
274
+ * Tells FakeTimers to clear 'native' (i.e. not fake) timers by delegating to their respective handlers. These are not cleared by
275
+ * default, leading to potentially unexpected behavior if timers existed prior to installing FakeTimers. (default: false)
276
+ */
277
+ shouldClearNativeTimers?: boolean | undefined;
278
+ }
279
+
214
280
  declare abstract class BaseReporter implements Reporter {
215
281
  start: number;
216
282
  end: number;
@@ -521,6 +587,7 @@ declare type TaskResultPack = [id: string, result: TaskResult | undefined];
521
587
  interface Suite extends TaskBase {
522
588
  type: 'suite';
523
589
  tasks: Task[];
590
+ filepath?: string;
524
591
  }
525
592
  interface File extends Suite {
526
593
  filepath: string;
@@ -536,8 +603,8 @@ interface Test<ExtraContext = {}> extends TaskBase {
536
603
  declare type Task = Test | Suite | File;
537
604
  declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return | void>;
538
605
  interface SuiteHooks {
539
- beforeAll: HookListener<[Suite], () => Awaitable<void>>[];
540
- afterAll: HookListener<[Suite]>[];
606
+ beforeAll: HookListener<[Suite | File], () => Awaitable<void>>[];
607
+ afterAll: HookListener<[Suite | File]>[];
541
608
  beforeEach: HookListener<[TestContext, Suite], () => Awaitable<void>>[];
542
609
  afterEach: HookListener<[TestContext, Suite]>[];
543
610
  }
@@ -770,7 +837,7 @@ interface InlineConfig {
770
837
  /**
771
838
  * Pattern of file paths to be ignore from triggering watch rerun
772
839
  *
773
- * @default ['**\/node_modules\/**', '**\/dist/**']
840
+ * @default [/\/node_modules\//, /\/dist\//]
774
841
  */
775
842
  watchIgnore?: (string | RegExp)[];
776
843
  /**
@@ -867,6 +934,14 @@ interface InlineConfig {
867
934
  * Show heap usage after each test. Usefull for debugging memory leaks.
868
935
  */
869
936
  logHeapUsage?: boolean;
937
+ /**
938
+ * Custom environment variables assigned to `process.env` before running tests.
939
+ */
940
+ env?: Record<string, string>;
941
+ /**
942
+ * Options for @sinon/fake-timers
943
+ */
944
+ fakeTimers?: FakeTimerInstallOpts;
870
945
  }
871
946
  interface UserConfig extends InlineConfig {
872
947
  /**
@@ -927,7 +1002,6 @@ declare class SnapshotManager {
927
1002
  declare type RunWithFiles = (files: string[], invalidates?: string[]) => Promise<void>;
928
1003
  interface WorkerPool {
929
1004
  runTests: RunWithFiles;
930
- collectTests: RunWithFiles;
931
1005
  close: () => Promise<void>;
932
1006
  }
933
1007
 
package/dist/node.js CHANGED
@@ -1,5 +1,5 @@
1
- export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.25eaf4e5.js';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.ee72d19a.js';
1
+ export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.6124d286.js';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.acd615bd.js';
3
3
  import 'buffer';
4
4
  import 'path';
5
5
  import 'child_process';
@@ -19,10 +19,10 @@ import 'local-pkg';
19
19
  import 'vite';
20
20
  import './chunk-constants.0567483c.js';
21
21
  import 'readline';
22
- import './chunk-vite-node-utils.20782527.js';
22
+ import './chunk-vite-node-utils.1536f168.js';
23
23
  import 'module';
24
24
  import 'vm';
25
- import './chunk-defaults.23b3ae8a.js';
25
+ import './chunk-defaults.ecb46baf.js';
26
26
  import 'worker_threads';
27
27
  import 'tinypool';
28
28
  import 'perf_hooks';
@@ -1,13 +1,13 @@
1
1
  import { promises } from 'fs';
2
- import { a as getWorkerState, t as toArray, G as clone, E as getType, l as relative, A as stdout, H as partitionSuiteChildren, I as hasTests, q as hasFailed, o as getFullName, r as resetModules } from './chunk-utils-global.a5a8641f.js';
2
+ import { a as getWorkerState, t as toArray, G as clone, E as getType, l as relative, H as partitionSuiteChildren, I as hasTests, q as hasFailed, o as getFullName, r as resetModules } from './chunk-utils-global.a5a8641f.js';
3
3
  import { Console } from 'console';
4
4
  import { Writable } from 'stream';
5
5
  import { importModule } from 'local-pkg';
6
- import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as expect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, z as getFn, A as getState } from './chunk-runtime-chain.37b69607.js';
6
+ import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as expect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, z as getFn, A as getState } from './chunk-runtime-chain.221b8dcb.js';
7
7
  import chai, { assert, should, util } from 'chai';
8
8
  import { r as rpc } from './chunk-runtime-rpc.63398738.js';
9
9
  import { d as clearTimeout, c as setTimeout, s as stringify } from './chunk-utils-timers.f25e8f44.js';
10
- import { t as takeCoverage } from './chunk-defaults.23b3ae8a.js';
10
+ import { t as takeCoverage } from './chunk-defaults.ecb46baf.js';
11
11
  import { createHash } from 'crypto';
12
12
  import { format } from 'util';
13
13
 
@@ -495,7 +495,7 @@ async function setupGlobalEnv(config) {
495
495
  globalSetup = true;
496
496
  setupConsoleLogSpy();
497
497
  if (config.globals)
498
- (await import('./chunk-integrations-globals.a37b2801.js')).registerApiGlobally();
498
+ (await import('./chunk-integrations-globals.60fc66ef.js')).registerApiGlobally();
499
499
  }
500
500
  function setupDefines(defines) {
501
501
  for (const key in defines)
@@ -522,33 +522,39 @@ function setupConsoleLogSpy() {
522
522
  }
523
523
  function sendStdout(taskId) {
524
524
  const buffer = stdoutBuffer.get(taskId);
525
- if (buffer) {
526
- const timer = timers.get(taskId);
527
- rpc().onUserConsoleLog({
528
- type: "stdout",
529
- content: buffer.map((i) => String(i)).join(""),
530
- taskId,
531
- time: timer.stdoutTime || RealDate.now(),
532
- size: buffer.length
533
- });
534
- stdoutBuffer.set(taskId, []);
535
- timer.stdoutTime = 0;
536
- }
525
+ if (!buffer)
526
+ return;
527
+ const content = buffer.map((i) => String(i)).join("");
528
+ if (!content.trim())
529
+ return;
530
+ const timer = timers.get(taskId);
531
+ rpc().onUserConsoleLog({
532
+ type: "stdout",
533
+ content,
534
+ taskId,
535
+ time: timer.stdoutTime || RealDate.now(),
536
+ size: buffer.length
537
+ });
538
+ stdoutBuffer.set(taskId, []);
539
+ timer.stdoutTime = 0;
537
540
  }
538
541
  function sendStderr(taskId) {
539
542
  const buffer = stderrBuffer.get(taskId);
540
- if (buffer) {
541
- const timer = timers.get(taskId);
542
- rpc().onUserConsoleLog({
543
- type: "stderr",
544
- content: buffer.map((i) => String(i)).join(""),
545
- taskId,
546
- time: timer.stderrTime || RealDate.now(),
547
- size: buffer.length
548
- });
549
- stderrBuffer.set(taskId, []);
550
- timer.stderrTime = 0;
551
- }
543
+ if (!buffer)
544
+ return;
545
+ const content = buffer.map((i) => String(i)).join("");
546
+ if (!content.trim())
547
+ return;
548
+ const timer = timers.get(taskId);
549
+ rpc().onUserConsoleLog({
550
+ type: "stderr",
551
+ content,
552
+ taskId,
553
+ time: timer.stderrTime || RealDate.now(),
554
+ size: buffer.length
555
+ });
556
+ stderrBuffer.set(taskId, []);
557
+ timer.stderrTime = 0;
552
558
  }
553
559
  const stdout = new Writable({
554
560
  write(data, encoding, callback) {
@@ -652,6 +658,9 @@ function serializeError(val, seen = /* @__PURE__ */ new WeakMap()) {
652
658
  return clone2;
653
659
  }
654
660
  }
661
+ function normalizeErrorMessage(message) {
662
+ return message.replace(/__vite_ssr_import_\d+__\./g, "");
663
+ }
655
664
  function processError(err) {
656
665
  if (!err)
657
666
  return err;
@@ -668,6 +677,10 @@ function processError(err) {
668
677
  err.expected = stringify(err.expected);
669
678
  if (typeof err.actual !== "string")
670
679
  err.actual = stringify(err.actual);
680
+ if (typeof err.message === "string")
681
+ err.message = normalizeErrorMessage(err.message);
682
+ if (typeof err.cause === "object" && err.cause.message === "string")
683
+ err.cause.message = normalizeErrorMessage(err.cause.message);
671
684
  try {
672
685
  return serializeError(err);
673
686
  } catch (e) {
@@ -748,7 +761,6 @@ async function collectTests(paths, config) {
748
761
  state: "fail",
749
762
  error: processError(e)
750
763
  };
751
- stdout().write("\0");
752
764
  }
753
765
  calculateHash(file);
754
766
  const hasOnlyTasks = someTasksAreOnly(file);
package/dist/worker.js CHANGED
@@ -1,7 +1,7 @@
1
- import { h as resolve, a as getWorkerState, A as stdout } from './chunk-utils-global.a5a8641f.js';
2
- import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.20782527.js';
1
+ import { h as resolve, a as getWorkerState } from './chunk-utils-global.a5a8641f.js';
2
+ import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.1536f168.js';
3
3
  import { d as distDir } from './chunk-constants.0567483c.js';
4
- import { e as executeInViteNode } from './chunk-runtime-mocker.ee72d19a.js';
4
+ import { e as executeInViteNode } from './chunk-runtime-mocker.acd615bd.js';
5
5
  import { r as rpc } from './chunk-runtime-rpc.63398738.js';
6
6
  import 'tty';
7
7
  import 'local-pkg';
@@ -54,7 +54,6 @@ async function startViteNode(ctx) {
54
54
  function init(ctx) {
55
55
  if (typeof __vitest_worker__ !== "undefined" && ctx.config.threads && ctx.config.isolate)
56
56
  throw new Error(`worker for ${ctx.files.join(",")} already initialized by ${getWorkerState().ctx.files.join(",")}. This is probably an internal bug of Vitest.`);
57
- stdout().write("\0");
58
57
  const { config, port, id } = ctx;
59
58
  process.env.VITEST_WORKER_ID = String(id);
60
59
  globalThis.__vitest_worker__ = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "0.12.0",
4
+ "version": "0.12.3",
5
5
  "description": "A blazing fast unit test framework powered by Vite",
6
6
  "keywords": [
7
7
  "vite",
@@ -81,7 +81,7 @@
81
81
  "local-pkg": "^0.4.1",
82
82
  "tinypool": "^0.1.3",
83
83
  "tinyspy": "^0.3.2",
84
- "vite": "^2.9.7"
84
+ "vite": "^2.9.8"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@antfu/install-pkg": "^0.1.0",
@@ -93,7 +93,7 @@
93
93
  "@types/node": "^17.0.31",
94
94
  "@types/prompts": "^2.4.0",
95
95
  "@types/sinonjs__fake-timers": "^8.1.2",
96
- "@vitest/ui": "0.12.0",
96
+ "@vitest/ui": "0.12.3",
97
97
  "birpc": "^0.2.2",
98
98
  "c8": "^7.11.2",
99
99
  "cac": "^6.7.12",
@@ -120,7 +120,7 @@
120
120
  "source-map-js": "^1.0.2",
121
121
  "strip-ansi": "^7.0.1",
122
122
  "typescript": "^4.6.4",
123
- "vite-node": "0.12.0",
123
+ "vite-node": "0.12.3",
124
124
  "ws": "^8.6.0"
125
125
  },
126
126
  "engines": {