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,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 };