vitest 0.27.2 → 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 (64) 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 +10 -34
  5. package/dist/{chunk-api-setup.029198e3.js → chunk-api-setup.52751a38.js} +27 -12
  6. package/dist/chunk-constants.797d3ebf.js +42 -0
  7. package/dist/{chunk-env-node.787e9561.js → chunk-env-node.ffd1183b.js} +26 -0
  8. package/dist/{chunk-install-pkg.7b006b3e.js → chunk-install-pkg.cfd23146.js} +51 -11
  9. package/dist/chunk-integrations-coverage.48e6286b.js +3993 -0
  10. package/dist/chunk-integrations-globals.0d5f50f0.js +29 -0
  11. package/dist/chunk-integrations-run-once.38756e30.js +27 -0
  12. package/dist/chunk-integrations-utils.f1f6f1ed.js +118 -0
  13. package/dist/{chunk-node-git.125c9008.js → chunk-node-git.d9ad64ab.js} +6 -7
  14. package/dist/{chunk-snapshot-manager.ce714e21.js → chunk-node-pkg.dcdf4369.js} +12653 -9324
  15. package/dist/{chunk-runtime-mocker.58511c38.js → chunk-runtime-mocker.03017e8c.js} +14 -13
  16. package/dist/{chunk-runtime-rpc.d709e91b.js → chunk-runtime-rpc.9c0386cc.js} +3 -2
  17. package/dist/chunk-runtime-setup.d9302cfd.js +20 -0
  18. package/dist/chunk-snapshot-env.6457638e.js +11 -0
  19. package/dist/chunk-utils-base.977ae74f.js +77 -0
  20. package/dist/chunk-utils-env.860d90c2.js +6 -0
  21. package/dist/chunk-utils-global.442d1d33.js +73 -0
  22. package/dist/{chunk-utils-import.054ab315.js → chunk-utils-import.9911c99d.js} +3289 -169
  23. package/dist/chunk-utils-tasks.1b603032.js +103 -0
  24. package/dist/cli-wrapper.js +8 -6
  25. package/dist/cli.js +18 -15
  26. package/dist/config.cjs +10 -7
  27. package/dist/config.d.ts +22 -4
  28. package/dist/config.js +10 -8
  29. package/dist/entry.js +244 -28
  30. package/dist/env-afee91f0.d.ts +10 -0
  31. package/dist/environments.d.ts +7 -2
  32. package/dist/environments.js +1 -1
  33. package/dist/index.d.ts +160 -11
  34. package/dist/index.js +18 -18
  35. package/dist/loader.js +9 -8
  36. package/dist/node.d.ts +9 -7
  37. package/dist/node.js +20 -17
  38. package/dist/runners-chunk.js +215 -0
  39. package/dist/runners.d.ts +39 -0
  40. package/dist/runners.js +18 -0
  41. package/dist/spy.js +1 -2
  42. package/dist/suite.d.ts +2 -0
  43. package/dist/suite.js +2 -18
  44. package/dist/{types-d97c72c7.d.ts → types-c800444e.d.ts} +196 -437
  45. package/dist/{vendor-index.e6c27006.js → vendor-index.618ca5a1.js} +1078 -10
  46. package/dist/{vendor-index.b0346fe4.js → vendor-index.bdee400f.js} +1 -0
  47. package/dist/worker.js +17 -16
  48. package/package.json +22 -12
  49. package/runners.d.ts +1 -0
  50. package/suite.d.ts +1 -0
  51. package/dist/chunk-integrations-coverage.44413252.js +0 -240
  52. package/dist/chunk-integrations-globals.0024ce21.js +0 -27
  53. package/dist/chunk-mock-date.c543fa3e.js +0 -349
  54. package/dist/chunk-runtime-chain.2da9e75c.js +0 -2595
  55. package/dist/chunk-runtime-error.de671af0.js +0 -144
  56. package/dist/chunk-runtime-setup.35da9209.js +0 -649
  57. package/dist/chunk-utils-env.f4a39d2c.js +0 -228
  58. package/dist/chunk-utils-source-map.5f5d12cf.js +0 -408
  59. package/dist/chunk-utils-timers.52534f96.js +0 -3573
  60. package/dist/index-50755efe.d.ts +0 -258
  61. package/dist/vendor-index.451e37bc.js +0 -1071
  62. package/dist/vendor-index.723a074f.js +0 -102
  63. package/dist/vendor-index.9c919048.js +0 -61
  64. package/dist/vendor-index.9f20a9be.js +0 -6291
