vitest 0.17.1 → 0.19.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.
- package/LICENSE.md +6 -6
- package/dist/browser.d.ts +1850 -0
- package/dist/browser.mjs +20 -0
- package/dist/{chunk-api-setup.c728e251.mjs → chunk-api-setup.0cf2c96a.mjs} +37 -11
- package/dist/{chunk-constants.27550afb.mjs → chunk-constants.38b43a44.mjs} +3 -3
- package/dist/{chunk-env-node.aa51c4cc.mjs → chunk-defaults.408a0cfe.mjs} +457 -455
- package/dist/{chunk-install-pkg.6f5930c3.mjs → chunk-install-pkg.6c6dc0c2.mjs} +11 -10
- package/dist/chunk-integrations-globals.803277be.mjs +24 -0
- package/dist/chunk-node-git.9058b82a.mjs +1139 -0
- package/dist/chunk-runtime-chain.1e1aabb3.mjs +2025 -0
- package/dist/{vendor-entry.1ad8a08d.mjs → chunk-runtime-error.d82dd2cf.mjs} +167 -183
- package/dist/{chunk-runtime-chain.6d23d202.mjs → chunk-runtime-hooks.db398170.mjs} +33 -2012
- package/dist/{chunk-runtime-mocker.34b9d585.mjs → chunk-runtime-mocker.dfdfd57b.mjs} +70 -22
- package/dist/{chunk-runtime-rpc.d986adb9.mjs → chunk-runtime-rpc.45d8ee19.mjs} +1 -1
- package/dist/{chunk-utils-global.4828c2e2.mjs → chunk-utils-global.2aa95025.mjs} +14 -9
- package/dist/{chunk-utils-source-map.a9047343.mjs → chunk-utils-source-map.8b066ce2.mjs} +2 -2
- package/dist/{chunk-vite-node-externalize.0fc8ed68.mjs → chunk-vite-node-externalize.a2813ad7.mjs} +1202 -2178
- package/dist/chunk-vite-node-utils.ad73f2ab.mjs +1433 -0
- package/dist/cli.mjs +11 -13
- package/dist/config.cjs +4 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.mjs +4 -1
- package/dist/entry.mjs +54 -10
- package/dist/index.d.ts +126 -58
- package/dist/index.mjs +12 -9
- package/dist/node.d.ts +109 -58
- package/dist/node.mjs +12 -14
- package/dist/spy.mjs +102 -2
- package/dist/suite.mjs +13 -0
- package/dist/vendor-index.61438b77.mjs +335 -0
- package/dist/{vendor-index.a2a385d8.mjs → vendor-index.62ce5c33.mjs} +6 -338
- package/dist/{vendor-index.98e769c1.mjs → vendor-index.de788b6a.mjs} +7 -7
- package/dist/worker.mjs +6 -6
- package/package.json +20 -12
- package/dist/chunk-integrations-globals.3df36e26.mjs +0 -26
- package/dist/chunk-integrations-spy.674b628e.mjs +0 -102
- package/dist/chunk-vite-node-utils.0f776286.mjs +0 -9195
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import require$$0 from 'readline';
|
|
2
2
|
import require$$2 from 'events';
|
|
3
3
|
|
|
4
4
|
function _mergeNamespaces(n, m) {
|
|
@@ -508,7 +508,7 @@ function requirePrompt$1 () {
|
|
|
508
508
|
if (hasRequiredPrompt$1) return prompt$1;
|
|
509
509
|
hasRequiredPrompt$1 = 1;
|
|
510
510
|
|
|
511
|
-
const readline
|
|
511
|
+
const readline = require$$0;
|
|
512
512
|
|
|
513
513
|
const _require = requireUtil$1(),
|
|
514
514
|
action = _require.action;
|
|
@@ -536,11 +536,11 @@ function requirePrompt$1 () {
|
|
|
536
536
|
|
|
537
537
|
this.onRender = (opts.onRender || (() => void 0)).bind(this);
|
|
538
538
|
|
|
539
|
-
const rl = readline
|
|
539
|
+
const rl = readline.createInterface({
|
|
540
540
|
input: this.in,
|
|
541
541
|
escapeCodeTimeout: 50
|
|
542
542
|
});
|
|
543
|
-
readline
|
|
543
|
+
readline.emitKeypressEvents(this.in, rl);
|
|
544
544
|
if (this.in.isTTY) this.in.setRawMode(true);
|
|
545
545
|
const isSelect = ['SelectPrompt', 'MultiselectPrompt'].indexOf(this.constructor.name) > -1;
|
|
546
546
|
|
|
@@ -3673,7 +3673,7 @@ function requirePrompt () {
|
|
|
3673
3673
|
if (hasRequiredPrompt) return prompt;
|
|
3674
3674
|
hasRequiredPrompt = 1;
|
|
3675
3675
|
|
|
3676
|
-
const readline
|
|
3676
|
+
const readline = require$$0;
|
|
3677
3677
|
const { action } = requireUtil();
|
|
3678
3678
|
const EventEmitter = require$$2;
|
|
3679
3679
|
const { beep, cursor } = requireSrc();
|
|
@@ -3692,8 +3692,8 @@ function requirePrompt () {
|
|
|
3692
3692
|
this.in = opts.stdin || process.stdin;
|
|
3693
3693
|
this.out = opts.stdout || process.stdout;
|
|
3694
3694
|
this.onRender = (opts.onRender || (() => void 0)).bind(this);
|
|
3695
|
-
const rl = readline
|
|
3696
|
-
readline
|
|
3695
|
+
const rl = readline.createInterface({ input:this.in, escapeCodeTimeout:50 });
|
|
3696
|
+
readline.emitKeypressEvents(this.in, rl);
|
|
3697
3697
|
|
|
3698
3698
|
if (this.in.isTTY) this.in.setRawMode(true);
|
|
3699
3699
|
const isSelect = [ 'SelectPrompt', 'MultiselectPrompt' ].indexOf(this.constructor.name) > -1;
|
package/dist/worker.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.
|
|
1
|
+
import { C as resolve, g as getWorkerState } from './chunk-utils-global.2aa95025.mjs';
|
|
2
|
+
import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.ad73f2ab.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.38b43a44.mjs';
|
|
5
|
+
import { e as executeInViteNode } from './chunk-runtime-mocker.dfdfd57b.mjs';
|
|
6
|
+
import { r as rpc } from './chunk-runtime-rpc.45d8ee19.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.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,6 +35,10 @@
|
|
|
35
35
|
"types": "./dist/node.d.ts",
|
|
36
36
|
"import": "./dist/node.mjs"
|
|
37
37
|
},
|
|
38
|
+
"./browser": {
|
|
39
|
+
"types": "./dist/browser.d.ts",
|
|
40
|
+
"import": "./dist/browser.mjs"
|
|
41
|
+
},
|
|
38
42
|
"./config": {
|
|
39
43
|
"types": "./config.d.ts",
|
|
40
44
|
"require": "./dist/config.cjs",
|
|
@@ -58,6 +62,7 @@
|
|
|
58
62
|
},
|
|
59
63
|
"peerDependencies": {
|
|
60
64
|
"@edge-runtime/vm": "*",
|
|
65
|
+
"@vitest/browser": "*",
|
|
61
66
|
"@vitest/ui": "*",
|
|
62
67
|
"c8": "*",
|
|
63
68
|
"happy-dom": "*",
|
|
@@ -67,6 +72,9 @@
|
|
|
67
72
|
"@vitest/ui": {
|
|
68
73
|
"optional": true
|
|
69
74
|
},
|
|
75
|
+
"@vitest/browser": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
70
78
|
"c8": {
|
|
71
79
|
"optional": true
|
|
72
80
|
},
|
|
@@ -86,14 +94,14 @@
|
|
|
86
94
|
"@types/node": "*",
|
|
87
95
|
"chai": "^4.3.6",
|
|
88
96
|
"debug": "^4.3.4",
|
|
89
|
-
"local-pkg": "^0.4.
|
|
90
|
-
"tinypool": "^0.2.
|
|
91
|
-
"tinyspy": "^0.
|
|
97
|
+
"local-pkg": "^0.4.2",
|
|
98
|
+
"tinypool": "^0.2.4",
|
|
99
|
+
"tinyspy": "^1.0.0",
|
|
92
100
|
"vite": "^2.9.12 || ^3.0.0-0"
|
|
93
101
|
},
|
|
94
102
|
"devDependencies": {
|
|
95
103
|
"@antfu/install-pkg": "^0.1.0",
|
|
96
|
-
"@edge-runtime/vm": "1.1.0-beta.
|
|
104
|
+
"@edge-runtime/vm": "1.1.0-beta.11",
|
|
97
105
|
"@sinonjs/fake-timers": "^9.1.2",
|
|
98
106
|
"@types/diff": "^5.0.2",
|
|
99
107
|
"@types/jsdom": "^16.2.14",
|
|
@@ -101,7 +109,7 @@
|
|
|
101
109
|
"@types/natural-compare": "^1.4.1",
|
|
102
110
|
"@types/prompts": "^2.4.0",
|
|
103
111
|
"@types/sinonjs__fake-timers": "^8.1.2",
|
|
104
|
-
"@vitest/ui": "0.
|
|
112
|
+
"@vitest/ui": "0.19.0",
|
|
105
113
|
"birpc": "^0.2.3",
|
|
106
114
|
"c8": "^7.11.3",
|
|
107
115
|
"cac": "^6.7.12",
|
|
@@ -111,13 +119,13 @@
|
|
|
111
119
|
"execa": "^6.1.0",
|
|
112
120
|
"fast-glob": "^3.2.11",
|
|
113
121
|
"find-up": "^6.3.0",
|
|
114
|
-
"flatted": "^3.2.
|
|
115
|
-
"happy-dom": "^
|
|
122
|
+
"flatted": "^3.2.6",
|
|
123
|
+
"happy-dom": "^6.0.3",
|
|
116
124
|
"jsdom": "^19.0.0",
|
|
117
125
|
"log-update": "^5.0.1",
|
|
118
126
|
"magic-string": "^0.26.2",
|
|
119
127
|
"micromatch": "^4.0.5",
|
|
120
|
-
"mlly": "^0.5.
|
|
128
|
+
"mlly": "^0.5.4",
|
|
121
129
|
"natural-compare": "^1.4.0",
|
|
122
130
|
"p-limit": "^4.0.0",
|
|
123
131
|
"pathe": "^0.2.0",
|
|
@@ -125,12 +133,12 @@
|
|
|
125
133
|
"pkg-types": "^0.3.3",
|
|
126
134
|
"pretty-format": "^27.5.1",
|
|
127
135
|
"prompts": "^2.4.2",
|
|
128
|
-
"rollup": "^2.
|
|
136
|
+
"rollup": "^2.77.0",
|
|
129
137
|
"source-map-js": "^1.0.2",
|
|
130
138
|
"strip-ansi": "^7.0.1",
|
|
131
139
|
"typescript": "^4.7.4",
|
|
132
|
-
"vite-node": "0.
|
|
133
|
-
"ws": "^8.8.
|
|
140
|
+
"vite-node": "0.19.0",
|
|
141
|
+
"ws": "^8.8.1"
|
|
134
142
|
},
|
|
135
143
|
"scripts": {
|
|
136
144
|
"build": "rimraf dist && rollup -c",
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { g as globalApis } from './chunk-constants.27550afb.mjs';
|
|
2
|
-
import { i as index } from './vendor-entry.1ad8a08d.mjs';
|
|
3
|
-
import 'url';
|
|
4
|
-
import './chunk-utils-global.4828c2e2.mjs';
|
|
5
|
-
import 'tty';
|
|
6
|
-
import 'local-pkg';
|
|
7
|
-
import 'path';
|
|
8
|
-
import 'fs';
|
|
9
|
-
import './chunk-env-node.aa51c4cc.mjs';
|
|
10
|
-
import 'module';
|
|
11
|
-
import './chunk-runtime-chain.6d23d202.mjs';
|
|
12
|
-
import 'chai';
|
|
13
|
-
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
14
|
-
import './chunk-runtime-rpc.d986adb9.mjs';
|
|
15
|
-
import './chunk-utils-source-map.a9047343.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 };
|