vitest 4.0.9 → 4.0.10

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 (42) hide show
  1. package/dist/browser.js +1 -1
  2. package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +6 -0
  3. package/dist/chunks/{base.CiIV2DDC.js → base.BFVArrYW.js} +5 -5
  4. package/dist/chunks/{cac.B_NTJoIH.js → cac.D9CYcNPM.js} +7 -7
  5. package/dist/chunks/{cli-api.D48wY175.js → cli-api.RnIE1JbW.js} +56 -54
  6. package/dist/chunks/{creator.BzqvXeRE.js → creator.DU9qFjsW.js} +2 -2
  7. package/dist/chunks/{globals.DBrtKPdh.js → globals.NLOzC_A5.js} +3 -3
  8. package/dist/chunks/{index.op2Re5rn.js → index.B8lJfb0J.js} +1 -1
  9. package/dist/chunks/{index.kotH7DY7.js → index.BYek7GgP.js} +5 -3
  10. package/dist/chunks/{index.z7NPOg2E.js → index.D4KonVSU.js} +1 -1
  11. package/dist/chunks/{index.CGezRSGU.js → index.DZ-mI_Nm.js} +1 -1
  12. package/dist/chunks/{index.CPA8jGhR.js → index.Dua7TZg_.js} +2 -2
  13. package/dist/chunks/{index.BfmpdV5p.js → index.QWbK7rHY.js} +3 -3
  14. package/dist/chunks/init-forks.BZSlxfwV.js +32 -0
  15. package/dist/chunks/{init-threads.C7T0-YMD.js → init-threads.CwE2n-Bv.js} +1 -1
  16. package/dist/chunks/{init.BQhNfT0h.js → init.Cz2kTB9a.js} +1 -1
  17. package/dist/chunks/{plugin.d.DevON6kQ.d.ts → plugin.d.C6KrdvNG.d.ts} +1 -1
  18. package/dist/chunks/{reporters.d.BQ0wpUaj.d.ts → reporters.d.keG-yFSu.d.ts} +2 -1
  19. package/dist/chunks/{setup-common.Dw1XgX0v.js → setup-common.BOzbXE3x.js} +2 -2
  20. package/dist/chunks/{test.w5HLbjmU.js → test.BPErLMrw.js} +1 -1
  21. package/dist/chunks/{vi.CyIUVSoU.js → vi.BiaV1qII.js} +2 -2
  22. package/dist/chunks/{vm.DXN8eCh2.js → vm.wSHjz-et.js} +1 -1
  23. package/dist/cli.js +2 -2
  24. package/dist/config.d.ts +3 -3
  25. package/dist/coverage.d.ts +1 -1
  26. package/dist/environments.js +1 -1
  27. package/dist/index.d.ts +2 -2
  28. package/dist/index.js +3 -3
  29. package/dist/node.d.ts +3 -3
  30. package/dist/node.js +9 -9
  31. package/dist/reporters.d.ts +1 -1
  32. package/dist/reporters.js +2 -2
  33. package/dist/runners.js +3 -3
  34. package/dist/worker.js +9 -9
  35. package/dist/workers/forks.js +10 -11
  36. package/dist/workers/runVmTests.js +6 -6
  37. package/dist/workers/threads.js +10 -10
  38. package/dist/workers/vmForks.js +4 -5
  39. package/dist/workers/vmThreads.js +4 -4
  40. package/package.json +14 -14
  41. package/dist/chunks/_commonjsHelpers.BFTU3MAI.js +0 -7
  42. package/dist/chunks/init-forks.aqTzCSR2.js +0 -65
@@ -1,65 +0,0 @@
1
- import v8 from 'node:v8';
2
- import { i as init } from './init.BQhNfT0h.js';
3
-
4
- if (!process.send) throw new Error("Expected worker to be run in node:child_process");
5
- // Store globals in case tests overwrite them
6
- const processExit = process.exit.bind(process);
7
- const processSend = process.send.bind(process);
8
- const processOn = process.on.bind(process);
9
- const processOff = process.off.bind(process);
10
- const processRemoveAllListeners = process.removeAllListeners.bind(process);
11
- // Work-around for nodejs/node#55094
12
- if (process.execArgv.some((execArg) => execArg.startsWith("--prof") || execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof") || execArg.startsWith("--diagnostic-dir"))) processOn("SIGTERM", () => processExit());
13
- function workerInit(options) {
14
- const { runTests } = options;
15
- init({
16
- post: (v) => processSend(v),
17
- on: (cb) => processOn("message", cb),
18
- off: (cb) => processOff("message", cb),
19
- teardown: () => processRemoveAllListeners("message"),
20
- serialize: v8.serialize,
21
- deserialize: (v) => v8.deserialize(Buffer.from(v)),
22
- runTests: (state) => executeTests("run", state),
23
- collectTests: (state) => executeTests("collect", state),
24
- setup: options.setup
25
- });
26
- async function executeTests(method, state) {
27
- state.ctx.config = unwrapSerializableConfig(state.ctx.config);
28
- try {
29
- await runTests(method, state);
30
- } finally {
31
- process.exit = processExit;
32
- }
33
- }
34
- }
35
- /**
36
- * Reverts the wrapping done by `wrapSerializableConfig` in {@link file://./../../node/pool/runtimes/forks.ts}
37
- */
38
- function unwrapSerializableConfig(config) {
39
- if (config.testNamePattern && typeof config.testNamePattern === "string") {
40
- const testNamePattern = config.testNamePattern;
41
- if (testNamePattern.startsWith("$$vitest:")) config.testNamePattern = parseRegexp(testNamePattern.slice(9));
42
- }
43
- if (config.defines && Array.isArray(config.defines.keys) && config.defines.original) {
44
- const { keys, original } = config.defines;
45
- const defines = {};
46
- // Apply all keys from the original. Entries which had undefined value are missing from original now
47
- for (const key of keys) defines[key] = original[key];
48
- config.defines = defines;
49
- }
50
- return config;
51
- }
52
- function parseRegexp(input) {
53
- // Parse input
54
- // eslint-disable-next-line regexp/no-misleading-capturing-group
55
- const m = input.match(/(\/?)(.+)\1([a-z]*)/i);
56
- // match nothing
57
- if (!m) return /$^/;
58
- // Invalid flags
59
- // eslint-disable-next-line regexp/optimal-quantifier-concatenation
60
- if (m[3] && !/^(?!.*?(.).*?\1)[gmixXsuUAJ]+$/.test(m[3])) return new RegExp(input);
61
- // Create the regular expression
62
- return new RegExp(m[2], m[3]);
63
- }
64
-
65
- export { workerInit as w };