@@ -1,102 +0,0 @@
1
- import * as tinyspy from 'tinyspy';
2
-
3
- const spies = /* @__PURE__ */ new Set();
4
- function isMockFunction(fn2) {
5
- return typeof fn2 === "function" && "_isMockFunction" in fn2 && fn2._isMockFunction;
6
- }
7
- function spyOn(obj, method, accessType) {
8
- const dictionary = {
9
- get: "getter",
10
- set: "setter"
11
- };
12
- const objMethod = accessType ? { [dictionary[accessType]]: method } : method;
13
- const stub = tinyspy.spyOn(obj, objMethod);
14
- return enhanceSpy(stub);
15
- }
16
- let callOrder = 0;
17
- function enhanceSpy(spy) {
18
- const stub = spy;
19
- let implementation;
20
- let instances = [];
21
- let invocations = [];
22
- const mockContext = {
23
- get calls() {
24
- return stub.calls;
25
- },
26
- get instances() {
27
- return instances;
28
- },
29
- get invocationCallOrder() {
30
- return invocations;
31
- },
32
- get results() {
33
- return stub.results.map(([callType, value]) => {
34
- const type = callType === "error" ? "throw" : "return";
35
- return { type, value };
36
- });
37
- },
38
- get lastCall() {
39
- return stub.calls[stub.calls.length - 1];
40
- }
41
- };
42
- let onceImplementations = [];
43
- let name = stub.name;
44
- stub.getMockName = () => name || "vi.fn()";
45
- stub.mockName = (n) => {
46
- name = n;
47
- return stub;
48
- };
49
- stub.mockClear = () => {
50
- stub.reset();
51
- instances = [];
52
- invocations = [];
53
- return stub;
54
- };
55
- stub.mockReset = () => {
56
- stub.mockClear();
57
- implementation = () => void 0;
58
- onceImplementations = [];
59
- return stub;
60
- };
61
- stub.mockRestore = () => {
62
- stub.mockReset();
63
- implementation = void 0;
64
- return stub;
65
- };
66
- stub.getMockImplementation = () => implementation;
67
- stub.mockImplementation = (fn2) => {
68
- implementation = fn2;
69
- return stub;
70
- };
71
- stub.mockImplementationOnce = (fn2) => {
72
- onceImplementations.push(fn2);
73
- return stub;
74
- };
75
- stub.mockReturnThis = () => stub.mockImplementation(function() {
76
- return this;
77
- });
78
- stub.mockReturnValue = (val) => stub.mockImplementation(() => val);
79
- stub.mockReturnValueOnce = (val) => stub.mockImplementationOnce(() => val);
80
- stub.mockResolvedValue = (val) => stub.mockImplementation(() => Promise.resolve(val));
81
- stub.mockResolvedValueOnce = (val) => stub.mockImplementationOnce(() => Promise.resolve(val));
82
- stub.mockRejectedValue = (val) => stub.mockImplementation(() => Promise.reject(val));
83
- stub.mockRejectedValueOnce = (val) => stub.mockImplementationOnce(() => Promise.reject(val));
84
- Object.defineProperty(stub, "mock", {
85
- get: () => mockContext
86
- });
87
- stub.willCall(function(...args) {
88
- instances.push(this);
89
- invocations.push(++callOrder);
90
- const impl = onceImplementations.shift() || implementation || stub.getOriginal() || (() => {
91
- });
92
- return impl.apply(this, args);
93
- });
94
- spies.add(stub);
95
- return stub;
96
- }
97
- function fn(implementation) {
98
- return enhanceSpy(tinyspy.spyOn({ fn: implementation || (() => {
99
- }) }, "fn"));
100
- }
101
-
102
- export { spies as a, fn as f, isMockFunction as i, spyOn as s };
@@ -1,61 +0,0 @@
1
- var onetime$1 = {exports: {}};
2
-
3
- var mimicFn$2 = {exports: {}};
4
-
5
- const mimicFn$1 = (to, from) => {
6
- for (const prop of Reflect.ownKeys(from)) {
7
- Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop));
8
- }
9
-
10
- return to;
11
- };
12
-
13
- mimicFn$2.exports = mimicFn$1;
14
- // TODO: Remove this for the next major release
15
- mimicFn$2.exports.default = mimicFn$1;
16
-
17
- const mimicFn = mimicFn$2.exports;
18
-
19
- const calledFunctions = new WeakMap();
20
-
21
- const onetime = (function_, options = {}) => {
22
- if (typeof function_ !== 'function') {
23
- throw new TypeError('Expected a function');
24
- }
25
-
26
- let returnValue;
27
- let callCount = 0;
28
- const functionName = function_.displayName || function_.name || '<anonymous>';
29
-
30
- const onetime = function (...arguments_) {
31
- calledFunctions.set(onetime, ++callCount);
32
-
33
- if (callCount === 1) {
34
- returnValue = function_.apply(this, arguments_);
35
- function_ = null;
36
- } else if (options.throw === true) {
37
- throw new Error(`Function \`${functionName}\` can only be called once`);
38
- }
39
-
40
- return returnValue;
41
- };
42
-
43
- mimicFn(onetime, function_);
44
- calledFunctions.set(onetime, callCount);
45
-
46
- return onetime;
47
- };
48
-
49
- onetime$1.exports = onetime;
50
- // TODO: Remove this for the next major release
51
- onetime$1.exports.default = onetime;
52
-
53
- onetime$1.exports.callCount = function_ => {
54
- if (!calledFunctions.has(function_)) {
55
- throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
56
- }
57
-
58
- return calledFunctions.get(function_);
59
- };
60
-
61
- export { onetime$1 as o };