vitest 4.0.0-beta.17 → 4.0.0-beta.19

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 (58) hide show
  1. package/dist/browser.d.ts +3 -3
  2. package/dist/browser.js +1 -1
  3. package/dist/{worker-base.js → chunks/base.CtHM3ryk.js} +18 -91
  4. package/dist/chunks/{browser.d.CCG7W26I.d.ts → browser.d.B9iJzZyn.d.ts} +3 -2
  5. package/dist/chunks/{cac.BO_6jvrs.js → cac.DCrQhweU.js} +15 -62
  6. package/dist/chunks/{cli-api.BvCJGado.js → cli-api.BjHteKX0.js} +1322 -55
  7. package/dist/chunks/{config.d.C4PpNy7v.d.ts → config.d.u2CUDWwS.d.ts} +2 -16
  8. package/dist/chunks/{coverage.3htTSxXZ.js → coverage.FU3w4IrQ.js} +39 -1213
  9. package/dist/chunks/{creator.Daoa5_gR.js → creator.DucAaYBz.js} +1 -1
  10. package/dist/chunks/{defaults.CXFFjsi8.js → defaults.BOqNVLsY.js} +0 -1
  11. package/dist/chunks/evaluatedModules.Dg1zASAC.js +17 -0
  12. package/dist/chunks/{global.d.D1pbKXir.d.ts → global.d.BgJSTpgQ.d.ts} +2 -1
  13. package/dist/chunks/{globals.DC4ntO86.js → globals.BGT_RUsD.js} +5 -3
  14. package/dist/chunks/{index.01uBqPwR.js → index.BdSLhLDZ.js} +1 -1
  15. package/dist/chunks/{index.Bt-upxGS.js → index.CbWINfS7.js} +29 -4
  16. package/dist/chunks/{index.DehVUBn4.js → index.CcRZ6fUh.js} +1507 -12
  17. package/dist/chunks/{index.Dnl38iQ_.js → index.RwjEGCQ0.js} +3 -3
  18. package/dist/chunks/init-forks.DSafeltJ.js +54 -0
  19. package/dist/chunks/init-threads.SUtZ-067.js +17 -0
  20. package/dist/chunks/{worker.DVTUM2IW.js → init.B2EESLQM.js} +98 -81
  21. package/dist/chunks/{inspector.Br76Q2Mb.js → inspector.DLZxSeU3.js} +1 -2
  22. package/dist/chunks/{moduleRunner.d.aXWuQhZN.d.ts → moduleRunner.d.YtNsMIoJ.d.ts} +1 -1
  23. package/dist/chunks/{plugin.d.CqKwuCSa.d.ts → plugin.d.BB__S31E.d.ts} +1 -1
  24. package/dist/chunks/{reporters.d.DAyr7w3M.d.ts → reporters.d.C6nGyY9_.d.ts} +1104 -1112
  25. package/dist/chunks/{resolveSnapshotEnvironment.BsJpmVZR.js → resolveSnapshotEnvironment.DJJKMKxb.js} +2 -2
  26. package/dist/chunks/{setup-common.BewgbkTd.js → setup-common.DR1sucx6.js} +1 -1
  27. package/dist/chunks/{startModuleRunner.DPBo3mme.js → startModuleRunner.C2tTvmF9.js} +3 -1
  28. package/dist/chunks/{test.CTuWuHYH.js → test.C3RPt8JR.js} +1 -1
  29. package/dist/chunks/{vi.B2--mG9U.js → vi.BZvkKVkM.js} +1 -1
  30. package/dist/{worker-vm.js → chunks/vm.DBeOXrP9.js} +6 -66
  31. package/dist/chunks/{worker.d.DSgBAZPX.d.ts → worker.d.BFk-vvBU.d.ts} +79 -4
  32. package/dist/cli.js +8 -9
  33. package/dist/config.cjs +0 -1
  34. package/dist/config.d.ts +6 -7
  35. package/dist/config.js +1 -1
  36. package/dist/coverage.d.ts +4 -4
  37. package/dist/coverage.js +2 -13
  38. package/dist/environments.js +1 -1
  39. package/dist/index.d.ts +13 -9
  40. package/dist/index.js +5 -3
  41. package/dist/module-evaluator.d.ts +3 -3
  42. package/dist/module-runner.js +1 -1
  43. package/dist/node.d.ts +79 -15
  44. package/dist/node.js +25 -26
  45. package/dist/reporters.d.ts +4 -4
  46. package/dist/reporters.js +9 -10
  47. package/dist/runners.d.ts +1 -1
  48. package/dist/runners.js +2 -2
  49. package/dist/worker.d.ts +26 -0
  50. package/dist/worker.js +46 -0
  51. package/dist/workers/forks.js +50 -0
  52. package/dist/workers/runVmTests.js +8 -7
  53. package/dist/workers/threads.js +50 -0
  54. package/dist/workers/vmForks.js +35 -0
  55. package/dist/workers/vmThreads.js +35 -0
  56. package/package.json +17 -14
  57. package/worker.d.ts +1 -0
  58. package/dist/chunks/typechecker.DsKAhua5.js +0 -1522
