vitest 0.0.77 → 0.0.81

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.
@@ -2,8 +2,8 @@ import { resolve } from 'path';
2
2
  import { fileURLToPath } from 'url';
3
3
 
4
4
  const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
5
- const defaultIncludes = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
6
- const defaultExcludes = ["**/node_modules/**", "**/dist/**"];
5
+ const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
6
+ const defaultExclude = ["**/node_modules/**", "**/dist/**"];
7
7
  const defaultPort = 51204;
8
8
  const API_PATH = "/__vitest_api__";
9
9
  const configFiles = [
@@ -22,14 +22,13 @@ const globalApis = [
22
22
  "chai",
23
23
  "expect",
24
24
  "assert",
25
- "sinon",
26
25
  "spy",
27
- "mock",
28
- "stub",
26
+ "spyOn",
27
+ "vitest",
29
28
  "beforeAll",
30
29
  "afterAll",
31
30
  "beforeEach",
32
31
  "afterEach"
33
32
  ];
34
33
 
35
- export { API_PATH as A, defaultExcludes as a, defaultPort as b, configFiles as c, defaultIncludes as d, distDir as e, globalApis as g };
34
+ export { API_PATH as A, defaultExclude as a, defaultPort as b, configFiles as c, defaultInclude as d, distDir as e, globalApis as g };
package/dist/entry.js CHANGED
@@ -2,12 +2,12 @@ import { Console } from 'console';
2
2
  import { Writable } from 'stream';
3
3
  import { importModule } from 'local-pkg';
4
4
  import chai, { expect, util } from 'chai';
5
- import SinonChai from 'sinon-chai';
6
5
  import Subset from 'chai-subset';
7
6
  import path, { basename } from 'path';
7
+ import { r as rpc, s as send } from './rpc-7de86f29.js';
8
8
  import { g as getNames, t as toArray, i as interpretOnlyMode, p as partitionSuiteChildren, c as hasTests, h as hasFailed } from './utils-9dcc4050.js';
9
9
  import fs from 'fs';
10
- import { d as c$1, m as generateDiff } from './error-c9295525.js';
10
+ import { d as c$1, m as generateDiff } from './error-6bb44a98.js';
11
11
  import { performance } from 'perf_hooks';
12
12
  import { b as setHooks, c as createSuiteHooks, e as clearContext, f as defaultSuite, h as context, j as getHooks, k as getFn } from './suite-95be5909.js';
13
13
  import { n as nanoid } from './index-9e71c815.js';
@@ -296,15 +296,6 @@ const environments = {
296
296
  "happy-dom": happy
297
297
  };
298
298
 
299
- const rpc = async (method, ...args) => {
300
- var _a;
301
- return (_a = process.__vitest_worker__) == null ? void 0 : _a.rpc(method, ...args);
302
- };
303
- const send = async (method, ...args) => {
304
- var _a;
305
- return (_a = process.__vitest_worker__) == null ? void 0 : _a.send(method, ...args);
306
- };
307
-
308
299
  var naturalCompare$2 = {exports: {}};
309
300
 
310
301
  /*
@@ -752,7 +743,7 @@ const asymmetricMatcher =
752
743
  : 0x1357a5;
753
744
  const SPACE$2 = ' ';
754
745
 
755
- const serialize$7 = (val, config, indentation, depth, refs, printer) => {
746
+ const serialize$8 = (val, config, indentation, depth, refs, printer) => {
756
747
  const stringedValue = val.toString();
757
748
 
758
749
  if (
@@ -828,13 +819,13 @@ const serialize$7 = (val, config, indentation, depth, refs, printer) => {
828
819
  return val.toAsymmetricMatcher();
829
820
  };
830
821
 
831
- AsymmetricMatcher$2.serialize = serialize$7;
822
+ AsymmetricMatcher$2.serialize = serialize$8;
832
823
 
833
824
  const test$6 = val => val && val.$$typeof === asymmetricMatcher;
834
825
 
835
826
  AsymmetricMatcher$2.test = test$6;
836
827
  const plugin$6 = {
837
- serialize: serialize$7,
828
+ serialize: serialize$8,
838
829
  test: test$6
839
830
  };
840
831
  var _default$7 = plugin$6;
@@ -935,12 +926,12 @@ const test$5 = val =>
935
926
 
936
927
  ConvertAnsi.test = test$5;
937
928
 
938
- const serialize$6 = (val, config, indentation, depth, refs, printer) =>
929
+ const serialize$7 = (val, config, indentation, depth, refs, printer) =>
939
930
  printer(toHumanReadableAnsi(val), config, indentation, depth, refs);
940
931
 
941
- ConvertAnsi.serialize = serialize$6;
932
+ ConvertAnsi.serialize = serialize$7;
942
933
  const plugin$5 = {
943
- serialize: serialize$6,
934
+ serialize: serialize$7,
944
935
  test: test$5
945
936
  };
946
937
  var _default$6 = plugin$5;
@@ -981,7 +972,7 @@ DOMCollection$2.test = test$4;
981
972
  const isNamedNodeMap = collection =>
982
973
  collection.constructor.name === 'NamedNodeMap';
983
974
 
984
- const serialize$5 = (collection, config, indentation, depth, refs, printer) => {
975
+ const serialize$6 = (collection, config, indentation, depth, refs, printer) => {
985
976
  const name = collection.constructor.name;
986
977
 
987
978
  if (++depth > config.maxDepth) {
@@ -1019,9 +1010,9 @@ const serialize$5 = (collection, config, indentation, depth, refs, printer) => {
1019
1010
  );
1020
1011
  };
1021
1012
 
1022
- DOMCollection$2.serialize = serialize$5;
1013
+ DOMCollection$2.serialize = serialize$6;
1023
1014
  const plugin$4 = {
1024
- serialize: serialize$5,
1015
+ serialize: serialize$6,
1025
1016
  test: test$4
1026
1017
  };
1027
1018
  var _default$5 = plugin$4;
@@ -1269,7 +1260,7 @@ function nodeIsFragment(node) {
1269
1260
  return node.nodeType === FRAGMENT_NODE;
1270
1261
  }
1271
1262
 
1272
- const serialize$4 = (node, config, indentation, depth, refs, printer) => {
1263
+ const serialize$5 = (node, config, indentation, depth, refs, printer) => {
1273
1264
  if (nodeIsText(node)) {
1274
1265
  return (0, _markup$2.printText)(node.data, config);
1275
1266
  }
@@ -1319,9 +1310,9 @@ const serialize$4 = (node, config, indentation, depth, refs, printer) => {
1319
1310
  );
1320
1311
  };
1321
1312
 
1322
- DOMElement$2.serialize = serialize$4;
1313
+ DOMElement$2.serialize = serialize$5;
1323
1314
  const plugin$3 = {
1324
- serialize: serialize$4,
1315
+ serialize: serialize$5,
1325
1316
  test: test$3
1326
1317
  };
1327
1318
  var _default$4 = plugin$3;
@@ -1504,7 +1495,7 @@ const printImmutableValues = (
1504
1495
  ) +
1505
1496
  ']';
1506
1497
 
1507
- const serialize$3 = (val, config, indentation, depth, refs, printer) => {
1498
+ const serialize$4 = (val, config, indentation, depth, refs, printer) => {
1508
1499
  if (val[IS_MAP_SENTINEL]) {
1509
1500
  return printImmutableEntries(
1510
1501
  val,
@@ -1561,7 +1552,7 @@ const serialize$3 = (val, config, indentation, depth, refs, printer) => {
1561
1552
  }; // Explicitly comparing sentinel properties to true avoids false positive
1562
1553
  // when mock identity-obj-proxy returns the key as the value for any key.
1563
1554
 
1564
- Immutable$2.serialize = serialize$3;
1555
+ Immutable$2.serialize = serialize$4;
1565
1556
 
1566
1557
  const test$2 = val =>
1567
1558
  val &&
@@ -1569,7 +1560,7 @@ const test$2 = val =>
1569
1560
 
1570
1561
  Immutable$2.test = test$2;
1571
1562
  const plugin$2 = {
1572
- serialize: serialize$3,
1563
+ serialize: serialize$4,
1573
1564
  test: test$2
1574
1565
  };
1575
1566
  var _default$3 = plugin$2;
@@ -1952,7 +1943,7 @@ const getPropKeys$1 = element => {
1952
1943
  .sort();
1953
1944
  };
1954
1945
 
1955
- const serialize$2 = (element, config, indentation, depth, refs, printer) =>
1946
+ const serialize$3 = (element, config, indentation, depth, refs, printer) =>
1956
1947
  ++depth > config.maxDepth
1957
1948
  ? (0, _markup$1.printElementAsLeaf)(getType(element), config)
1958
1949
  : (0, _markup$1.printElement)(
@@ -1978,13 +1969,13 @@ const serialize$2 = (element, config, indentation, depth, refs, printer) =>
1978
1969
  indentation
1979
1970
  );
1980
1971
 
1981
- ReactElement$2.serialize = serialize$2;
1972
+ ReactElement$2.serialize = serialize$3;
1982
1973
 
1983
1974
  const test$1 = val => val != null && ReactIs.isElement(val);
1984
1975
 
1985
1976
  ReactElement$2.test = test$1;
1986
1977
  const plugin$1 = {
1987
- serialize: serialize$2,
1978
+ serialize: serialize$3,
1988
1979
  test: test$1
1989
1980
  };
1990
1981
  var _default$2 = plugin$1;
@@ -2028,7 +2019,7 @@ const getPropKeys = object => {
2028
2019
  : [];
2029
2020
  };
2030
2021
 
2031
- const serialize$1 = (object, config, indentation, depth, refs, printer) =>
2022
+ const serialize$2 = (object, config, indentation, depth, refs, printer) =>
2032
2023
  ++depth > config.maxDepth
2033
2024
  ? (0, _markup.printElementAsLeaf)(object.type, config)
2034
2025
  : (0, _markup.printElement)(
@@ -2058,13 +2049,13 @@ const serialize$1 = (object, config, indentation, depth, refs, printer) =>
2058
2049
  indentation
2059
2050
  );
2060
2051
 
2061
- ReactTestComponent$2.serialize = serialize$1;
2052
+ ReactTestComponent$2.serialize = serialize$2;
2062
2053
 
2063
2054
  const test = val => val && val.$$typeof === testSymbol;
2064
2055
 
2065
2056
  ReactTestComponent$2.test = test;
2066
2057
  const plugin = {
2067
- serialize: serialize$1,
2058
+ serialize: serialize$2,
2068
2059
  test
2069
2060
  };
2070
2061
  var _default$1 = plugin;
@@ -2730,7 +2721,7 @@ ${string}
2730
2721
  const removeExtraLineBreaks = (string) => string.length > 2 && string.startsWith("\n") && string.endsWith("\n") ? string.slice(1, -1) : string;
2731
2722
  const escapeRegex = true;
2732
2723
  const printFunctionName = false;
2733
- function serialize(val, indent = 2, formatOverrides = {}) {
2724
+ function serialize$1(val, indent = 2, formatOverrides = {}) {
2734
2725
  return normalizeNewlines(format_1(val, __spreadValues$1({
2735
2726
  escapeRegex,
2736
2727
  indent,
@@ -2844,7 +2835,7 @@ class SnapshotState {
2844
2835
  key = testNameToKey(testName, count);
2845
2836
  if (!(isInline && this._snapshotData[key] !== void 0))
2846
2837
  this._uncheckedKeys.delete(key);
2847
- const receivedSerialized = addExtraLineBreaks(serialize(received, void 0, this._snapshotFormat));
2838
+ const receivedSerialized = addExtraLineBreaks(serialize$1(received, void 0, this._snapshotFormat));
2848
2839
  const expected = isInline ? inlineSnapshot : this._snapshotData[key];
2849
2840
  const pass = (expected == null ? void 0 : expected.trim()) === (receivedSerialized == null ? void 0 : receivedSerialized.trim());
2850
2841
  const hasSnapshot = expected !== void 0;
@@ -3508,31 +3499,22 @@ function JestChaiExpect() {
3508
3499
  utils.expectTypes(this, ["number"]);
3509
3500
  return this.closeTo(number, numDigits);
3510
3501
  });
3511
- function isSpy(putativeSpy) {
3512
- return typeof putativeSpy === "function" && typeof putativeSpy.getCall === "function" && typeof putativeSpy.calledWithExactly === "function";
3513
- }
3514
- function isCall(putativeCall) {
3515
- return putativeCall && isSpy(putativeCall.proxy);
3516
- }
3517
- const assertIsMock = (assertion) => {
3518
- if (!isSpy(assertion._obj) && !isCall(assertion._obj))
3519
- throw new TypeError(`${utils.inspect(assertion._obj)} is not a spy or a call to a spy!`);
3502
+ const getSpy = (assertion) => {
3503
+ return assertion._obj;
3520
3504
  };
3521
3505
  def(["toHaveBeenCalledTimes", "toBeCalledTimes"], function(number) {
3522
- assertIsMock(this);
3523
- return this.callCount(number);
3506
+ return this.assert(getSpy(this).callCount === number, "expected spy to be called #{exp} times", "expected spy to not be called #{exp} times", number);
3524
3507
  });
3525
3508
  def("toHaveBeenCalledOnce", function() {
3526
- assertIsMock(this);
3527
- return this.callCount(1);
3509
+ return this.assert(getSpy(this).callCount === 1, "expected spy to be called once", "expected spy to not be called once", 1);
3528
3510
  });
3529
3511
  def(["toHaveBeenCalled", "toBeCalled"], function() {
3530
- assertIsMock(this);
3531
- return this.called;
3512
+ return this.assert(getSpy(this).called, "expected spy to be called at least once", "expected spy to not be called at all", true);
3532
3513
  });
3533
3514
  def(["toHaveBeenCalledWith", "toBeCalledWith"], function(...args) {
3534
- assertIsMock(this);
3535
- return this.calledWith(...args);
3515
+ const spy = getSpy(this);
3516
+ const pass = spy.calls.some((callArg) => equals(callArg, args));
3517
+ return this.assert(pass, "expected spy to be called with arguments: #{exp}", "expected spy to not be called with arguments: #{exp}", args);
3536
3518
  });
3537
3519
  const ordinalOf = (i) => {
3538
3520
  const j = i % 10;
@@ -3546,16 +3528,14 @@ function JestChaiExpect() {
3546
3528
  return `${i}th`;
3547
3529
  };
3548
3530
  def(["toHaveBeenNthCalledWith", "nthCalledWith"], function(times, ...args) {
3549
- assertIsMock(this);
3550
- const spy = utils.flag(this, "object");
3551
- const nthCall = spy.getCall(times - 1);
3552
- this.assert(nthCall.calledWith(...args), `expected ${ordinalOf(times)} spy call to have been called with #{exp}`, `expected ${ordinalOf(times)} spy call not to have been called with #{exp}`, args, nthCall.args);
3531
+ const spy = getSpy(this);
3532
+ const nthCall = spy.calls[times - 1];
3533
+ this.assert(equals(nthCall, args), `expected ${ordinalOf(times)} spy call to have been called with #{exp}`, `expected ${ordinalOf(times)} spy call to not have been called with #{exp}`, args, nthCall);
3553
3534
  });
3554
3535
  def(["toHaveBeenLastCalledWith", "lastCalledWith"], function(...args) {
3555
- assertIsMock(this);
3556
- const spy = utils.flag(this, "object");
3557
- const lastCall = spy.getCall(spy.returnValues.length - 1);
3558
- this.assert(lastCall.calledWith(...args), "expected last spy call to have been called with #{exp}", "expected last spy call not to have been called with #{exp}", args, lastCall.args);
3536
+ const spy = getSpy(this);
3537
+ const lastCall = spy.calls.at(-1);
3538
+ this.assert(equals(lastCall, args), "expected last spy call to have been called with #{exp}", "expected last spy call to not have been called with #{exp}", args, lastCall);
3559
3539
  });
3560
3540
  def(["toThrow", "toThrowError"], function(expected) {
3561
3541
  const negate = utils.flag(this, "negate");
@@ -3565,37 +3545,35 @@ function JestChaiExpect() {
3565
3545
  this.to.throw(expected);
3566
3546
  });
3567
3547
  def(["toHaveReturned", "toReturn"], function() {
3568
- assertIsMock(this);
3569
- const spy = utils.flag(this, "object");
3570
- const calledAndNotThrew = spy.called && !spy.alwaysThrew();
3571
- this.assert(calledAndNotThrew, "expected spy to be successfully called at least once", "expected spy not to be successfully called", calledAndNotThrew, !calledAndNotThrew);
3548
+ const spy = getSpy(this);
3549
+ const calledAndNotThrew = spy.called && !spy.results.some(([type]) => type === "error");
3550
+ this.assert(calledAndNotThrew, "expected spy to be successfully called at least once", "expected spy to not be successfully called", calledAndNotThrew, !calledAndNotThrew);
3572
3551
  });
3573
3552
  def(["toHaveReturnedTimes", "toReturnTimes"], function(times) {
3574
- assertIsMock(this);
3575
- const spy = utils.flag(this, "object");
3576
- const successfullReturns = spy.getCalls().reduce((success, call) => call.threw() ? success : ++success, 0);
3577
- this.assert(successfullReturns === times, `expected spy to be successfully called ${times} times`, `expected spy not to be successfully called ${times} times`, `expected number of returns: ${times}`, `recieved number of returns: ${successfullReturns}`);
3553
+ const spy = getSpy(this);
3554
+ const successfullReturns = spy.results.reduce((success, [type]) => type === "error" ? success : ++success, 0);
3555
+ this.assert(successfullReturns === times, `expected spy to be successfully called ${times} times`, `expected spy to not be successfully called ${times} times`, `expected number of returns: ${times}`, `recieved number of returns: ${successfullReturns}`);
3578
3556
  });
3579
3557
  def(["toHaveReturnedWith", "toReturnWith"], function(value) {
3580
- assertIsMock(this);
3581
- return this.returned(value);
3558
+ const spy = getSpy(this);
3559
+ const pass = spy.results.some(([type, result]) => type === "ok" && equals(value, result));
3560
+ this.assert(pass, "expected spy to be successfully called with #{exp}", "expected spy to not be successfully called with #{exp}", value);
3582
3561
  });
3583
3562
  def(["toHaveLastReturnedWith", "lastReturnedWith"], function(value) {
3584
- assertIsMock(this);
3585
- const spy = utils.flag(this, "object");
3586
- const lastReturn = spy.lastCall.returned(value);
3587
- this.assert(lastReturn, "expected last spy call to return #{exp}", "expected last spy call not to return #{exp}", value, spy.lastCall.returnValue);
3563
+ const spy = getSpy(this);
3564
+ const lastResult = spy.returns.at(-1);
3565
+ const pass = equals(lastResult, value);
3566
+ this.assert(pass, "expected last spy call to return #{exp}", "expected last spy call to not return #{exp}", value, lastResult);
3588
3567
  });
3589
3568
  def(["toHaveNthReturnedWith", "nthReturnedWith"], function(nthCall, value) {
3590
- assertIsMock(this);
3591
- const spy = utils.flag(this, "object");
3569
+ const spy = getSpy(this);
3592
3570
  const isNot = utils.flag(this, "negate");
3593
- const call = spy.getCall(nthCall - 1);
3571
+ const [callType, callResult] = spy.results[nthCall - 1];
3594
3572
  const ordinalCall = `${ordinalOf(nthCall)} call`;
3595
- if (!isNot && call.threw())
3573
+ if (!isNot && callType === "error")
3596
3574
  chai.assert.fail(`expected ${ordinalCall} to return #{exp}, but instead it threw an error`);
3597
- const nthCallReturn = call.returned(value);
3598
- this.assert(nthCallReturn, `expected ${ordinalCall} spy call to return #{exp}`, `expected ${ordinalCall} spy call not to return #{exp}`, value, call.returnValue);
3575
+ const nthCallReturn = equals(callResult, value);
3576
+ this.assert(nthCallReturn, `expected ${ordinalCall} spy call to return #{exp}`, `expected ${ordinalCall} spy call to not return #{exp}`, value, callResult);
3599
3577
  });
3600
3578
  };
3601
3579
  }
@@ -3604,7 +3582,6 @@ let installed = false;
3604
3582
  async function setupChai() {
3605
3583
  if (installed)
3606
3584
  return;
3607
- chai.use(SinonChai);
3608
3585
  chai.use(JestExtend());
3609
3586
  chai.use(JestChaiExpect());
3610
3587
  chai.use(Subset);
@@ -3620,7 +3597,7 @@ async function setupGlobalEnv(config) {
3620
3597
  setupConsoleLogSpy();
3621
3598
  await setupChai();
3622
3599
  if (config.global)
3623
- (await import('./global-38c2f902.js')).registerApiGlobally();
3600
+ (await import('./global-b8e9d6fe.js')).registerApiGlobally();
3624
3601
  }
3625
3602
  function setupConsoleLogSpy() {
3626
3603
  const stdout = new Writable({
@@ -3669,6 +3646,23 @@ async function runSetupFiles(config) {
3669
3646
  }));
3670
3647
  }
3671
3648
 
3649
+ function serialize(err) {
3650
+ if (typeof err !== "object")
3651
+ return err;
3652
+ Object.keys(err).forEach((key) => {
3653
+ const val = err[key];
3654
+ if (typeof val === "function")
3655
+ err[key] = `Function<${val.name}>`;
3656
+ if (typeof val !== "object")
3657
+ return;
3658
+ if ("then" in val)
3659
+ err[key] = "Promise";
3660
+ if (typeof Element !== "undefined" && val instanceof Element)
3661
+ err[key] = val.tagName;
3662
+ serialize(err[key]);
3663
+ });
3664
+ return err;
3665
+ }
3672
3666
  function processError(err) {
3673
3667
  if (!err)
3674
3668
  return err;
@@ -3676,7 +3670,7 @@ function processError(err) {
3676
3670
  err.stackStr = String(err.stack);
3677
3671
  if (err.name)
3678
3672
  err.nameStr = String(err.name);
3679
- return err;
3673
+ return serialize(err);
3680
3674
  }
3681
3675
 
3682
3676
  async function collectTests(paths, config) {
@@ -3696,9 +3690,12 @@ async function collectTests(paths, config) {
3696
3690
  try {
3697
3691
  await runSetupFiles(config);
3698
3692
  await import(filepath);
3699
- for (const c of [defaultSuite, ...context.tasks]) {
3693
+ const defaultTasks = await defaultSuite.collect(file);
3694
+ for (const c of [...defaultTasks.tasks, ...context.tasks]) {
3700
3695
  if (c.type === "test") {
3701
3696
  file.tasks.push(c);
3697
+ } else if (c.type === "suite") {
3698
+ file.tasks.push(c);
3702
3699
  } else {
3703
3700
  const suite = await c.collect(file);
3704
3701
  if (suite.name || suite.tasks.length)
@@ -1303,7 +1303,7 @@ async function printStack(ctx, stack, highlight, onStack) {
1303
1303
  const color = frame === highlight ? c.yellow : c.gray;
1304
1304
  const path = relative(ctx.config.root, frame.file);
1305
1305
  ctx.console.log(color(` ${c.dim(F_POINTER)} ${[frame.method, c.dim(`${path}:${pos.line}:${pos.column}`)].filter(Boolean).join(" ")}`));
1306
- onStack == null ? void 0 : onStack(frame, pos);
1306
+ await (onStack == null ? void 0 : onStack(frame, pos));
1307
1307
  if (frame.file in ctx.state.filesMap)
1308
1308
  break;
1309
1309
  }
@@ -1,11 +1,11 @@
1
- import { g as globalApis } from './constants-2435fa16.js';
2
- import { i as index } from './index-6feda5ef.js';
1
+ import { g as globalApis } from './constants-1268ea5c.js';
2
+ import { i as index } from './index-16a06164.js';
3
3
  import 'path';
4
4
  import 'url';
5
5
  import './suite-95be5909.js';
6
6
  import './index-9e71c815.js';
7
7
  import 'chai';
8
- import 'sinon';
8
+ import 'tinyspy';
9
9
 
10
10
  function registerApiGlobally() {
11
11
  globalApis.forEach((api) => {
@@ -1,14 +1,16 @@
1
1
  import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it } from './suite-95be5909.js';
2
2
  import chai, { assert, should, expect } from 'chai';
3
- import sinon from 'sinon';
3
+ import { spyOn, spy } from 'tinyspy';
4
4
 
5
5
  const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
6
6
  const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
7
7
  const beforeEach = (fn, timeout) => getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
8
8
  const afterEach = (fn, timeout) => getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
9
9
 
10
- const { mock, spy, stub } = sinon;
11
- sinon.fn = sinon.spy;
10
+ const vitest = {
11
+ spyOn,
12
+ fn: spy
13
+ };
12
14
 
13
15
  var index = /*#__PURE__*/Object.freeze({
14
16
  __proto__: null,
@@ -24,10 +26,9 @@ var index = /*#__PURE__*/Object.freeze({
24
26
  should: should,
25
27
  expect: expect,
26
28
  chai: chai,
27
- sinon: sinon,
28
- mock: mock,
29
29
  spy: spy,
30
- stub: stub
30
+ spyOn: spyOn,
31
+ vitest: vitest
31
32
  });
32
33
 
33
- export { afterAll as a, beforeAll as b, beforeEach as c, afterEach as d, stub as e, index as i, mock as m, spy as s };
34
+ export { afterAll as a, beforeAll as b, beforeEach as c, afterEach as d, index as i, vitest as v };
package/dist/index.d.ts CHANGED
@@ -3,8 +3,8 @@ import { TransformResult, ViteDevServer } from 'vite';
3
3
  import { OptionsReceived } from 'pretty-format';
4
4
  import { MessagePort } from 'worker_threads';
5
5
  export { assert, default as chai, expect, should } from 'chai';
6
- import sinon from 'sinon';
7
- export { default as sinon } from 'sinon';
6
+ import { spyOn, spy } from 'tinyspy';
7
+ export { spy, spyOn } from 'tinyspy';
8
8
 
9
9
  declare const EXPECTED_COLOR: Formatter;
10
10
  declare const RECEIVED_COLOR: Formatter;
@@ -148,7 +148,7 @@ interface VitestContext {
148
148
  server: ViteDevServer;
149
149
  state: StateManager;
150
150
  snapshot: SnapshotManager;
151
- reporter: Reporter;
151
+ reporters: Reporter[];
152
152
  console: Console;
153
153
  }
154
154
  interface UserConsoleLog {
@@ -300,12 +300,12 @@ interface UserOptions {
300
300
  *
301
301
  * @default ['**\/*.test.ts']
302
302
  */
303
- includes?: string[];
303
+ include?: string[];
304
304
  /**
305
305
  * Exclude globs for test files
306
306
  * @default ['**\/node_modules\/**']
307
307
  */
308
- excludes?: string[];
308
+ exclude?: string[];
309
309
  /**
310
310
  * Handling for dependencies inlining or externalizing
311
311
  */
@@ -313,7 +313,7 @@ interface UserOptions {
313
313
  /**
314
314
  * Externalize means that Vite will bypass the package to native Node.
315
315
  *
316
- * Externaled dependencies will not be applied Vite's transformers and resolvers.
316
+ * Externalized dependencies will not be applied Vite's transformers and resolvers.
317
317
  * And does not support HMR on reload.
318
318
  *
319
319
  * Typically, packages under `node_modules` are externalized.
@@ -359,7 +359,7 @@ interface UserOptions {
359
359
  /**
360
360
  * Custom reporter for output
361
361
  */
362
- reporter?: Reporter;
362
+ reporters?: Reporter | Reporter[];
363
363
  /**
364
364
  * Enable multi-threading
365
365
  *
@@ -408,7 +408,7 @@ interface UserOptions {
408
408
  /**
409
409
  * Listen to port and serve API
410
410
  *
411
- * When set to try, the default port is 55555
411
+ * When set to true, the default port is 55555
412
412
  *
413
413
  * @default false
414
414
  */
@@ -448,6 +448,7 @@ interface WorkerContext {
448
448
  interface RpcMap {
449
449
  fetch: [[id: string], TransformResult | null | undefined];
450
450
  log: [[UserConsoleLog], void];
451
+ processExit: [[code?: number], void];
451
452
  onCollected: [[files: File[]], void];
452
453
  onFinished: [[], void];
453
454
  onTaskUpdate: [[pack: TaskResultPack], void];
@@ -566,9 +567,10 @@ declare const afterAll: (fn: SuiteHooks['afterAll'][0], timeout?: number | undef
566
567
  declare const beforeEach: (fn: SuiteHooks['beforeEach'][0], timeout?: number | undefined) => void;
567
568
  declare const afterEach: (fn: SuiteHooks['afterEach'][0], timeout?: number | undefined) => void;
568
569
 
569
- declare const mock: sinon.SinonMockStatic;
570
- declare const spy: sinon.SinonSpyStatic;
571
- declare const stub: sinon.SinonStubStatic;
570
+ declare const vitest: {
571
+ spyOn: typeof spyOn;
572
+ fn: typeof spy;
573
+ };
572
574
 
573
575
  declare module 'vite' {
574
576
  interface UserConfig {
@@ -635,4 +637,4 @@ declare global {
635
637
  }
636
638
  }
637
639
 
638
- export { Arrayable, Awaitable, CliOptions, ComputeMode, Environment, EnvironmentReturn, File, HookListener, ModuleCache, Nullable, Reporter, ResolvedConfig, RpcCall, RpcMap, RpcPayload, RpcSend, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConsoleLog, UserOptions, VitestContext, WorkerContext, afterAll, afterEach, beforeAll, beforeEach, describe, it, mock, spy, stub, suite, test };
640
+ export { Arrayable, Awaitable, CliOptions, ComputeMode, Environment, EnvironmentReturn, File, HookListener, ModuleCache, Nullable, Reporter, ResolvedConfig, RpcCall, RpcMap, RpcPayload, RpcSend, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, Suite, SuiteCollector, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestCollector, TestFactory, TestFunction, UncheckedSnapshot, UserConsoleLog, UserOptions, VitestContext, WorkerContext, afterAll, afterEach, beforeAll, beforeEach, describe, it, suite, test, vitest };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { d as describe, i as it, s as suite, t as test } from './suite-95be5909.js';
2
- export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, m as mock, s as spy, e as stub } from './index-6feda5ef.js';
2
+ export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, v as vitest } from './index-16a06164.js';
3
3
  export { assert, default as chai, expect, should } from 'chai';
4
- export { default as sinon } from 'sinon';
4
+ export { spy, spyOn } from 'tinyspy';
5
5
  import './index-9e71c815.js';
@@ -1,5 +1,5 @@
1
1
  import { stringify } from 'flatted';
2
- import { A as API_PATH } from './constants-2435fa16.js';
2
+ import { A as API_PATH } from './constants-1268ea5c.js';
3
3
  import 'path';
4
4
  import 'url';
5
5
 
@@ -0,0 +1,10 @@
1
+ const rpc = async (method, ...args) => {
2
+ var _a;
3
+ return (_a = process.__vitest_worker__) == null ? void 0 : _a.rpc(method, ...args);
4
+ };
5
+ const send = async (method, ...args) => {
6
+ var _a;
7
+ return (_a = process.__vitest_worker__) == null ? void 0 : _a.send(method, ...args);
8
+ };
9
+
10
+ export { rpc as r, send as s };
package/dist/worker.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { resolve, dirname } from 'path';
2
2
  import { n as nanoid } from './index-9e71c815.js';
3
- import { e as distDir } from './constants-2435fa16.js';
3
+ import { e as distDir } from './constants-1268ea5c.js';
4
4
  import { builtinModules, createRequire } from 'module';
5
5
  import { pathToFileURL, fileURLToPath } from 'url';
6
6
  import vm from 'vm';
7
7
  import { s as slash } from './utils-9dcc4050.js';
8
+ import { s as send } from './rpc-7de86f29.js';
8
9
 
9
10
  const defaultInline = [
10
11
  "vitest/dist",
@@ -208,6 +209,14 @@ const moduleCache = new Map();
208
209
  async function init(ctx) {
209
210
  if (_run)
210
211
  return _run;
212
+ const processExit = process.exit;
213
+ process.on("beforeExit", (code) => {
214
+ send("processExit", code);
215
+ });
216
+ process.exit = (code = process.exitCode || 0) => {
217
+ send("processExit", code);
218
+ return processExit(code);
219
+ };
211
220
  const { config } = ctx;
212
221
  _run = (await executeInViteNode({
213
222
  root: config.root,
package/global.d.ts CHANGED
@@ -5,10 +5,9 @@ declare global {
5
5
  const it: typeof import('vitest')['it']
6
6
  const expect: typeof import('vitest')['expect']
7
7
  const assert: typeof import('vitest')['assert']
8
- const sinon: typeof import('vitest')['sinon']
9
8
  const spy: typeof import('vitest')['spy']
10
- const mock: typeof import('vitest')['mock']
11
- const stub: typeof import('vitest')['stub']
9
+ const spyOn: typeof import('vitest')['spyOn']
10
+ const vitest: typeof import('vitest')['vitest']
12
11
  const beforeAll: typeof import('vitest')['beforeAll']
13
12
  const afterAll: typeof import('vitest')['afterAll']
14
13
  const beforeEach: typeof import('vitest')['beforeEach']