vitest 0.18.0 → 0.18.1
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.
- package/LICENSE.md +1 -1
- package/dist/{chunk-api-setup.63babd7c.mjs → chunk-api-setup.9d3f7670.mjs} +18 -9
- package/dist/{chunk-constants.8eb2ed35.mjs → chunk-constants.d4406290.mjs} +1 -1
- package/dist/{chunk-env-node.26c72624.mjs → chunk-env-node.bbba78e5.mjs} +2 -1
- package/dist/chunk-integrations-globals.00b6e1ad.mjs +23 -0
- package/dist/{chunk-runtime-chain.eb764dff.mjs → chunk-runtime-chain.b60d57da.mjs} +31 -7
- package/dist/{chunk-runtime-mocker.79ccc3de.mjs → chunk-runtime-mocker.1d853e3a.mjs} +70 -22
- package/dist/{chunk-runtime-rpc.cc6a06a2.mjs → chunk-runtime-rpc.9d1f4c48.mjs} +1 -1
- package/dist/{chunk-utils-global.1b22c4fd.mjs → chunk-utils-global.0a7416cf.mjs} +1 -1
- package/dist/{chunk-utils-source-map.957e7756.mjs → chunk-utils-source-map.c03f8bc4.mjs} +1 -1
- package/dist/{chunk-vite-node-externalize.0791f2ed.mjs → chunk-vite-node-externalize.6956d2d9.mjs} +10 -9
- package/dist/chunk-vite-node-utils.8077cd3c.mjs +1422 -0
- package/dist/cli.mjs +7 -7
- package/dist/config.cjs +1 -0
- package/dist/config.mjs +1 -0
- package/dist/entry.mjs +638 -11
- package/dist/index.d.ts +17 -23
- package/dist/index.mjs +8 -8
- package/dist/node.d.ts +9 -16
- package/dist/node.mjs +8 -8
- package/dist/spy.mjs +102 -2
- package/dist/worker.mjs +6 -6
- package/package.json +12 -12
- package/dist/chunk-integrations-globals.61e4d6ae.mjs +0 -26
- package/dist/chunk-integrations-spy.674b628e.mjs +0 -102
- package/dist/chunk-vite-node-utils.af8ead96.mjs +0 -9195
- package/dist/vendor-entry.78de67ab.mjs +0 -660
package/dist/index.d.ts
CHANGED
|
@@ -207,26 +207,18 @@ interface CustomEventMap {
|
|
|
207
207
|
type InferCustomEventPayload<T extends string> =
|
|
208
208
|
T extends keyof CustomEventMap ? CustomEventMap[T] : any
|
|
209
209
|
|
|
210
|
-
type ModuleNamespace = Record<string, any> & {
|
|
211
|
-
[Symbol.toStringTag]: 'Module'
|
|
212
|
-
}
|
|
213
|
-
|
|
214
210
|
interface ViteHotContext {
|
|
215
211
|
readonly data: any
|
|
216
212
|
|
|
217
213
|
accept(): void
|
|
218
|
-
accept(cb: (mod:
|
|
219
|
-
accept(dep: string, cb: (mod:
|
|
220
|
-
accept(
|
|
221
|
-
deps: readonly string[],
|
|
222
|
-
cb: (mods: Array<ModuleNamespace | undefined>) => void
|
|
223
|
-
): void
|
|
214
|
+
accept(cb: (mod: any) => void): void
|
|
215
|
+
accept(dep: string, cb: (mod: any) => void): void
|
|
216
|
+
accept(deps: readonly string[], cb: (mods: any[]) => void): void
|
|
224
217
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
): void
|
|
218
|
+
/**
|
|
219
|
+
* @deprecated
|
|
220
|
+
*/
|
|
221
|
+
acceptDeps(): never
|
|
230
222
|
|
|
231
223
|
dispose(cb: (data: any) => void): void
|
|
232
224
|
decline(): void
|
|
@@ -919,22 +911,24 @@ interface EachFunction {
|
|
|
919
911
|
<T extends ReadonlyArray<any>>(cases: ReadonlyArray<T>): (name: string, fn: (...args: ExtractEachCallbackArgs<T>) => Awaitable<void>) => void;
|
|
920
912
|
<T>(cases: ReadonlyArray<T>): (name: string, fn: (...args: T[]) => Awaitable<void>) => void;
|
|
921
913
|
}
|
|
922
|
-
declare type
|
|
914
|
+
declare type ChainableTestAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'fails', [
|
|
923
915
|
name: string,
|
|
924
916
|
fn?: TestFunction<ExtraContext>,
|
|
925
917
|
timeout?: number
|
|
926
|
-
], void
|
|
918
|
+
], void>;
|
|
919
|
+
declare type TestAPI<ExtraContext = {}> = ChainableTestAPI<ExtraContext> & {
|
|
927
920
|
each: EachFunction;
|
|
928
|
-
skipIf(condition: any):
|
|
929
|
-
runIf(condition: any):
|
|
921
|
+
skipIf(condition: any): ChainableTestAPI<ExtraContext>;
|
|
922
|
+
runIf(condition: any): ChainableTestAPI<ExtraContext>;
|
|
930
923
|
};
|
|
931
|
-
declare type
|
|
924
|
+
declare type ChainableSuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'only' | 'skip' | 'todo' | 'shuffle', [
|
|
932
925
|
name: string,
|
|
933
926
|
factory?: SuiteFactory
|
|
934
|
-
], SuiteCollector<ExtraContext
|
|
927
|
+
], SuiteCollector<ExtraContext>>;
|
|
928
|
+
declare type SuiteAPI<ExtraContext = {}> = ChainableSuiteAPI & {
|
|
935
929
|
each: EachFunction;
|
|
936
|
-
skipIf(condition: any):
|
|
937
|
-
runIf(condition: any):
|
|
930
|
+
skipIf(condition: any): ChainableSuiteAPI<ExtraContext>;
|
|
931
|
+
runIf(condition: any): ChainableSuiteAPI<ExtraContext>;
|
|
938
932
|
};
|
|
939
933
|
declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return>;
|
|
940
934
|
declare type HookCleanupCallback = (() => Awaitable<unknown>) | void;
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { p as afterAll, u as afterEach, o as beforeAll, q as beforeEach, x as createExpect, k as describe, y as expect, A as getRunningMode, n as isFirstRun, B as isWatchMode, l as it, m as runOnce, j as suite, t as test, v as vi, z as vitest, w as withCallback } from './chunk-runtime-chain.b60d57da.mjs';
|
|
2
2
|
export { assert, default as chai, should } from 'chai';
|
|
3
|
-
import '
|
|
4
|
-
import './chunk-
|
|
5
|
-
import '
|
|
3
|
+
import 'util';
|
|
4
|
+
import './chunk-utils-global.0a7416cf.mjs';
|
|
5
|
+
import 'path';
|
|
6
6
|
import 'tty';
|
|
7
7
|
import 'local-pkg';
|
|
8
|
-
import '
|
|
8
|
+
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
9
|
+
import './chunk-runtime-rpc.9d1f4c48.mjs';
|
|
9
10
|
import 'fs';
|
|
10
|
-
import './chunk-utils-source-map.
|
|
11
|
-
import './
|
|
11
|
+
import './chunk-utils-source-map.c03f8bc4.mjs';
|
|
12
|
+
import './spy.mjs';
|
|
12
13
|
import 'tinyspy';
|
|
13
|
-
import 'util';
|
package/dist/node.d.ts
CHANGED
|
@@ -51,26 +51,18 @@ interface CustomEventMap {
|
|
|
51
51
|
type InferCustomEventPayload<T extends string> =
|
|
52
52
|
T extends keyof CustomEventMap ? CustomEventMap[T] : any
|
|
53
53
|
|
|
54
|
-
type ModuleNamespace = Record<string, any> & {
|
|
55
|
-
[Symbol.toStringTag]: 'Module'
|
|
56
|
-
}
|
|
57
|
-
|
|
58
54
|
interface ViteHotContext {
|
|
59
55
|
readonly data: any
|
|
60
56
|
|
|
61
57
|
accept(): void
|
|
62
|
-
accept(cb: (mod:
|
|
63
|
-
accept(dep: string, cb: (mod:
|
|
64
|
-
accept(
|
|
65
|
-
deps: readonly string[],
|
|
66
|
-
cb: (mods: Array<ModuleNamespace | undefined>) => void
|
|
67
|
-
): void
|
|
58
|
+
accept(cb: (mod: any) => void): void
|
|
59
|
+
accept(dep: string, cb: (mod: any) => void): void
|
|
60
|
+
accept(deps: readonly string[], cb: (mods: any[]) => void): void
|
|
68
61
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
): void
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated
|
|
64
|
+
*/
|
|
65
|
+
acceptDeps(): never
|
|
74
66
|
|
|
75
67
|
dispose(cb: (data: any) => void): void
|
|
76
68
|
decline(): void
|
|
@@ -1605,6 +1597,7 @@ declare function createVitest(options: UserConfig, viteOverrides?: UserConfig$1)
|
|
|
1605
1597
|
|
|
1606
1598
|
declare function VitestPlugin(options?: UserConfig, ctx?: Vitest): Promise<Plugin$1[]>;
|
|
1607
1599
|
|
|
1600
|
+
declare type Key = string | symbol;
|
|
1608
1601
|
interface ViteRunnerRequest {
|
|
1609
1602
|
(dep: string): any;
|
|
1610
1603
|
callstack: string[];
|
|
@@ -1630,7 +1623,7 @@ declare class VitestMocker {
|
|
|
1630
1623
|
normalizePath(path: string): string;
|
|
1631
1624
|
getFsPath(path: string, external: string | null): string;
|
|
1632
1625
|
resolveMockPath(mockPath: string, external: string | null): string | null;
|
|
1633
|
-
|
|
1626
|
+
mockObject(object: Record<string | symbol, any>): Record<Key, any>;
|
|
1634
1627
|
unmockPath(path: string): void;
|
|
1635
1628
|
mockPath(path: string, external: string | null, factory?: () => any): void;
|
|
1636
1629
|
importActual<T>(id: string, importer: string): Promise<T>;
|
package/dist/node.mjs
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.
|
|
2
|
-
export { V as VitestRunner } from './chunk-runtime-mocker.
|
|
3
|
-
import './chunk-env-node.
|
|
1
|
+
export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.6956d2d9.mjs';
|
|
2
|
+
export { V as VitestRunner } from './chunk-runtime-mocker.1d853e3a.mjs';
|
|
3
|
+
import './chunk-env-node.bbba78e5.mjs';
|
|
4
4
|
import 'local-pkg';
|
|
5
5
|
import 'fs';
|
|
6
6
|
import 'module';
|
|
7
7
|
import 'url';
|
|
8
|
-
import './chunk-utils-global.
|
|
9
|
-
import 'tty';
|
|
8
|
+
import './chunk-utils-global.0a7416cf.mjs';
|
|
10
9
|
import 'path';
|
|
10
|
+
import 'tty';
|
|
11
11
|
import 'vite';
|
|
12
12
|
import 'process';
|
|
13
|
-
import './chunk-constants.
|
|
13
|
+
import './chunk-constants.d4406290.mjs';
|
|
14
14
|
import 'os';
|
|
15
15
|
import 'util';
|
|
16
16
|
import 'stream';
|
|
17
17
|
import 'events';
|
|
18
18
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
19
|
-
import './chunk-vite-node-utils.
|
|
19
|
+
import './chunk-vite-node-utils.8077cd3c.mjs';
|
|
20
20
|
import 'vm';
|
|
21
21
|
import 'assert';
|
|
22
22
|
import 'debug';
|
|
23
23
|
import 'worker_threads';
|
|
24
24
|
import 'tinypool';
|
|
25
25
|
import 'perf_hooks';
|
|
26
|
-
import './chunk-utils-source-map.
|
|
26
|
+
import './chunk-utils-source-map.c03f8bc4.mjs';
|
|
27
27
|
import 'crypto';
|
|
28
28
|
import 'buffer';
|
|
29
29
|
import 'child_process';
|
package/dist/spy.mjs
CHANGED
|
@@ -1,2 +1,102 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 { fn, isMockFunction, spies, spyOn };
|
package/dist/worker.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { q as resolve, a as getWorkerState } from './chunk-utils-global.
|
|
2
|
-
import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.
|
|
1
|
+
import { q as resolve, a as getWorkerState } from './chunk-utils-global.0a7416cf.mjs';
|
|
2
|
+
import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.8077cd3c.mjs';
|
|
3
3
|
import { workerId } from 'tinypool';
|
|
4
|
-
import { d as distDir } from './chunk-constants.
|
|
5
|
-
import { e as executeInViteNode } from './chunk-runtime-mocker.
|
|
6
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
4
|
+
import { d as distDir } from './chunk-constants.d4406290.mjs';
|
|
5
|
+
import { e as executeInViteNode } from './chunk-runtime-mocker.1d853e3a.mjs';
|
|
6
|
+
import { r as rpc } from './chunk-runtime-rpc.9d1f4c48.mjs';
|
|
7
|
+
import 'path';
|
|
7
8
|
import 'tty';
|
|
8
9
|
import 'local-pkg';
|
|
9
|
-
import 'path';
|
|
10
10
|
import 'module';
|
|
11
11
|
import 'url';
|
|
12
12
|
import 'vm';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.1",
|
|
4
4
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -86,14 +86,14 @@
|
|
|
86
86
|
"@types/node": "*",
|
|
87
87
|
"chai": "^4.3.6",
|
|
88
88
|
"debug": "^4.3.4",
|
|
89
|
-
"local-pkg": "^0.4.
|
|
90
|
-
"tinypool": "^0.2.
|
|
91
|
-
"tinyspy": "^0.
|
|
89
|
+
"local-pkg": "^0.4.2",
|
|
90
|
+
"tinypool": "^0.2.4",
|
|
91
|
+
"tinyspy": "^1.0.0",
|
|
92
92
|
"vite": "^2.9.12 || ^3.0.0-0"
|
|
93
93
|
},
|
|
94
94
|
"devDependencies": {
|
|
95
95
|
"@antfu/install-pkg": "^0.1.0",
|
|
96
|
-
"@edge-runtime/vm": "1.1.0-beta.
|
|
96
|
+
"@edge-runtime/vm": "1.1.0-beta.11",
|
|
97
97
|
"@sinonjs/fake-timers": "^9.1.2",
|
|
98
98
|
"@types/diff": "^5.0.2",
|
|
99
99
|
"@types/jsdom": "^16.2.14",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"@types/natural-compare": "^1.4.1",
|
|
102
102
|
"@types/prompts": "^2.4.0",
|
|
103
103
|
"@types/sinonjs__fake-timers": "^8.1.2",
|
|
104
|
-
"@vitest/ui": "0.18.
|
|
104
|
+
"@vitest/ui": "0.18.1",
|
|
105
105
|
"birpc": "^0.2.3",
|
|
106
106
|
"c8": "^7.11.3",
|
|
107
107
|
"cac": "^6.7.12",
|
|
@@ -111,13 +111,13 @@
|
|
|
111
111
|
"execa": "^6.1.0",
|
|
112
112
|
"fast-glob": "^3.2.11",
|
|
113
113
|
"find-up": "^6.3.0",
|
|
114
|
-
"flatted": "^3.2.
|
|
115
|
-
"happy-dom": "^
|
|
114
|
+
"flatted": "^3.2.6",
|
|
115
|
+
"happy-dom": "^6.0.3",
|
|
116
116
|
"jsdom": "^19.0.0",
|
|
117
117
|
"log-update": "^5.0.1",
|
|
118
118
|
"magic-string": "^0.26.2",
|
|
119
119
|
"micromatch": "^4.0.5",
|
|
120
|
-
"mlly": "^0.5.
|
|
120
|
+
"mlly": "^0.5.4",
|
|
121
121
|
"natural-compare": "^1.4.0",
|
|
122
122
|
"p-limit": "^4.0.0",
|
|
123
123
|
"pathe": "^0.2.0",
|
|
@@ -125,12 +125,12 @@
|
|
|
125
125
|
"pkg-types": "^0.3.3",
|
|
126
126
|
"pretty-format": "^27.5.1",
|
|
127
127
|
"prompts": "^2.4.2",
|
|
128
|
-
"rollup": "^2.
|
|
128
|
+
"rollup": "^2.77.0",
|
|
129
129
|
"source-map-js": "^1.0.2",
|
|
130
130
|
"strip-ansi": "^7.0.1",
|
|
131
131
|
"typescript": "^4.7.4",
|
|
132
|
-
"vite-node": "0.18.
|
|
133
|
-
"ws": "^8.8.
|
|
132
|
+
"vite-node": "0.18.1",
|
|
133
|
+
"ws": "^8.8.1"
|
|
134
134
|
},
|
|
135
135
|
"scripts": {
|
|
136
136
|
"build": "rimraf dist && rollup -c",
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { g as globalApis } from './chunk-constants.8eb2ed35.mjs';
|
|
2
|
-
import { i as index } from './vendor-entry.78de67ab.mjs';
|
|
3
|
-
import 'url';
|
|
4
|
-
import './chunk-utils-global.1b22c4fd.mjs';
|
|
5
|
-
import 'tty';
|
|
6
|
-
import 'local-pkg';
|
|
7
|
-
import 'path';
|
|
8
|
-
import 'fs';
|
|
9
|
-
import './chunk-env-node.26c72624.mjs';
|
|
10
|
-
import 'module';
|
|
11
|
-
import './chunk-runtime-chain.eb764dff.mjs';
|
|
12
|
-
import 'chai';
|
|
13
|
-
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
14
|
-
import './chunk-runtime-rpc.cc6a06a2.mjs';
|
|
15
|
-
import './chunk-utils-source-map.957e7756.mjs';
|
|
16
|
-
import './chunk-integrations-spy.674b628e.mjs';
|
|
17
|
-
import 'tinyspy';
|
|
18
|
-
import 'util';
|
|
19
|
-
|
|
20
|
-
function registerApiGlobally() {
|
|
21
|
-
globalApis.forEach((api) => {
|
|
22
|
-
globalThis[api] = index[api];
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { registerApiGlobally };
|
|
@@ -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 };
|