vitest 2.1.3 → 2.1.4

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 (74) hide show
  1. package/LICENSE.md +1 -209
  2. package/dist/browser.d.ts +21 -21
  3. package/dist/browser.js +7 -7
  4. package/dist/chunks/{RandomSequencer.Bh5-tlNJ.js → RandomSequencer.CMRlh2v4.js} +143 -142
  5. package/dist/chunks/{base.BO5Jx7vw.js → base.C3xNdjV6.js} +3 -3
  6. package/dist/chunks/{benchmark.C8CRJYG4.js → benchmark.Cdu9hjj4.js} +2 -2
  7. package/dist/chunks/{benchmark.JVlTzojj.d.ts → benchmark.geERunq4.d.ts} +1 -1
  8. package/dist/chunks/{cac.BSMVokHR.js → cac.DrfPaMvZ.js} +11 -10
  9. package/dist/chunks/{cli-api.btGgw3PC.js → cli-api.CKrRYkw8.js} +732 -577
  10. package/dist/chunks/{console.CfT1Wjed.js → console.BYGVloWk.js} +2 -6
  11. package/dist/chunks/{coverage.zlNdAMHK.js → coverage.BoMDb1ip.js} +1 -1
  12. package/dist/chunks/{creator.CBPphXqR.js → creator.IIqd8RWT.js} +8 -8
  13. package/dist/chunks/{execute._eQQfgI8.js → execute.2pr0rHgK.js} +8 -6
  14. package/dist/chunks/{globals.Bdzt04Qm.js → globals.Bp645TTJ.js} +8 -13
  15. package/dist/chunks/{index.BpSiYbpB.js → index.68735LiX.js} +28 -5
  16. package/dist/chunks/{index.X0nbfr6-.js → index.BJDntFik.js} +7 -7
  17. package/dist/chunks/{index.Dz2opmmU.js → index.Bn81VaWg.js} +3808 -3787
  18. package/dist/chunks/{index.CPD77dLA.js → index.CqYx2Nsr.js} +7 -7
  19. package/dist/chunks/{index.4GFF2h22.js → index.D3d79vc8.js} +6 -6
  20. package/dist/chunks/index.Dqe5k2Rk.js +54 -0
  21. package/dist/chunks/{node.Bx4JZjMG.js → node.AKq966Jp.js} +1 -5
  22. package/dist/chunks/{reporters.C4ZHgdxQ.d.ts → reporters.anwo7Y6a.d.ts} +1328 -1313
  23. package/dist/chunks/{resolveConfig.Dha6ilPI.js → resolveConfig.DPmbhVlP.js} +3193 -3175
  24. package/dist/chunks/{rpc.B7Mfb-Yf.js → rpc.C3q9uwRX.js} +2 -2
  25. package/dist/chunks/{run-once.Sxe67Wng.js → run-once.2ogXb3JV.js} +1 -1
  26. package/dist/chunks/{runBaseTests.Cx4wXyTR.js → runBaseTests.Dm-659zB.js} +21 -25
  27. package/dist/chunks/{setup-common.BKyF15v_.js → setup-common.DDmVKp6O.js} +3 -3
  28. package/dist/chunks/{suite.BMWOKiTe.d.ts → suite.B2jumIFP.d.ts} +2 -2
  29. package/dist/chunks/{utils.CY6Spixo.js → utils.BB4zjzR8.js} +2 -2
  30. package/dist/chunks/utils.C8RiOc4B.js +77 -0
  31. package/dist/chunks/{vi.BskyZC5g.js → vi.JMQoNY_Z.js} +94 -141
  32. package/dist/chunks/{vite.YH7MrecS.d.ts → vite.BdBj-UWY.d.ts} +1 -1
  33. package/dist/chunks/{vm.DB_hLchi.js → vm.jpyrB0xy.js} +5 -8
  34. package/dist/chunks/{worker.B6RjTtbk.d.ts → worker.BAlI9hII.d.ts} +12 -3
  35. package/dist/chunks/{worker.CcJLfX8w.d.ts → worker.DHnGaO2M.d.ts} +1 -1
  36. package/dist/cli.js +3 -4
  37. package/dist/config.cjs +4 -4
  38. package/dist/config.d.ts +10 -10
  39. package/dist/config.js +4 -4
  40. package/dist/coverage.d.ts +9 -9
  41. package/dist/coverage.js +8 -11
  42. package/dist/environments.d.ts +2 -2
  43. package/dist/environments.js +1 -1
  44. package/dist/execute.d.ts +53 -53
  45. package/dist/execute.js +7 -6
  46. package/dist/index.d.ts +75 -1099
  47. package/dist/index.js +7 -18
  48. package/dist/node.d.ts +43 -41
  49. package/dist/node.js +22 -28
  50. package/dist/path.js +1 -1
  51. package/dist/reporters.d.ts +10 -10
  52. package/dist/reporters.js +12 -18
  53. package/dist/runners.d.ts +12 -19
  54. package/dist/runners.js +142 -148
  55. package/dist/snapshot.js +2 -6
  56. package/dist/suite.d.ts +2 -2
  57. package/dist/suite.js +2 -6
  58. package/dist/worker.js +5 -6
  59. package/dist/workers/forks.js +9 -8
  60. package/dist/workers/runVmTests.js +16 -20
  61. package/dist/workers/threads.js +9 -8
  62. package/dist/workers/vmForks.js +9 -12
  63. package/dist/workers/vmThreads.js +9 -12
  64. package/dist/workers.d.ts +13 -13
  65. package/dist/workers.js +14 -18
  66. package/package.json +26 -26
  67. package/dist/chunks/base.DwXGwWst.js +0 -89
  68. package/dist/chunks/env.CmHVDJnw.js +0 -7
  69. package/dist/chunks/index.-d_XpZEA.js +0 -140
  70. package/dist/chunks/index.CxRxs566.js +0 -23
  71. package/dist/chunks/tasks.BZnCS9aT.js +0 -18
  72. package/dist/chunks/utils.Ck2hJTRs.js +0 -23
  73. package/dist/chunks/{environment.CzISCQ7o.d.ts → environment.LoooBwUu.d.ts} +24 -24
  74. package/dist/chunks/{index.lVXYBqEP.js → index.BMoXz_-n.js} +186 -186