@@ -39,7 +39,7 @@ import { render } from '@testing-library/jsx'
39
39
  import HelloWorld from './HelloWorld.jsx'
40
40
 
41
41
  test('renders name', async () => {
42
- const { getByText } = render(<HelloWorld name="Vitest" />)
42
+ const { getByText } = await render(<HelloWorld name="Vitest" />)
43
43
  await expect.element(getByText('Hello Vitest!')).toBeInTheDocument()
44
44
  })
45
45
  `
@@ -40,7 +40,6 @@ const configDefaults = Object.freeze({
40
40
  watch: !isCI && process.stdin.isTTY,
41
41
  globals: false,
42
42
  environment: "node",
43
- pool: "forks",
44
43
  clearMocks: false,
45
44
  restoreMocks: false,
46
45
  mockReset: false,
@@ -0,0 +1,17 @@
1
+ import { dirname, resolve } from 'pathe';
2
+ import { EvaluatedModules } from 'vite/module-runner';
3
+
4
+ // TODO: this is not needed in Vite 7.2+
5
+ class VitestEvaluatedModules extends EvaluatedModules {
6
+ getModuleSourceMapById(id) {
7
+ const map = super.getModuleSourceMapById(id);
8
+ if (map != null && !("_patched" in map)) {
9
+ map._patched = true;
10
+ const dir = dirname(map.url);
11
+ map.resolvedSources = (map.map.sources || []).map((s) => resolve(dir, s || ""));
12
+ }
13
+ return map;
14
+ }
15
+ }
16
+
17
+ export { VitestEvaluatedModules as V };
@@ -2,7 +2,7 @@ import { PromisifyAssertion, Tester, ExpectStatic } from '@vitest/expect';
2
2
  import { Plugin } from '@vitest/pretty-format';
3
3
  import { SnapshotState } from '@vitest/snapshot';
4
4
  import { B as BenchmarkResult } from './benchmark.d.DAaHLpsq.js';
5
- import { U as UserConsoleLog } from './worker.d.DSgBAZPX.js';
5
+ import { U as UserConsoleLog } from './worker.d.BFk-vvBU.js';
6
6
 
7
7
  interface SnapshotMatcher<T> {
8
8
  <U extends { [P in keyof T] : any }>(snapshot: Partial<U>, hint?: string): void;
@@ -23,6 +23,7 @@ declare module "@vitest/expect" {
23
23
  message?: string;
24
24
  }
25
25
  interface ExpectStatic {
26
+ assert: Chai.AssertStatic;
26
27
  unreachable: (message?: string) => never;
27
28
  soft: <T>(actual: T, message?: string) => Assertion<T>;
28
29
  poll: <T>(actual: () => T, options?: ExpectPollOptions) => PromisifyAssertion<Awaited<T>>;
@@ -1,6 +1,6 @@
1
1
  import { g as globalApis } from './constants.D_Q9UYh-.js';
2
- import { i as index } from './index.Dnl38iQ_.js';
3
- import './vi.B2--mG9U.js';
2
+ import { i as index } from './index.RwjEGCQ0.js';
3
+ import './vi.BZvkKVkM.js';
4
4
  import '@vitest/expect';
5
5
  import '@vitest/runner';
6
6
  import '@vitest/runner/utils';
@@ -15,8 +15,10 @@ import '@vitest/utils/source-map';
15
15
  import './_commonjsHelpers.BFTU3MAI.js';
16
16
  import './date.-jtEtIeV.js';
17
17
  import './benchmark.DHKMYAts.js';
18
- import 'expect-type';
18
+ import './evaluatedModules.Dg1zASAC.js';
19
+ import 'pathe';
19
20
  import 'vite/module-runner';
21
+ import 'expect-type';
20
22
 
21
23
  function registerApiGlobally() {
22
24
  globalApis.forEach((api) => {
@@ -2,7 +2,7 @@ import fs from 'node:fs';
2
2
  import { getTasks, getFullName, getTests } from '@vitest/runner/utils';
3
3
  import * as pathe from 'pathe';
4
4
  import c from 'tinyrainbow';
5
- import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName, s as separator } from './index.DehVUBn4.js';
5
+ import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName, s as separator } from './index.CcRZ6fUh.js';
6
6
  import { stripVTControlCharacters } from 'node:util';
7
7
  import { notNullish } from '@vitest/utils/helpers';
8
8
 
@@ -391,7 +391,7 @@ var jsdom = {
391
391
  userAgent,
392
392
  ...restOptions
393
393
  });
394
- const clearWindowErrors = catchWindowErrors(dom.window);
394
+ const clearAddEventListenerPatch = patchAddEventListener(dom.window), clearWindowErrors = catchWindowErrors(dom.window);
395
395
  dom.window.Buffer = Buffer, dom.window.jsdom = dom;
396
396
  for (const name of [
397
397
  "structuredClone",
@@ -422,7 +422,7 @@ var jsdom = {
422
422
  return dom.getInternalVMContext();
423
423
  },
424
424
  teardown() {
425
- clearWindowErrors(), dom.window.close(), dom = void 0;
425
+ clearAddEventListenerPatch(), clearWindowErrors(), dom.window.close(), dom = void 0;
426
426
  }
427
427
  };
428
428
  },
@@ -438,12 +438,37 @@ var jsdom = {
438
438
  contentType,
439
439
  userAgent,
440
440
  ...restOptions
441
- }), { keys, originals } = populateGlobal(global, dom.window, { bindFunctions: true }), clearWindowErrors = catchWindowErrors(global);
441
+ }), clearAddEventListenerPatch = patchAddEventListener(dom.window), { keys, originals } = populateGlobal(global, dom.window, { bindFunctions: true }), clearWindowErrors = catchWindowErrors(global);
442
442
  return global.jsdom = dom, { teardown(global) {
443
- clearWindowErrors(), dom.window.close(), delete global.jsdom, keys.forEach((key) => delete global[key]), originals.forEach((v, k) => global[k] = v);
443
+ clearAddEventListenerPatch(), clearWindowErrors(), dom.window.close(), delete global.jsdom, keys.forEach((key) => delete global[key]), originals.forEach((v, k) => global[k] = v);
444
444
  } };
445
445
  }
446
446
  };
447
+ function patchAddEventListener(window) {
448
+ const JSDOMAbortSignal = window.AbortSignal, JSDOMAbortController = window.AbortController, originalAddEventListener = window.EventTarget.prototype.addEventListener;
449
+ return window.EventTarget.prototype.addEventListener = function addEventListener(type, callback, options) {
450
+ if (typeof options === "object" && options.signal != null) {
451
+ const { signal,...otherOptions } = options;
452
+ // - this happens because AbortSignal is provided by Node.js,
453
+ // but jsdom APIs require jsdom's AbortSignal, while Node APIs
454
+ // (like fetch and Request) require a Node.js AbortSignal
455
+ // - disable narrow typing with "as any" because we need it later
456
+ if (!(signal instanceof JSDOMAbortSignal)) {
457
+ const jsdomCompatOptions = Object.create(null);
458
+ Object.assign(jsdomCompatOptions, otherOptions);
459
+ // use jsdom-native abort controller instead and forward the
460
+ // previous one with `addEventListener`
461
+ const jsdomAbortController = new JSDOMAbortController();
462
+ return signal.addEventListener("abort", () => {
463
+ jsdomAbortController.abort(signal.reason);
464
+ }), jsdomCompatOptions.signal = jsdomAbortController.signal, originalAddEventListener.call(this, type, callback, jsdomCompatOptions);
465
+ }
466
+ }
467
+ return originalAddEventListener.call(this, type, callback, options);
468
+ }, () => {
469
+ window.EventTarget.prototype.addEventListener = originalAddEventListener;
470
+ };
471
+ }
447
472
 
448
473
  // some globals we do not want, either because deprecated or we set it ourselves
449
474
  const denyList = new Set([