vitest 0.27.3 → 0.28.0

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 (60) hide show
  1. package/LICENSE.md +4 -93
  2. package/browser.d.ts +1 -1
  3. package/dist/browser.d.ts +11 -13
  4. package/dist/browser.js +9 -34
  5. package/dist/{chunk-api-setup.0a2398d8.js → chunk-api-setup.52751a38.js} +26 -12
  6. package/dist/chunk-constants.797d3ebf.js +42 -0
  7. package/dist/{chunk-install-pkg.7b006b3e.js → chunk-install-pkg.cfd23146.js} +51 -11
  8. package/dist/{vendor-index.57682f0c.js → chunk-integrations-coverage.48e6286b.js} +33 -4
  9. package/dist/chunk-integrations-globals.0d5f50f0.js +29 -0
  10. package/dist/chunk-integrations-run-once.38756e30.js +27 -0
  11. package/dist/chunk-integrations-utils.f1f6f1ed.js +118 -0
  12. package/dist/{chunk-node-git.59caac18.js → chunk-node-git.d9ad64ab.js} +6 -8
  13. package/dist/{chunk-snapshot-manager.d16903ef.js → chunk-node-pkg.dcdf4369.js} +7440 -172
  14. package/dist/{chunk-runtime-mocker.66533d65.js → chunk-runtime-mocker.03017e8c.js} +13 -12
  15. package/dist/{chunk-runtime-rpc.e79efa9a.js → chunk-runtime-rpc.9c0386cc.js} +3 -2
  16. package/dist/chunk-runtime-setup.d9302cfd.js +20 -0
  17. package/dist/chunk-snapshot-env.6457638e.js +11 -0
  18. package/dist/chunk-utils-base.977ae74f.js +77 -0
  19. package/dist/chunk-utils-env.860d90c2.js +6 -0
  20. package/dist/chunk-utils-global.442d1d33.js +73 -0
  21. package/dist/{chunk-utils-import.eb63557e.js → chunk-utils-import.9911c99d.js} +3289 -169
  22. package/dist/chunk-utils-tasks.1b603032.js +103 -0
  23. package/dist/cli-wrapper.js +7 -6
  24. package/dist/cli.js +16 -15
  25. package/dist/config.d.ts +7 -2
  26. package/dist/entry.js +233 -28
  27. package/dist/env-afee91f0.d.ts +10 -0
  28. package/dist/environments.d.ts +7 -2
  29. package/dist/index.d.ts +160 -11
  30. package/dist/index.js +17 -18
  31. package/dist/loader.js +6 -6
  32. package/dist/node.d.ts +9 -7
  33. package/dist/node.js +18 -17
  34. package/dist/runners-chunk.js +215 -0
  35. package/dist/runners.d.ts +39 -0
  36. package/dist/runners.js +18 -0
  37. package/dist/spy.js +1 -2
  38. package/dist/suite.d.ts +2 -0
  39. package/dist/suite.js +2 -19
  40. package/dist/{types-c1386a7d.d.ts → types-c800444e.d.ts} +160 -425
  41. package/dist/{vendor-index.e6c27006.js → vendor-index.618ca5a1.js} +1078 -10
  42. package/dist/{vendor-index.b0346fe4.js → vendor-index.bdee400f.js} +1 -0
  43. package/dist/worker.js +11 -13
  44. package/package.json +21 -12
  45. package/runners.d.ts +1 -0
  46. package/suite.d.ts +1 -0
  47. package/dist/chunk-integrations-coverage.18366936.js +0 -242
  48. package/dist/chunk-integrations-globals.59b4d460.js +0 -28
  49. package/dist/chunk-mock-date.91595ccd.js +0 -350
  50. package/dist/chunk-runtime-chain.07d16eac.js +0 -2594
  51. package/dist/chunk-runtime-error.f2062967.js +0 -144
  52. package/dist/chunk-runtime-setup.8ca273cd.js +0 -653
  53. package/dist/chunk-utils-env.4ebb0106.js +0 -229
  54. package/dist/chunk-utils-source-map.832515f7.js +0 -408
  55. package/dist/chunk-utils-timers.52534f96.js +0 -3573
  56. package/dist/index-2dd51af4.d.ts +0 -258
  57. package/dist/vendor-index.451e37bc.js +0 -1071
  58. package/dist/vendor-index.723a074f.js +0 -102
  59. package/dist/vendor-index.9c919048.js +0 -61
  60. package/dist/vendor-index.9f20a9be.js +0 -6291
