vitest 0.0.62 → 0.0.66
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 +2 -1
- package/README.gh.md +11 -15
- package/dist/chunk-5TNYWP3O.js +81 -0
- package/dist/chunk-ANPMHBIF.js +253 -0
- package/dist/chunk-APGELTDH.js +19 -0
- package/dist/chunk-R2SMNEBL.js +95 -0
- package/dist/chunk-VLGIKNLC.js +78 -0
- package/dist/chunk-XUIDSY4V.js +35 -0
- package/dist/chunk-YPKHVZRP.js +86 -0
- package/dist/global-PRFYLY7P.js +22 -0
- package/dist/index.d.ts +33 -10
- package/dist/index.js +46 -1
- package/dist/node/cli.d.ts +0 -12
- package/dist/node/cli.js +2609 -19
- package/dist/{types-c0d293d3.d.ts → options-63a726fa.d.ts} +133 -148
- package/dist/runtime/entry.d.ts +1 -3
- package/dist/runtime/entry.js +2535 -9
- package/dist/{node → runtime}/worker.d.ts +4 -5
- package/dist/runtime/worker.js +263 -0
- package/package.json +40 -27
- package/dist/chunk-4HLM7BTV.js +0 -1
- package/dist/chunk-JKSYS65D.js +0 -1
- package/dist/chunk-LNO4ZIPT.js +0 -1
- package/dist/chunk-NTRHKVSE.js +0 -1
- package/dist/global-GT6TCEAH.js +0 -1
- package/dist/node/worker.js +0 -4
package/LICENSE
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2021 Anthony Fu <https://github.com/antfu>
|
|
3
|
+
Copyright (c) 2021-Present Anthony Fu <https://github.com/antfu>
|
|
4
|
+
Copyright (c) 2021-Present Matias Capeletto <https://github.com/patak-dev>
|
|
4
5
|
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.gh.md
CHANGED
|
@@ -29,7 +29,7 @@ A blazing fast unit test framework powered by Vite.
|
|
|
29
29
|
- [Smart & instant watch mode](#watch-mode), like HMR for tests!
|
|
30
30
|
- [Native code coverage](#coverage) via [c8](https://github.com/bcoe/c8)
|
|
31
31
|
- [Sinon](https://sinonjs.org/) built-in for mocking, stubbing, and spies.
|
|
32
|
-
- [JSDOM](https://github.com/jsdom/jsdom) and [happy-dom](https://github.com/capricorn86/happy-dom)
|
|
32
|
+
- [JSDOM](https://github.com/jsdom/jsdom) and [happy-dom](https://github.com/capricorn86/happy-dom) for DOM and browser API mocking
|
|
33
33
|
- Components testing ([Vue](./test/vue), [React](./test/react), [Lit](./test/lit), [Vitesse](./test/vitesse))
|
|
34
34
|
- Workers multi-threading via [Piscina](https://github.com/piscinajs/piscina)
|
|
35
35
|
- ESM first, top level await
|
|
@@ -80,8 +80,8 @@ $ npx vitest
|
|
|
80
80
|
|
|
81
81
|
- Create `vitest.config.ts`, which will have the higher priority
|
|
82
82
|
- Pass `--config` option to CLI, e.g. `vitest --config ./path/to/vitest.config.ts`
|
|
83
|
-
- Use `process.env.VITEST` to conditionally apply
|
|
84
|
-
|
|
83
|
+
- Use `process.env.VITEST` to conditionally apply different configuration in `vite.config.ts`
|
|
84
|
+
|
|
85
85
|
To configure `vitest` itself, add `test` property in your Vite config
|
|
86
86
|
|
|
87
87
|
```ts
|
|
@@ -142,20 +142,15 @@ export default defineConfig({
|
|
|
142
142
|
|
|
143
143
|
## Browser Mocking
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
```ts
|
|
148
|
-
// vite.config.ts
|
|
149
|
-
import { defineConfig } from 'vite'
|
|
145
|
+
Vitest supports both [happy-dom](https://github.com/capricorn86/happy-dom) or [jsdom](https://github.com/jsdom/jsdom) for mocking DOM and browser APIs. They don't come with Vitest, you might need to install them:
|
|
150
146
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
})
|
|
147
|
+
```bash
|
|
148
|
+
$ npm i -D happy-dom
|
|
149
|
+
# or
|
|
150
|
+
$ npm i -D jsdom
|
|
156
151
|
```
|
|
157
152
|
|
|
158
|
-
|
|
153
|
+
After that, change the `environment` option in your config file:
|
|
159
154
|
|
|
160
155
|
```ts
|
|
161
156
|
// vite.config.ts
|
|
@@ -163,7 +158,7 @@ import { defineConfig } from 'vite'
|
|
|
163
158
|
|
|
164
159
|
export default defineConfig({
|
|
165
160
|
test: {
|
|
166
|
-
|
|
161
|
+
environment: 'happy-dom' // or 'jsdom', 'node'
|
|
167
162
|
}
|
|
168
163
|
})
|
|
169
164
|
```
|
|
@@ -181,6 +176,7 @@ Vitest smartly searches the module graph and only rerun the related tests (just
|
|
|
181
176
|
Vitest works perfectly with [c8](https://github.com/bcoe/c8)
|
|
182
177
|
|
|
183
178
|
```bash
|
|
179
|
+
$ npm i -D c8
|
|
184
180
|
$ c8 vitest
|
|
185
181
|
```
|
|
186
182
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_esm_shims
|
|
3
|
+
} from "./chunk-R2SMNEBL.js";
|
|
4
|
+
|
|
5
|
+
// src/utils.ts
|
|
6
|
+
init_esm_shims();
|
|
7
|
+
function toArray(array) {
|
|
8
|
+
array = array || [];
|
|
9
|
+
if (Array.isArray(array))
|
|
10
|
+
return array;
|
|
11
|
+
return [array];
|
|
12
|
+
}
|
|
13
|
+
function notNullish(v) {
|
|
14
|
+
return v != null;
|
|
15
|
+
}
|
|
16
|
+
function slash(str) {
|
|
17
|
+
return str.replace(/\\/g, "/");
|
|
18
|
+
}
|
|
19
|
+
function partitionSuiteChildren(suite) {
|
|
20
|
+
let tasksGroup = [];
|
|
21
|
+
const tasksGroups = [];
|
|
22
|
+
for (const c of suite.tasks) {
|
|
23
|
+
if (tasksGroup.length === 0 || c.computeMode === tasksGroup[0].computeMode) {
|
|
24
|
+
tasksGroup.push(c);
|
|
25
|
+
} else {
|
|
26
|
+
tasksGroups.push(tasksGroup);
|
|
27
|
+
tasksGroup = [c];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (tasksGroup.length > 0)
|
|
31
|
+
tasksGroups.push(tasksGroup);
|
|
32
|
+
return tasksGroups;
|
|
33
|
+
}
|
|
34
|
+
function interpretOnlyMode(items) {
|
|
35
|
+
if (items.some((i) => i.mode === "only")) {
|
|
36
|
+
items.forEach((i) => {
|
|
37
|
+
if (i.mode === "run")
|
|
38
|
+
i.mode = "skip";
|
|
39
|
+
else if (i.mode === "only")
|
|
40
|
+
i.mode = "run";
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function getTests(suite) {
|
|
45
|
+
return toArray(suite).flatMap((s) => s.tasks.flatMap((c) => c.type === "test" ? [c] : getTests(c)));
|
|
46
|
+
}
|
|
47
|
+
function getSuites(suite) {
|
|
48
|
+
return toArray(suite).flatMap((s) => s.type === "suite" ? [s, ...getSuites(s.tasks)] : []);
|
|
49
|
+
}
|
|
50
|
+
function hasTests(suite) {
|
|
51
|
+
return toArray(suite).some((s) => s.tasks.some((c) => c.type === "test" || hasTests(c)));
|
|
52
|
+
}
|
|
53
|
+
function hasFailed(suite) {
|
|
54
|
+
return toArray(suite).some((s) => {
|
|
55
|
+
var _a;
|
|
56
|
+
return ((_a = s.result) == null ? void 0 : _a.state) === "fail" || s.type === "suite" && hasFailed(s.tasks);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function getNames(task) {
|
|
60
|
+
const names = [task.name];
|
|
61
|
+
let current = task;
|
|
62
|
+
while ((current == null ? void 0 : current.suite) || (current == null ? void 0 : current.file)) {
|
|
63
|
+
current = current.suite || current.file;
|
|
64
|
+
if (current == null ? void 0 : current.name)
|
|
65
|
+
names.unshift(current.name);
|
|
66
|
+
}
|
|
67
|
+
return names;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
toArray,
|
|
72
|
+
notNullish,
|
|
73
|
+
slash,
|
|
74
|
+
partitionSuiteChildren,
|
|
75
|
+
interpretOnlyMode,
|
|
76
|
+
getTests,
|
|
77
|
+
getSuites,
|
|
78
|
+
hasTests,
|
|
79
|
+
hasFailed,
|
|
80
|
+
getNames
|
|
81
|
+
};
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import {
|
|
2
|
+
nanoid
|
|
3
|
+
} from "./chunk-APGELTDH.js";
|
|
4
|
+
import {
|
|
5
|
+
init_esm_shims
|
|
6
|
+
} from "./chunk-R2SMNEBL.js";
|
|
7
|
+
|
|
8
|
+
// src/runtime/suite.ts
|
|
9
|
+
init_esm_shims();
|
|
10
|
+
|
|
11
|
+
// src/runtime/context.ts
|
|
12
|
+
init_esm_shims();
|
|
13
|
+
var context = {
|
|
14
|
+
tasks: [],
|
|
15
|
+
currentSuite: null
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/runtime/map.ts
|
|
19
|
+
init_esm_shims();
|
|
20
|
+
var fnMap = new WeakMap();
|
|
21
|
+
var hooksMap = new WeakMap();
|
|
22
|
+
function setFn(key, fn) {
|
|
23
|
+
fnMap.set(key, fn);
|
|
24
|
+
}
|
|
25
|
+
function getFn(key) {
|
|
26
|
+
return fnMap.get(key);
|
|
27
|
+
}
|
|
28
|
+
function setHooks(key, hooks) {
|
|
29
|
+
hooksMap.set(key, hooks);
|
|
30
|
+
}
|
|
31
|
+
function getHooks(key) {
|
|
32
|
+
return hooksMap.get(key);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/runtime/suite.ts
|
|
36
|
+
var suite = createSuite();
|
|
37
|
+
var defaultSuite = suite("");
|
|
38
|
+
function getCurrentSuite() {
|
|
39
|
+
return context.currentSuite || defaultSuite;
|
|
40
|
+
}
|
|
41
|
+
var getDefaultTestTimeout = () => {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
return ((_b = (_a = process.__vitest_worker__) == null ? void 0 : _a.config) == null ? void 0 : _b.testTimeout) ?? 5e3;
|
|
44
|
+
};
|
|
45
|
+
var getDefaultHookTimeout = () => {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
return ((_b = (_a = process.__vitest_worker__) == null ? void 0 : _a.config) == null ? void 0 : _b.hookTimeout) ?? 5e3;
|
|
48
|
+
};
|
|
49
|
+
function createSuiteHooks() {
|
|
50
|
+
return {
|
|
51
|
+
beforeAll: [],
|
|
52
|
+
afterAll: [],
|
|
53
|
+
beforeEach: [],
|
|
54
|
+
afterEach: []
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function createSuiteCollector(name, factory = () => {
|
|
58
|
+
}, mode, suiteComputeMode) {
|
|
59
|
+
var _a;
|
|
60
|
+
const tasks = [];
|
|
61
|
+
const factoryQueue = [];
|
|
62
|
+
let suite2;
|
|
63
|
+
initSuite();
|
|
64
|
+
const test2 = createTestCollector((name2, fn, mode2, computeMode) => {
|
|
65
|
+
const test3 = {
|
|
66
|
+
id: nanoid(),
|
|
67
|
+
type: "test",
|
|
68
|
+
name: name2,
|
|
69
|
+
mode: mode2,
|
|
70
|
+
computeMode: computeMode ?? (suiteComputeMode ?? "serial"),
|
|
71
|
+
suite: void 0
|
|
72
|
+
};
|
|
73
|
+
setFn(test3, fn);
|
|
74
|
+
tasks.push(test3);
|
|
75
|
+
});
|
|
76
|
+
const collector = {
|
|
77
|
+
type: "collector",
|
|
78
|
+
name,
|
|
79
|
+
mode,
|
|
80
|
+
test: test2,
|
|
81
|
+
tasks,
|
|
82
|
+
collect,
|
|
83
|
+
clear,
|
|
84
|
+
on: addHook
|
|
85
|
+
};
|
|
86
|
+
function addHook(name2, ...fn) {
|
|
87
|
+
getHooks(suite2)[name2].push(...fn);
|
|
88
|
+
}
|
|
89
|
+
function initSuite() {
|
|
90
|
+
suite2 = {
|
|
91
|
+
id: nanoid(),
|
|
92
|
+
type: "suite",
|
|
93
|
+
computeMode: "serial",
|
|
94
|
+
name,
|
|
95
|
+
mode,
|
|
96
|
+
tasks: []
|
|
97
|
+
};
|
|
98
|
+
setHooks(suite2, createSuiteHooks());
|
|
99
|
+
}
|
|
100
|
+
function clear() {
|
|
101
|
+
tasks.length = 0;
|
|
102
|
+
factoryQueue.length = 0;
|
|
103
|
+
initSuite();
|
|
104
|
+
}
|
|
105
|
+
async function collect(file) {
|
|
106
|
+
factoryQueue.length = 0;
|
|
107
|
+
if (factory) {
|
|
108
|
+
const prev = context.currentSuite;
|
|
109
|
+
context.currentSuite = collector;
|
|
110
|
+
await factory(test2);
|
|
111
|
+
context.currentSuite = prev;
|
|
112
|
+
}
|
|
113
|
+
const allChildren = await Promise.all([...factoryQueue, ...tasks].map((i) => i.type === "collector" ? i.collect(file) : i));
|
|
114
|
+
suite2.file = file;
|
|
115
|
+
suite2.tasks = allChildren;
|
|
116
|
+
allChildren.forEach((task) => {
|
|
117
|
+
task.suite = suite2;
|
|
118
|
+
if (file)
|
|
119
|
+
task.file = file;
|
|
120
|
+
});
|
|
121
|
+
return suite2;
|
|
122
|
+
}
|
|
123
|
+
(_a = context.currentSuite) == null ? void 0 : _a.tasks.push(collector);
|
|
124
|
+
return collector;
|
|
125
|
+
}
|
|
126
|
+
function createTestCollector(collectTest) {
|
|
127
|
+
function test2(name, fn, timeout) {
|
|
128
|
+
collectTest(name, withTimeout(fn, timeout), "run");
|
|
129
|
+
}
|
|
130
|
+
test2.concurrent = concurrent;
|
|
131
|
+
test2.skip = skip;
|
|
132
|
+
test2.only = only;
|
|
133
|
+
test2.todo = todo;
|
|
134
|
+
function concurrent(name, fn, timeout) {
|
|
135
|
+
collectTest(name, withTimeout(fn, timeout), "run", "concurrent");
|
|
136
|
+
}
|
|
137
|
+
concurrent.skip = (name, fn, timeout) => collectTest(name, withTimeout(fn, timeout), "skip", "concurrent");
|
|
138
|
+
concurrent.only = (name, fn, timeout) => collectTest(name, withTimeout(fn, timeout), "only", "concurrent");
|
|
139
|
+
concurrent.todo = todo;
|
|
140
|
+
function skip(name, fn, timeout) {
|
|
141
|
+
collectTest(name, withTimeout(fn, timeout), "skip");
|
|
142
|
+
}
|
|
143
|
+
skip.concurrent = concurrent.skip;
|
|
144
|
+
function only(name, fn, timeout) {
|
|
145
|
+
collectTest(name, withTimeout(fn, timeout), "only");
|
|
146
|
+
}
|
|
147
|
+
only.concurrent = concurrent.only;
|
|
148
|
+
function todo(name) {
|
|
149
|
+
collectTest(name, () => {
|
|
150
|
+
}, "todo");
|
|
151
|
+
}
|
|
152
|
+
todo.concurrent = todo;
|
|
153
|
+
return test2;
|
|
154
|
+
}
|
|
155
|
+
var test = function() {
|
|
156
|
+
function test2(name, fn, timeout) {
|
|
157
|
+
return getCurrentSuite().test(name, fn, timeout);
|
|
158
|
+
}
|
|
159
|
+
function concurrent(name, fn, timeout) {
|
|
160
|
+
return getCurrentSuite().test.concurrent(name, fn, timeout);
|
|
161
|
+
}
|
|
162
|
+
concurrent.skip = (name, fn, timeout) => getCurrentSuite().test.concurrent.skip(name, fn, timeout);
|
|
163
|
+
concurrent.only = (name, fn, timeout) => getCurrentSuite().test.concurrent.only(name, fn, timeout);
|
|
164
|
+
concurrent.todo = (name) => getCurrentSuite().test.concurrent.todo(name);
|
|
165
|
+
function skip(name, fn, timeout) {
|
|
166
|
+
return getCurrentSuite().test.skip(name, fn, timeout);
|
|
167
|
+
}
|
|
168
|
+
skip.concurrent = (name, fn, timeout) => getCurrentSuite().test.skip.concurrent(name, fn, timeout);
|
|
169
|
+
function only(name, fn, timeout) {
|
|
170
|
+
return getCurrentSuite().test.only(name, fn, timeout);
|
|
171
|
+
}
|
|
172
|
+
only.concurrent = (name, fn, timeout) => getCurrentSuite().test.only.concurrent(name, fn, timeout);
|
|
173
|
+
function todo(name) {
|
|
174
|
+
return getCurrentSuite().test.todo(name);
|
|
175
|
+
}
|
|
176
|
+
todo.concurrent = (name) => getCurrentSuite().test.todo.concurrent(name);
|
|
177
|
+
test2.concurrent = concurrent;
|
|
178
|
+
test2.skip = skip;
|
|
179
|
+
test2.only = only;
|
|
180
|
+
test2.todo = todo;
|
|
181
|
+
return test2;
|
|
182
|
+
}();
|
|
183
|
+
function createSuite() {
|
|
184
|
+
function suite2(suiteName, factory) {
|
|
185
|
+
return createSuiteCollector(suiteName, factory, "run");
|
|
186
|
+
}
|
|
187
|
+
function concurrent(suiteName, factory) {
|
|
188
|
+
return createSuiteCollector(suiteName, factory, "run", "concurrent");
|
|
189
|
+
}
|
|
190
|
+
concurrent.skip = (suiteName, factory) => createSuiteCollector(suiteName, factory, "skip", "concurrent");
|
|
191
|
+
concurrent.only = (suiteName, factory) => createSuiteCollector(suiteName, factory, "only", "concurrent");
|
|
192
|
+
concurrent.todo = (suiteName) => createSuiteCollector(suiteName, void 0, "todo");
|
|
193
|
+
function skip(suiteName, factory) {
|
|
194
|
+
return createSuiteCollector(suiteName, factory, "skip");
|
|
195
|
+
}
|
|
196
|
+
skip.concurrent = concurrent.skip;
|
|
197
|
+
function only(suiteName, factory) {
|
|
198
|
+
return createSuiteCollector(suiteName, factory, "only");
|
|
199
|
+
}
|
|
200
|
+
only.concurrent = concurrent.only;
|
|
201
|
+
function todo(suiteName) {
|
|
202
|
+
return createSuiteCollector(suiteName, void 0, "todo");
|
|
203
|
+
}
|
|
204
|
+
todo.concurrent = concurrent.todo;
|
|
205
|
+
suite2.concurrent = concurrent;
|
|
206
|
+
suite2.skip = skip;
|
|
207
|
+
suite2.only = only;
|
|
208
|
+
suite2.todo = todo;
|
|
209
|
+
return suite2;
|
|
210
|
+
}
|
|
211
|
+
var describe = suite;
|
|
212
|
+
var it = test;
|
|
213
|
+
var beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
214
|
+
var afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
215
|
+
var beforeEach = (fn, timeout) => getCurrentSuite().on("beforeEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
216
|
+
var afterEach = (fn, timeout) => getCurrentSuite().on("afterEach", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
|
|
217
|
+
function clearContext() {
|
|
218
|
+
context.tasks.length = 0;
|
|
219
|
+
defaultSuite.clear();
|
|
220
|
+
context.currentSuite = defaultSuite;
|
|
221
|
+
}
|
|
222
|
+
function withTimeout(fn, _timeout) {
|
|
223
|
+
const timeout = _timeout ?? getDefaultTestTimeout();
|
|
224
|
+
if (timeout <= 0 || timeout === Infinity)
|
|
225
|
+
return fn;
|
|
226
|
+
return (...args) => {
|
|
227
|
+
return Promise.race([fn(...args), new Promise((resolve, reject) => {
|
|
228
|
+
const timer = setTimeout(() => {
|
|
229
|
+
clearTimeout(timer);
|
|
230
|
+
reject(new Error(`Test timed out in ${timeout}ms.`));
|
|
231
|
+
}, timeout);
|
|
232
|
+
timer.unref();
|
|
233
|
+
})]);
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export {
|
|
238
|
+
context,
|
|
239
|
+
getFn,
|
|
240
|
+
setHooks,
|
|
241
|
+
getHooks,
|
|
242
|
+
suite,
|
|
243
|
+
defaultSuite,
|
|
244
|
+
createSuiteHooks,
|
|
245
|
+
test,
|
|
246
|
+
describe,
|
|
247
|
+
it,
|
|
248
|
+
beforeAll,
|
|
249
|
+
afterAll,
|
|
250
|
+
beforeEach,
|
|
251
|
+
afterEach,
|
|
252
|
+
clearContext
|
|
253
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_esm_shims
|
|
3
|
+
} from "./chunk-R2SMNEBL.js";
|
|
4
|
+
|
|
5
|
+
// node_modules/.pnpm/nanoid@3.1.30/node_modules/nanoid/non-secure/index.js
|
|
6
|
+
init_esm_shims();
|
|
7
|
+
var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
8
|
+
var nanoid = (size = 21) => {
|
|
9
|
+
let id = "";
|
|
10
|
+
let i = size;
|
|
11
|
+
while (i--) {
|
|
12
|
+
id += urlAlphabet[Math.random() * 64 | 0];
|
|
13
|
+
}
|
|
14
|
+
return id;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
nanoid
|
|
19
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
|
+
var __esm = (fn, res) => function __init() {
|
|
26
|
+
return fn && (res = (0, fn[Object.keys(fn)[0]])(fn = 0)), res;
|
|
27
|
+
};
|
|
28
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
29
|
+
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
30
|
+
};
|
|
31
|
+
var __export = (target, all) => {
|
|
32
|
+
__markAsModule(target);
|
|
33
|
+
for (var name in all)
|
|
34
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
35
|
+
};
|
|
36
|
+
var __reExport = (target, module, desc) => {
|
|
37
|
+
if (module && typeof module === "object" || typeof module === "function") {
|
|
38
|
+
for (let key of __getOwnPropNames(module))
|
|
39
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
40
|
+
__defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
|
|
41
|
+
}
|
|
42
|
+
return target;
|
|
43
|
+
};
|
|
44
|
+
var __toModule = (module) => {
|
|
45
|
+
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
|
|
46
|
+
};
|
|
47
|
+
var __accessCheck = (obj, member, msg) => {
|
|
48
|
+
if (!member.has(obj))
|
|
49
|
+
throw TypeError("Cannot " + msg);
|
|
50
|
+
};
|
|
51
|
+
var __privateGet = (obj, member, getter) => {
|
|
52
|
+
__accessCheck(obj, member, "read from private field");
|
|
53
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
54
|
+
};
|
|
55
|
+
var __privateAdd = (obj, member, value) => {
|
|
56
|
+
if (member.has(obj))
|
|
57
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
58
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
59
|
+
};
|
|
60
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
61
|
+
__accessCheck(obj, member, "write to private field");
|
|
62
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
63
|
+
return value;
|
|
64
|
+
};
|
|
65
|
+
var __privateWrapper = (obj, member, setter, getter) => {
|
|
66
|
+
return {
|
|
67
|
+
set _(value) {
|
|
68
|
+
__privateSet(obj, member, value, setter);
|
|
69
|
+
},
|
|
70
|
+
get _() {
|
|
71
|
+
return __privateGet(obj, member, getter);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// node_modules/.pnpm/tsup@5.11.1_typescript@4.5.3/node_modules/tsup/assets/esm_shims.js
|
|
77
|
+
import { fileURLToPath } from "url";
|
|
78
|
+
import path from "path";
|
|
79
|
+
var init_esm_shims = __esm({
|
|
80
|
+
"node_modules/.pnpm/tsup@5.11.1_typescript@4.5.3/node_modules/tsup/assets/esm_shims.js"() {
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
export {
|
|
85
|
+
__spreadValues,
|
|
86
|
+
__spreadProps,
|
|
87
|
+
__commonJS,
|
|
88
|
+
__export,
|
|
89
|
+
__toModule,
|
|
90
|
+
__privateGet,
|
|
91
|
+
__privateAdd,
|
|
92
|
+
__privateSet,
|
|
93
|
+
__privateWrapper,
|
|
94
|
+
init_esm_shims
|
|
95
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_esm_shims
|
|
3
|
+
} from "./chunk-R2SMNEBL.js";
|
|
4
|
+
|
|
5
|
+
// src/integrations/snapshot/port/jest-test-result-helper.ts
|
|
6
|
+
init_esm_shims();
|
|
7
|
+
var emptySummary = (options) => {
|
|
8
|
+
const summary = {
|
|
9
|
+
added: 0,
|
|
10
|
+
failure: false,
|
|
11
|
+
filesAdded: 0,
|
|
12
|
+
filesRemoved: 0,
|
|
13
|
+
filesRemovedList: [],
|
|
14
|
+
filesUnmatched: 0,
|
|
15
|
+
filesUpdated: 0,
|
|
16
|
+
matched: 0,
|
|
17
|
+
total: 0,
|
|
18
|
+
unchecked: 0,
|
|
19
|
+
uncheckedKeysByFile: [],
|
|
20
|
+
unmatched: 0,
|
|
21
|
+
updated: 0,
|
|
22
|
+
didUpdate: options.updateSnapshot === "all"
|
|
23
|
+
};
|
|
24
|
+
return summary;
|
|
25
|
+
};
|
|
26
|
+
var packSnapshotState = (filepath, state) => {
|
|
27
|
+
const snapshot = {
|
|
28
|
+
filepath,
|
|
29
|
+
added: 0,
|
|
30
|
+
fileDeleted: false,
|
|
31
|
+
matched: 0,
|
|
32
|
+
unchecked: 0,
|
|
33
|
+
uncheckedKeys: [],
|
|
34
|
+
unmatched: 0,
|
|
35
|
+
updated: 0
|
|
36
|
+
};
|
|
37
|
+
const uncheckedCount = state.getUncheckedCount();
|
|
38
|
+
const uncheckedKeys = state.getUncheckedKeys();
|
|
39
|
+
if (uncheckedCount)
|
|
40
|
+
state.removeUncheckedKeys();
|
|
41
|
+
const status = state.save();
|
|
42
|
+
snapshot.fileDeleted = status.deleted;
|
|
43
|
+
snapshot.added = state.added;
|
|
44
|
+
snapshot.matched = state.matched;
|
|
45
|
+
snapshot.unmatched = state.unmatched;
|
|
46
|
+
snapshot.updated = state.updated;
|
|
47
|
+
snapshot.unchecked = !status.deleted ? uncheckedCount : 0;
|
|
48
|
+
snapshot.uncheckedKeys = Array.from(uncheckedKeys);
|
|
49
|
+
return snapshot;
|
|
50
|
+
};
|
|
51
|
+
var addSnapshotResult = (summary, result) => {
|
|
52
|
+
if (result.added)
|
|
53
|
+
summary.filesAdded++;
|
|
54
|
+
if (result.fileDeleted)
|
|
55
|
+
summary.filesRemoved++;
|
|
56
|
+
if (result.unmatched)
|
|
57
|
+
summary.filesUnmatched++;
|
|
58
|
+
if (result.updated)
|
|
59
|
+
summary.filesUpdated++;
|
|
60
|
+
summary.added += result.added;
|
|
61
|
+
summary.matched += result.matched;
|
|
62
|
+
summary.unchecked += result.unchecked;
|
|
63
|
+
if (result.uncheckedKeys && result.uncheckedKeys.length > 0) {
|
|
64
|
+
summary.uncheckedKeysByFile.push({
|
|
65
|
+
filePath: result.filepath,
|
|
66
|
+
keys: result.uncheckedKeys
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
summary.unmatched += result.unmatched;
|
|
70
|
+
summary.updated += result.updated;
|
|
71
|
+
summary.total += result.added + result.matched + result.unmatched + result.updated;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
emptySummary,
|
|
76
|
+
packSnapshotState,
|
|
77
|
+
addSnapshotResult
|
|
78
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_esm_shims
|
|
3
|
+
} from "./chunk-R2SMNEBL.js";
|
|
4
|
+
|
|
5
|
+
// src/constants.ts
|
|
6
|
+
init_esm_shims();
|
|
7
|
+
import { resolve } from "path";
|
|
8
|
+
import { fileURLToPath } from "url";
|
|
9
|
+
var distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
|
|
10
|
+
var defaultIncludes = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
|
|
11
|
+
var defaultExcludes = ["**/node_modules/**", "**/dist/**"];
|
|
12
|
+
var globalApis = [
|
|
13
|
+
"suite",
|
|
14
|
+
"test",
|
|
15
|
+
"describe",
|
|
16
|
+
"it",
|
|
17
|
+
"chai",
|
|
18
|
+
"expect",
|
|
19
|
+
"assert",
|
|
20
|
+
"sinon",
|
|
21
|
+
"spy",
|
|
22
|
+
"mock",
|
|
23
|
+
"stub",
|
|
24
|
+
"beforeAll",
|
|
25
|
+
"afterAll",
|
|
26
|
+
"beforeEach",
|
|
27
|
+
"afterEach"
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
export {
|
|
31
|
+
distDir,
|
|
32
|
+
defaultIncludes,
|
|
33
|
+
defaultExcludes,
|
|
34
|
+
globalApis
|
|
35
|
+
};
|