@@ -1,6 +1,6 @@
1
1
  import { getSafeTimers } from '@vitest/utils';
2
- import { c as createBirpc } from './index.BpSiYbpB.js';
3
- import { g as getWorkerState } from './utils.Ck2hJTRs.js';
2
+ import { c as createBirpc } from './index.68735LiX.js';
3
+ import { g as getWorkerState } from './utils.C8RiOc4B.js';
4
4
 
5
5
  const { get } = Reflect;
6
6
  function withSafeTimers(fn) {
@@ -1,4 +1,4 @@
1
- import { g as getWorkerState } from './utils.Ck2hJTRs.js';
1
+ import { g as getWorkerState } from './utils.C8RiOc4B.js';
2
2
 
3
3
  const filesCount = /* @__PURE__ */ new Map();
4
4
  const cache = /* @__PURE__ */ new Map();
@@ -1,39 +1,35 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { startTests, collectTests } from '@vitest/runner';
3
- import 'pathe';
4
- import '@vitest/runner/utils';
5
- import { getSafeTimers } from '@vitest/utils';
6
- import { g as getWorkerState } from './utils.Ck2hJTRs.js';
7
- import './env.CmHVDJnw.js';
8
- import { a as globalExpect, r as resetModules, v as vi } from './vi.BskyZC5g.js';
9
- import { a as startCoverageInsideWorker, s as stopCoverageInsideWorker } from './coverage.zlNdAMHK.js';
10
- import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.4GFF2h22.js';
3
+ import { a as resolveSnapshotEnvironment, s as setupChaiConfig, r as resolveTestRunner } from './index.D3d79vc8.js';
4
+ import { s as startCoverageInsideWorker, a as stopCoverageInsideWorker } from './coverage.BoMDb1ip.js';
5
+ import { a as globalExpect, v as vi } from './vi.JMQoNY_Z.js';
6
+ import { c as closeInspector } from './inspector.70d6emsh.js';
11
7
  import { createRequire } from 'node:module';
12
- import util from 'node:util';
13
8
  import timers from 'node:timers';
14
- import { installSourcemapsSupport } from 'vite-node/source-map';
9
+ import util from 'node:util';
10
+ import { getSafeTimers } from '@vitest/utils';
15
11
  import { KNOWN_ASSET_TYPES } from 'vite-node/constants';
16
- import { V as VitestIndex } from './index.-d_XpZEA.js';
17
- import { s as setupCommonEnv } from './setup-common.BKyF15v_.js';
18
- import { c as closeInspector } from './inspector.70d6emsh.js';
19
- import 'std-env';
12
+ import { installSourcemapsSupport } from 'vite-node/source-map';
13
+ import { V as VitestIndex } from './index.Dqe5k2Rk.js';
14
+ import { s as setupCommonEnv } from './setup-common.DDmVKp6O.js';
15
+ import { g as getWorkerState, r as resetModules } from './utils.C8RiOc4B.js';
20
16
  import 'chai';
21
- import './_commonjsHelpers.BFTU3MAI.js';
17
+ import 'node:path';
18
+ import '../path.js';
19
+ import 'node:url';
20
+ import './rpc.C3q9uwRX.js';
21
+ import './index.68735LiX.js';
22
22
  import '@vitest/expect';
23
+ import '@vitest/runner/utils';
24
+ import './_commonjsHelpers.BFTU3MAI.js';
23
25
  import '@vitest/snapshot';
24
26
  import '@vitest/utils/error';
25
- import './tasks.BZnCS9aT.js';
26
27
  import '@vitest/utils/source-map';
27
- import './base.DwXGwWst.js';
28
28
  import './date.W2xKR2qe.js';
29
29
  import '@vitest/spy';
30
- import '../path.js';
31
- import 'node:url';
32
- import './rpc.B7Mfb-Yf.js';
33
- import './index.BpSiYbpB.js';
34
- import './benchmark.C8CRJYG4.js';
35
- import './index.CxRxs566.js';
36
- import './run-once.Sxe67Wng.js';
30
+ import './run-once.2ogXb3JV.js';
31
+ import './benchmark.Cdu9hjj4.js';
32
+ import 'expect-type';
37
33
 
38
34
  let globalSetup = false;
39
35
  async function setupGlobalEnv(config, { environment }, executor) {
@@ -81,7 +77,7 @@ function resolveAsset(mod, url) {
81
77
  mod.exports = url;
82
78
  }
83
79
  async function setupConsoleLogSpy() {
84
- const { createCustomConsole } = await import('./console.CfT1Wjed.js');
80
+ const { createCustomConsole } = await import('./console.BYGVloWk.js');
85
81
  globalThis.console = createCustomConsole();
86
82
  }
87
83
  async function withEnv({ environment }, options, fn) {
@@ -1,6 +1,6 @@
1
- import { setSafeTimers } from '@vitest/utils';
2
1
  import { addSerializer } from '@vitest/snapshot';
3
- import { r as resetRunOnceCounter } from './run-once.Sxe67Wng.js';
2
+ import { setSafeTimers } from '@vitest/utils';
3
+ import { r as resetRunOnceCounter } from './run-once.2ogXb3JV.js';
4
4
 
5
5
  let globalSetup = false;
6
6
  async function setupCommonEnv(config) {
@@ -13,7 +13,7 @@ async function setupCommonEnv(config) {
13
13
  globalSetup = true;
14
14
  setSafeTimers();
15
15
  if (config.globals) {
16
- (await import('./globals.Bdzt04Qm.js')).registerApiGlobally();
16
+ (await import('./globals.Bp645TTJ.js')).registerApiGlobally();
17
17
  }
18
18
  }
19
19
  function setupDefines(defines) {
@@ -1,7 +1,7 @@
1
1
  import { Custom } from '@vitest/runner';
2
- import '@vitest/runner/utils';
3
- import { b as BenchFunction, c as BenchmarkAPI } from './benchmark.JVlTzojj.js';
2
+ import { a as BenchFunction, c as BenchmarkAPI } from './benchmark.geERunq4.js';
4
3
  import { Options } from 'tinybench';
4
+ import '@vitest/runner/utils';
5
5
 
6
6
  declare function getBenchOptions(key: Custom): Options;
7
7
  declare function getBenchFn(key: Custom): BenchFunction;
@@ -1,7 +1,7 @@
1
1
  import { stripVTControlCharacters } from 'node:util';
2
+ import { slash } from '@vitest/utils';
2
3
  import { isAbsolute, relative, dirname, basename } from 'pathe';
3
4
  import c from 'tinyrainbow';
4
- import { a as slash } from './base.DwXGwWst.js';
5
5
 
6
6
  const F_RIGHT = "\u2192";
7
7
  const F_DOWN = "\u2193";
@@ -205,4 +205,4 @@ var utils = /*#__PURE__*/Object.freeze({
205
205
  testPass: testPass
206
206
  });
207
207
 
208
- export { F_RIGHT as F, F_POINTER as a, getStateString as b, formatTimeString as c, countTestErrors as d, divider as e, formatProjectName as f, getStateSymbol as g, getCols as h, getHookStateSymbol as i, renderSnapshotSummary as r, taskFail as t, utils as u };
208
+ export { F_POINTER as F, F_RIGHT as a, F_CHECK as b, getStateString as c, divider as d, formatTimeString as e, formatProjectName as f, getStateSymbol as g, countTestErrors as h, getCols as i, getHookStateSymbol as j, renderSnapshotSummary as r, taskFail as t, utils as u };
@@ -0,0 +1,77 @@
1
+ import { getSafeTimers } from '@vitest/utils';
2
+
3
+ const NAME_WORKER_STATE = "__vitest_worker__";
4
+ function getWorkerState() {
5
+ const workerState = globalThis[NAME_WORKER_STATE];
6
+ if (!workerState) {
7
+ const errorMsg = 'Vitest failed to access its internal state.\n\nOne of the following is possible:\n- "vitest" is imported directly without running "vitest" command\n- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n';
8
+ throw new Error(errorMsg);
9
+ }
10
+ return workerState;
11
+ }
12
+ function provideWorkerState(context, state) {
13
+ Object.defineProperty(context, NAME_WORKER_STATE, {
14
+ value: state,
15
+ configurable: true,
16
+ writable: true,
17
+ enumerable: false
18
+ });
19
+ return state;
20
+ }
21
+ function getCurrentEnvironment() {
22
+ const state = getWorkerState();
23
+ return state?.environment.name;
24
+ }
25
+ function isChildProcess() {
26
+ return typeof process !== "undefined" && !!process.send;
27
+ }
28
+ function setProcessTitle(title) {
29
+ try {
30
+ process.title = `node (${title})`;
31
+ } catch {
32
+ }
33
+ }
34
+ function resetModules(modules, resetMocks = false) {
35
+ const skipPaths = [
36
+ // Vitest
37
+ /\/vitest\/dist\//,
38
+ /\/vite-node\/dist\//,
39
+ // yarn's .store folder
40
+ /vitest-virtual-\w+\/dist/,
41
+ // cnpm
42
+ /@vitest\/dist/,
43
+ // don't clear mocks
44
+ ...!resetMocks ? [/^mock:/] : []
45
+ ];
46
+ modules.forEach((mod, path) => {
47
+ if (skipPaths.some((re) => re.test(path))) {
48
+ return;
49
+ }
50
+ modules.invalidateModule(mod);
51
+ });
52
+ }
53
+ function waitNextTick() {
54
+ const { setTimeout } = getSafeTimers();
55
+ return new Promise((resolve) => setTimeout(resolve, 0));
56
+ }
57
+ async function waitForImportsToResolve() {
58
+ await waitNextTick();
59
+ const state = getWorkerState();
60
+ const promises = [];
61
+ let resolvingCount = 0;
62
+ for (const mod of state.moduleCache.values()) {
63
+ if (mod.promise && !mod.evaluated) {
64
+ promises.push(mod.promise);
65
+ }
66
+ if (mod.resolving) {
67
+ resolvingCount++;
68
+ }
69
+ }
70
+ if (!promises.length && !resolvingCount) {
71
+ return;
72
+ }
73
+ await Promise.allSettled(promises);
74
+ await waitForImportsToResolve();
75
+ }
76
+
77
+ export { getCurrentEnvironment as a, getWorkerState as g, isChildProcess as i, provideWorkerState as p, resetModules as r, setProcessTitle as s, waitForImportsToResolve as w };
@@ -1,61 +1,106 @@
1
+ import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters } from '@vitest/expect';
2
+ import { getCurrentTest } from '@vitest/runner';
3
+ import { getNames, getTestName } from '@vitest/runner/utils';
1
4
  import * as chai$1 from 'chai';
5
+ import { g as getWorkerState, a as getCurrentEnvironment, i as isChildProcess, r as resetModules, w as waitForImportsToResolve } from './utils.C8RiOc4B.js';
6
+ import { getSafeTimers, assertTypes, createSimpleStackTrace } from '@vitest/utils';
2
7
  import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './_commonjsHelpers.BFTU3MAI.js';
3
- import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters } from '@vitest/expect';
4
8
  import { stripSnapshotIndentation, addSerializer, SnapshotClient } from '@vitest/snapshot';
5
- import { getNames } from '@vitest/runner/utils';
6
9
  import '@vitest/utils/error';
7
- import { getCurrentTest } from '@vitest/runner';
8
- import { g as getTestName } from './tasks.BZnCS9aT.js';
9
- import { g as getWorkerState, a as getCurrentEnvironment } from './utils.Ck2hJTRs.js';
10
- import { getSafeTimers, assertTypes, createSimpleStackTrace } from '@vitest/utils';
11
- import 'pathe';
12
- import './env.CmHVDJnw.js';
13
10
  import { parseSingleStack } from '@vitest/utils/source-map';
14
- import { i as isChildProcess } from './base.DwXGwWst.js';
15
11
  import { R as RealDate, r as resetDate, m as mockDate } from './date.W2xKR2qe.js';
16
12
  import { spyOn, fn, isMockFunction, mocks } from '@vitest/spy';
17
13
 
18
- function resetModules(modules, resetMocks = false) {
19
- const skipPaths = [
20
- // Vitest
21
- /\/vitest\/dist\//,
22
- /\/vite-node\/dist\//,
23
- // yarn's .store folder
24
- /vitest-virtual-\w+\/dist/,
25
- // cnpm
26
- /@vitest\/dist/,
27
- // don't clear mocks
28
- ...!resetMocks ? [/^mock:/] : []
29
- ];
30
- modules.forEach((mod, path) => {
31
- if (skipPaths.some((re) => re.test(path))) {
32
- return;
33
- }
34
- modules.invalidateModule(mod);
35
- });
36
- }
37
- function waitNextTick() {
38
- const { setTimeout } = getSafeTimers();
39
- return new Promise((resolve) => setTimeout(resolve, 0));
14
+ const unsupported = [
15
+ // .poll is meant to retry matchers until they succeed, and
16
+ // snapshots will always succeed as long as the poll method doesn't thow an error
17
+ // in this case using the `vi.waitFor` method is more appropriate
18
+ "matchSnapshot",
19
+ "toMatchSnapshot",
20
+ "toMatchInlineSnapshot",
21
+ "toThrowErrorMatchingSnapshot",
22
+ "toThrowErrorMatchingInlineSnapshot",
23
+ // toThrow will never succeed because we call the poll callback until it doesn't throw
24
+ "throws",
25
+ "Throw",
26
+ "throw",
27
+ "toThrow",
28
+ "toThrowError"
29
+ // these are not supported because you can call them without `.poll`,
30
+ // we throw an error inside the rejects/resolves methods to prevent this
31
+ // rejects,
32
+ // resolves
33
+ ];
34
+ function createExpectPoll(expect) {
35
+ return function poll(fn, options = {}) {
36
+ const state = getWorkerState();
37
+ const defaults = state.config.expect?.poll ?? {};
38
+ const {
39
+ interval = defaults.interval ?? 50,
40
+ timeout = defaults.timeout ?? 1e3,
41
+ message
42
+ } = options;
43
+ const assertion = expect(null, message).withContext({
44
+ poll: true
45
+ });
46
+ fn = fn.bind(assertion);
47
+ const proxy = new Proxy(assertion, {
48
+ get(target, key, receiver) {
49
+ const assertionFunction = Reflect.get(target, key, receiver);
50
+ if (typeof assertionFunction !== "function") {
51
+ return assertionFunction instanceof chai$1.Assertion ? proxy : assertionFunction;
52
+ }
53
+ if (key === "assert") {
54
+ return assertionFunction;
55
+ }
56
+ if (typeof key === "string" && unsupported.includes(key)) {
57
+ throw new SyntaxError(
58
+ `expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`
59
+ );
60
+ }
61
+ return function(...args) {
62
+ const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
63
+ return new Promise((resolve, reject) => {
64
+ let intervalId;
65
+ let lastError;
66
+ const { setTimeout, clearTimeout } = getSafeTimers();
67
+ const timeoutId = setTimeout(() => {
68
+ clearTimeout(intervalId);
69
+ reject(
70
+ copyStackTrace$1(
71
+ new Error(`Matcher did not succeed in ${timeout}ms`, {
72
+ cause: lastError
73
+ }),
74
+ STACK_TRACE_ERROR
75
+ )
76
+ );
77
+ }, timeout);
78
+ const check = async () => {
79
+ try {
80
+ chai$1.util.flag(assertion, "_name", key);
81
+ const obj = await fn();
82
+ chai$1.util.flag(assertion, "object", obj);
83
+ resolve(await assertionFunction.call(assertion, ...args));
84
+ clearTimeout(intervalId);
85
+ clearTimeout(timeoutId);
86
+ } catch (err) {
87
+ lastError = err;
88
+ intervalId = setTimeout(check, interval);
89
+ }
90
+ };
91
+ check();
92
+ });
93
+ };
94
+ }
95
+ });
96
+ return proxy;
97
+ };
40
98
  }
41
- async function waitForImportsToResolve() {
42
- await waitNextTick();
43
- const state = getWorkerState();
44
- const promises = [];
45
- let resolvingCount = 0;
46
- for (const mod of state.moduleCache.values()) {
47
- if (mod.promise && !mod.evaluated) {
48
- promises.push(mod.promise);
49
- }
50
- if (mod.resolving) {
51
- resolvingCount++;
52
- }
53
- }
54
- if (!promises.length && !resolvingCount) {
55
- return;
99
+ function copyStackTrace$1(target, source) {
100
+ if (source.stack !== void 0) {
101
+ target.stack = source.stack.replace(source.message, target.message);
56
102
  }
57
- await Promise.allSettled(promises);
58
- await waitForImportsToResolve();
103
+ return target;
59
104
  }
60
105
 
61
106
  function commonjsRequire(path) {
@@ -365,98 +410,6 @@ chai$1.use(Subset);
365
410
  chai$1.use(SnapshotPlugin);
366
411
  chai$1.use(JestAsymmetricMatchers);
367
412
 
368
- const unsupported = [
369
- // .poll is meant to retry matchers until they succeed, and
370
- // snapshots will always succeed as long as the poll method doesn't thow an error
371
- // in this case using the `vi.waitFor` method is more appropriate
372
- "matchSnapshot",
373
- "toMatchSnapshot",
374
- "toMatchInlineSnapshot",
375
- "toThrowErrorMatchingSnapshot",
376
- "toThrowErrorMatchingInlineSnapshot",
377
- // toThrow will never succeed because we call the poll callback until it doesn't throw
378
- "throws",
379
- "Throw",
380
- "throw",
381
- "toThrow",
382
- "toThrowError"
383
- // these are not supported because you can call them without `.poll`,
384
- // we throw an error inside the rejects/resolves methods to prevent this
385
- // rejects,
386
- // resolves
387
- ];
388
- function createExpectPoll(expect) {
389
- return function poll(fn, options = {}) {
390
- const state = getWorkerState();
391
- const defaults = state.config.expect?.poll ?? {};
392
- const {
393
- interval = defaults.interval ?? 50,
394
- timeout = defaults.timeout ?? 1e3,
395
- message
396
- } = options;
397
- const assertion = expect(null, message).withContext({
398
- poll: true
399
- });
400
- fn = fn.bind(assertion);
401
- const proxy = new Proxy(assertion, {
402
- get(target, key, receiver) {
403
- const assertionFunction = Reflect.get(target, key, receiver);
404
- if (typeof assertionFunction !== "function") {
405
- return assertionFunction instanceof chai$1.Assertion ? proxy : assertionFunction;
406
- }
407
- if (key === "assert") {
408
- return assertionFunction;
409
- }
410
- if (typeof key === "string" && unsupported.includes(key)) {
411
- throw new SyntaxError(
412
- `expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`
413
- );
414
- }
415
- return function(...args) {
416
- const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
417
- return new Promise((resolve, reject) => {
418
- let intervalId;
419
- let lastError;
420
- const { setTimeout, clearTimeout } = getSafeTimers();
421
- const timeoutId = setTimeout(() => {
422
- clearTimeout(intervalId);
423
- reject(
424
- copyStackTrace$1(
425
- new Error(`Matcher did not succeed in ${timeout}ms`, {
426
- cause: lastError
427
- }),
428
- STACK_TRACE_ERROR
429
- )
430
- );
431
- }, timeout);
432
- const check = async () => {
433
- try {
434
- chai$1.util.flag(assertion, "_name", key);
435
- const obj = await fn();
436
- chai$1.util.flag(assertion, "object", obj);
437
- resolve(await assertionFunction.call(assertion, ...args));
438
- clearTimeout(intervalId);
439
- clearTimeout(timeoutId);
440
- } catch (err) {
441
- lastError = err;
442
- intervalId = setTimeout(check, interval);
443
- }
444
- };
445
- check();
446
- });
447
- };
448
- }
449
- });
450
- return proxy;
451
- };
452
- }
453
- function copyStackTrace$1(target, source) {
454
- if (source.stack !== void 0) {
455
- target.stack = source.stack.replace(source.message, target.message);
456
- }
457
- return target;
458
- }
459
-
460
413
  function createExpect(test) {
461
414
  const expect = (value, message) => {
462
415
  const { assertionCalls } = getState(expect);
@@ -3942,4 +3895,4 @@ function getImporter(name) {
3942
3895
  return stack?.file || "";
3943
3896
  }
3944
3897
 
3945
- export { globalExpect as a, vitest as b, createExpect as c, getSnapshotClient as g, resetModules as r, vi as v };
3898
+ export { globalExpect as a, vitest as b, createExpect as c, getSnapshotClient as g, vi as v };
@@ -1,4 +1,4 @@
1
- import { I as InlineConfig } from './reporters.C4ZHgdxQ.js';
1
+ import { I as InlineConfig } from './reporters.anwo7Y6a.js';
2
2
 
3
3
  type VitestInlineConfig = InlineConfig;
4
4
  declare module 'vite' {
@@ -1,18 +1,15 @@
1
- import vm, { isContext } from 'node:vm';
2
1
  import { fileURLToPath, pathToFileURL } from 'node:url';
2
+ import vm, { isContext } from 'node:vm';
3
3
  import { dirname, basename, extname, normalize, join, resolve } from 'pathe';
4
- import { createCustomConsole } from './console.CfT1Wjed.js';
5
- import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute._eQQfgI8.js';
6
4
  import { distDir } from '../path.js';
7
- import { dirname as dirname$1 } from 'node:path';
5
+ import { createCustomConsole } from './console.BYGVloWk.js';
6
+ import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.2pr0rHgK.js';
8
7
  import fs from 'node:fs';
8
+ import { dirname as dirname$1 } from 'node:path';
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 '@vitest/runner/utils';
13
- import '@vitest/utils';
14
- import { p as provideWorkerState } from './utils.Ck2hJTRs.js';
15
- import './env.CmHVDJnw.js';
12
+ import { p as provideWorkerState } from './utils.C8RiOc4B.js';
16
13
 
17
14
  const _require = createRequire(import.meta.url);
18
15
  const requiresCache = /* @__PURE__ */ new WeakMap();
@@ -1,8 +1,8 @@
1
- import { ViteNodeResolveId, ModuleCacheMap } from 'vite-node';
2
1
  import { File, TaskResultPack, CancelReason, Task } from '@vitest/runner';
2
+ import { ViteNodeResolveId, ModuleCacheMap } from 'vite-node';
3
3
  import { S as SerializedConfig } from './config.Crbj2GAb.js';
4
+ import { T as TransformMode, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.LoooBwUu.js';
4
5
  import { SnapshotResult } from '@vitest/snapshot';
5
- import { T as TransformMode, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.CzISCQ7o.js';
6
6
 
7
7
  type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
8
8
  type ReturnType<T> = T extends (...args: any) => infer R ? R : never;
@@ -17,6 +17,10 @@ interface ChannelOptions {
17
17
  * Listener to receive raw message
18
18
  */
19
19
  on: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
20
+ /**
21
+ * Clear the listener when `$close` is called
22
+ */
23
+ off?: (fn: (data: any, ...extras: any[]) => void) => any | Promise<any>;
20
24
  /**
21
25
  * Custom function to serialize data
22
26
  *
@@ -29,6 +33,10 @@ interface ChannelOptions {
29
33
  * by default it passes the data as-is
30
34
  */
31
35
  deserialize?: (data: any) => any;
36
+ /**
37
+ * Call the methods with the RPC context or the original functions object
38
+ */
39
+ bind?: 'rpc' | 'functions';
32
40
  }
33
41
  interface EventOptions<Remote> {
34
42
  /**
@@ -67,6 +75,7 @@ type BirpcReturn<RemoteFunctions, LocalFunctions = Record<string, never>> = {
67
75
  [K in keyof RemoteFunctions]: BirpcFn<RemoteFunctions[K]>;
68
76
  } & {
69
77
  $functions: LocalFunctions;
78
+ $close: () => void;
70
79
  };
71
80
 
72
81
  interface RuntimeRPC {
@@ -143,4 +152,4 @@ interface WorkerGlobalState {
143
152
  };
144
153
  }
145
154
 
146
- export type { BirpcOptions as B, ContextRPC as C, RuntimeRPC as R, WorkerGlobalState as W, BirpcReturn as a, WorkerRPC as b, RunnerRPC as c, ResolveIdFunction as d, ContextTestEnvironment as e };
155
+ export type { BirpcOptions as B, ContextRPC as C, RuntimeRPC as R, WorkerGlobalState as W, BirpcReturn as a, WorkerRPC as b, RunnerRPC as c, ContextTestEnvironment as d, ResolveIdFunction as e };
@@ -1,5 +1,5 @@
1
1
  import { MessagePort } from 'node:worker_threads';
2
- import { C as ContextRPC } from './worker.B6RjTtbk.js';
2
+ import { C as ContextRPC } from './worker.BAlI9hII.js';
3
3
 
4
4
  interface WorkerContext extends ContextRPC {
5
5
  port: MessagePort;
package/dist/cli.js CHANGED
@@ -1,9 +1,8 @@
1
- import { c as createCLI } from './chunks/cac.BSMVokHR.js';
2
- import 'pathe';
1
+ import { c as createCLI } from './chunks/cac.DrfPaMvZ.js';
2
+ import '@vitest/utils';
3
3
  import 'events';
4
+ import 'pathe';
4
5
  import 'tinyrainbow';
5
- import './chunks/base.DwXGwWst.js';
6
- import '@vitest/utils';
7
6
  import './chunks/constants.fzPh7AOq.js';
8
7
 
9
8
  createCLI().parse();
package/dist/config.cjs CHANGED
@@ -4,10 +4,6 @@ var os = require('node:os');
4
4
  var stdEnv = require('std-env');
5
5
  var vite = require('vite');
6
6
 
7
- const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
8
- const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
9
- (isNode || isDeno) && process.platform === "win32";
10
-
11
7
  const defaultBrowserPort = 63315;
12
8
  const extraInlineDeps = [
13
9
  /^(?!.*node_modules).*\.mjs$/,
@@ -16,6 +12,10 @@ const extraInlineDeps = [
16
12
  /vite\w*\/dist\/client\/env.mjs/
17
13
  ];
18
14
 
15
+ const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
16
+ const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
17
+ (isNode || isDeno) && process.platform === "win32";
18
+
19
19
  const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
20
20
  const defaultExclude = [
21
21
  "**/node_modules/**",
package/dist/config.d.ts CHANGED
@@ -1,23 +1,23 @@
1
- import './chunks/vite.YH7MrecS.js';
2
1
  import { UserConfig as UserConfig$1, ConfigEnv } from 'vite';
3
2
  export { ConfigEnv, Plugin, UserConfig as ViteUserConfig, mergeConfig } from 'vite';
4
- import { R as ResolvedCoverageOptions, c as CoverageV8Options, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport, W as WorkspaceProjectConfiguration } from './chunks/reporters.C4ZHgdxQ.js';
5
- import '@vitest/runner';
6
- import '@vitest/pretty-format';
3
+ import { R as ResolvedCoverageOptions, c as CoverageV8Options, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport, W as WorkspaceProjectConfiguration } from './chunks/reporters.anwo7Y6a.js';
4
+ import './chunks/vite.BdBj-UWY.js';
7
5
  import './chunks/config.Crbj2GAb.js';
6
+ import '@vitest/pretty-format';
7
+ import '@vitest/runner';
8
8
  import '@vitest/snapshot';
9
9
  import '@vitest/snapshot/environment';
10
10
  import 'vite-node';
11
- import './chunks/environment.CzISCQ7o.js';
11
+ import 'chai';
12
+ import './chunks/environment.LoooBwUu.js';
12
13
  import 'node:stream';
13
- import 'vite-node/client';
14
- import '@vitest/snapshot/manager';
15
- import 'vite-node/server';
16
14
  import '@vitest/utils';
17
15
  import '@vitest/utils/source-map';
16
+ import 'vite-node/client';
17
+ import 'vite-node/server';
18
+ import '@vitest/snapshot/manager';
18
19
  import 'node:fs';
19
- import 'chai';
20
- import './chunks/benchmark.JVlTzojj.js';
20
+ import './chunks/benchmark.geERunq4.js';
21
21
  import '@vitest/runner/utils';
22
22
  import 'tinybench';
23
23
 
package/dist/config.js CHANGED
@@ -2,10 +2,6 @@ import os from 'node:os';
2
2
  import { isCI } from 'std-env';
3
3
  export { mergeConfig } from 'vite';
4
4
 
5
- const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
6
- const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
7
- (isNode || isDeno) && process.platform === "win32";
8
-
9
5
  const defaultBrowserPort = 63315;
10
6
  const extraInlineDeps = [
11
7
  /^(?!.*node_modules).*\.mjs$/,
@@ -14,6 +10,10 @@ const extraInlineDeps = [
14
10
  /vite\w*\/dist\/client\/env.mjs/
15
11
  ];
16
12
 
13
+ const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
14
+ const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
15
+ (isNode || isDeno) && process.platform === "win32";
16
+
17
17
  const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
18
18
  const defaultExclude = [
19
19
  "**/node_modules/**",