@@ -1,144 +0,0 @@
1
- import util$1 from 'util';
2
- import { util } from 'chai';
3
- import { a as stringify } from './chunk-utils-timers.52534f96.js';
4
- import { w as deepClone, g as getWorkerState, x as getType } from './chunk-mock-date.91595ccd.js';
5
-
6
- const IS_RECORD_SYMBOL = "@@__IMMUTABLE_RECORD__@@";
7
- const IS_COLLECTION_SYMBOL = "@@__IMMUTABLE_ITERABLE__@@";
8
- const isImmutable = (v) => v && (v[IS_COLLECTION_SYMBOL] || v[IS_RECORD_SYMBOL]);
9
- const OBJECT_PROTO = Object.getPrototypeOf({});
10
- function getUnserializableMessage(err) {
11
- if (err instanceof Error)
12
- return `<unserializable>: ${err.message}`;
13
- if (typeof err === "string")
14
- return `<unserializable>: ${err}`;
15
- return "<unserializable>";
16
- }
17
- function serializeError(val, seen = /* @__PURE__ */ new WeakMap()) {
18
- if (!val || typeof val === "string")
19
- return val;
20
- if (typeof val === "function")
21
- return `Function<${val.name || "anonymous"}>`;
22
- if (typeof val === "symbol")
23
- return val.toString();
24
- if (typeof val !== "object")
25
- return val;
26
- if (isImmutable(val))
27
- return serializeError(val.toJSON(), seen);
28
- if (val instanceof Promise || val.constructor && val.constructor.prototype === "AsyncFunction")
29
- return "Promise";
30
- if (typeof Element !== "undefined" && val instanceof Element)
31
- return val.tagName;
32
- if (typeof val.asymmetricMatch === "function")
33
- return `${val.toString()} ${util$1.format(val.sample)}`;
34
- if (seen.has(val))
35
- return seen.get(val);
36
- if (Array.isArray(val)) {
37
- const clone = new Array(val.length);
38
- seen.set(val, clone);
39
- val.forEach((e, i) => {
40
- try {
41
- clone[i] = serializeError(e, seen);
42
- } catch (err) {
43
- clone[i] = getUnserializableMessage(err);
44
- }
45
- });
46
- return clone;
47
- } else {
48
- const clone = /* @__PURE__ */ Object.create(null);
49
- seen.set(val, clone);
50
- let obj = val;
51
- while (obj && obj !== OBJECT_PROTO) {
52
- Object.getOwnPropertyNames(obj).forEach((key) => {
53
- if (key in clone)
54
- return;
55
- try {
56
- clone[key] = serializeError(val[key], seen);
57
- } catch (err) {
58
- delete clone[key];
59
- clone[key] = getUnserializableMessage(err);
60
- }
61
- });
62
- obj = Object.getPrototypeOf(obj);
63
- }
64
- return clone;
65
- }
66
- }
67
- function normalizeErrorMessage(message) {
68
- return message.replace(/__vite_ssr_import_\d+__\./g, "");
69
- }
70
- function processError(err) {
71
- if (!err || typeof err !== "object")
72
- return err;
73
- if (err.stack)
74
- err.stackStr = String(err.stack);
75
- if (err.name)
76
- err.nameStr = String(err.name);
77
- const clonedActual = deepClone(err.actual);
78
- const clonedExpected = deepClone(err.expected);
79
- const { replacedActual, replacedExpected } = replaceAsymmetricMatcher(clonedActual, clonedExpected);
80
- err.actual = replacedActual;
81
- err.expected = replacedExpected;
82
- const workerState = getWorkerState();
83
- const maxDiffSize = workerState.config.outputDiffMaxSize;
84
- if (typeof err.expected !== "string")
85
- err.expected = stringify(err.expected, 10, { maxLength: maxDiffSize });
86
- if (typeof err.actual !== "string")
87
- err.actual = stringify(err.actual, 10, { maxLength: maxDiffSize });
88
- try {
89
- if (typeof err.message === "string")
90
- err.message = normalizeErrorMessage(err.message);
91
- if (typeof err.cause === "object" && typeof err.cause.message === "string")
92
- err.cause.message = normalizeErrorMessage(err.cause.message);
93
- } catch {
94
- }
95
- try {
96
- return serializeError(err);
97
- } catch (e) {
98
- return serializeError(new Error(`Failed to fully serialize error: ${e == null ? void 0 : e.message}
99
- Inner error message: ${err == null ? void 0 : err.message}`));
100
- }
101
- }
102
- function isAsymmetricMatcher(data) {
103
- const type = getType(data);
104
- return type === "Object" && typeof data.asymmetricMatch === "function";
105
- }
106
- function isReplaceable(obj1, obj2) {
107
- const obj1Type = getType(obj1);
108
- const obj2Type = getType(obj2);
109
- return obj1Type === obj2Type && obj1Type === "Object";
110
- }
111
- function replaceAsymmetricMatcher(actual, expected, actualReplaced = /* @__PURE__ */ new WeakSet(), expectedReplaced = /* @__PURE__ */ new WeakSet()) {
112
- if (!isReplaceable(actual, expected))
113
- return { replacedActual: actual, replacedExpected: expected };
114
- if (actualReplaced.has(actual) || expectedReplaced.has(expected))
115
- return { replacedActual: actual, replacedExpected: expected };
116
- actualReplaced.add(actual);
117
- expectedReplaced.add(expected);
118
- util.getOwnEnumerableProperties(expected).forEach((key) => {
119
- const expectedValue = expected[key];
120
- const actualValue = actual[key];
121
- if (isAsymmetricMatcher(expectedValue)) {
122
- if (expectedValue.asymmetricMatch(actualValue))
123
- actual[key] = expectedValue;
124
- } else if (isAsymmetricMatcher(actualValue)) {
125
- if (actualValue.asymmetricMatch(expectedValue))
126
- expected[key] = actualValue;
127
- } else if (isReplaceable(actualValue, expectedValue)) {
128
- const replaced = replaceAsymmetricMatcher(
129
- actualValue,
130
- expectedValue,
131
- actualReplaced,
132
- expectedReplaced
133
- );
134
- actual[key] = replaced.replacedActual;
135
- expected[key] = replaced.replacedExpected;
136
- }
137
- });
138
- return {
139
- replacedActual: actual,
140
- replacedExpected: expected
141
- };
142
- }
143
-
144
- export { processError as p };