@storybook/addon-vitest 10.1.0-alpha.9 → 10.1.0-beta.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/dist/_browser-chunks/chunk-TJXI7EIW.js +61 -0
- package/dist/_node-chunks/chunk-3NMZMB7I.js +71 -0
- package/dist/_node-chunks/chunk-FUZOQ3FW.js +339 -0
- package/dist/_node-chunks/chunk-GK6RMDY2.js +138 -0
- package/dist/_node-chunks/chunk-HKXN64KX.js +45 -0
- package/dist/_node-chunks/chunk-LVG5WDH3.js +158 -0
- package/dist/_node-chunks/chunk-MZFBI7ON.js +61 -0
- package/dist/_node-chunks/chunk-NMJA4RKJ.js +38 -0
- package/dist/_node-chunks/chunk-R65ONYP6.js +44 -0
- package/dist/_node-chunks/{chunk-WMX7UISE.js → chunk-XHKBPQ3A.js} +15 -24
- package/dist/index.js +1 -5
- package/dist/manager.js +274 -491
- package/dist/node/coverage-reporter.js +319 -864
- package/dist/node/vitest.js +201 -456
- package/dist/postinstall.js +497 -1502
- package/dist/preset.js +166 -349
- package/dist/vitest-plugin/global-setup.js +52 -107
- package/dist/vitest-plugin/index.js +1163 -2378
- package/dist/vitest-plugin/setup-file.js +6 -12
- package/dist/vitest-plugin/test-utils.js +31 -71
- package/package.json +3 -7
- package/dist/_browser-chunks/chunk-CAYLRBRX.js +0 -77
- package/dist/_browser-chunks/chunk-JK72E6FR.js +0 -6
- package/dist/_node-chunks/chunk-4TORVAZH.js +0 -105
- package/dist/_node-chunks/chunk-6Q62BC44.js +0 -37
- package/dist/_node-chunks/chunk-EQRHHTTK.js +0 -98
- package/dist/_node-chunks/chunk-EWGF3LDY.js +0 -481
- package/dist/_node-chunks/chunk-RDCJFLHV.js +0 -247
- package/dist/_node-chunks/chunk-W5CYX7PP.js +0 -50
- package/dist/_node-chunks/chunk-XKCUKATS.js +0 -2574
|
@@ -1,46 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_0y3a0b4lhx0h from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_0y3a0b4lhx0h from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_0y3a0b4lhx0h from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_0y3a0b4lhx0h.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_0y3a0b4lhx0h.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_0y3a0b4lhx0h.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
__commonJS,
|
|
14
|
-
__name,
|
|
15
14
|
__require,
|
|
16
15
|
__toESM
|
|
17
|
-
} from "../_node-chunks/chunk-
|
|
16
|
+
} from "../_node-chunks/chunk-HKXN64KX.js";
|
|
18
17
|
|
|
19
18
|
// ../../node_modules/tree-kill/index.js
|
|
20
19
|
var require_tree_kill = __commonJS({
|
|
21
20
|
"../../node_modules/tree-kill/index.js"(exports, module) {
|
|
22
21
|
"use strict";
|
|
23
|
-
var childProcess = __require("child_process");
|
|
24
|
-
var spawn2 = childProcess.spawn;
|
|
25
|
-
var exec = childProcess.exec;
|
|
22
|
+
var childProcess = __require("child_process"), spawn2 = childProcess.spawn, exec = childProcess.exec;
|
|
26
23
|
module.exports = function(pid, signal, callback) {
|
|
27
|
-
if (typeof signal
|
|
28
|
-
callback
|
|
29
|
-
signal = void 0;
|
|
30
|
-
}
|
|
31
|
-
pid = parseInt(pid);
|
|
32
|
-
if (Number.isNaN(pid)) {
|
|
33
|
-
if (callback) {
|
|
24
|
+
if (typeof signal == "function" && callback === void 0 && (callback = signal, signal = void 0), pid = parseInt(pid), Number.isNaN(pid)) {
|
|
25
|
+
if (callback)
|
|
34
26
|
return callback(new Error("pid must be a number"));
|
|
35
|
-
|
|
36
|
-
throw new Error("pid must be a number");
|
|
37
|
-
}
|
|
27
|
+
throw new Error("pid must be a number");
|
|
38
28
|
}
|
|
39
|
-
var tree = {};
|
|
40
|
-
|
|
41
|
-
tree[pid] = [];
|
|
42
|
-
pidsToProcess[pid] = 1;
|
|
43
|
-
switch (process.platform) {
|
|
29
|
+
var tree = {}, pidsToProcess = {};
|
|
30
|
+
switch (tree[pid] = [], pidsToProcess[pid] = 1, process.platform) {
|
|
44
31
|
case "win32":
|
|
45
32
|
exec("taskkill /pid " + pid + " /T /F", callback);
|
|
46
33
|
break;
|
|
@@ -70,28 +57,17 @@ var require_tree_kill = __commonJS({
|
|
|
70
57
|
try {
|
|
71
58
|
Object.keys(tree).forEach(function(pid) {
|
|
72
59
|
tree[pid].forEach(function(pidpid) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
killed[pidpid] = 1;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
if (!killed[pid]) {
|
|
79
|
-
killPid(pid, signal);
|
|
80
|
-
killed[pid] = 1;
|
|
81
|
-
}
|
|
60
|
+
killed[pidpid] || (killPid(pidpid, signal), killed[pidpid] = 1);
|
|
61
|
+
}), killed[pid] || (killPid(pid, signal), killed[pid] = 1);
|
|
82
62
|
});
|
|
83
63
|
} catch (err) {
|
|
84
|
-
if (callback)
|
|
64
|
+
if (callback)
|
|
85
65
|
return callback(err);
|
|
86
|
-
|
|
87
|
-
throw err;
|
|
88
|
-
}
|
|
66
|
+
throw err;
|
|
89
67
|
}
|
|
90
|
-
if (callback)
|
|
68
|
+
if (callback)
|
|
91
69
|
return callback();
|
|
92
|
-
}
|
|
93
70
|
}
|
|
94
|
-
__name(killAll, "killAll");
|
|
95
71
|
function killPid(pid, signal) {
|
|
96
72
|
try {
|
|
97
73
|
process.kill(parseInt(pid, 10), signal);
|
|
@@ -99,33 +75,23 @@ var require_tree_kill = __commonJS({
|
|
|
99
75
|
if (err.code !== "ESRCH") throw err;
|
|
100
76
|
}
|
|
101
77
|
}
|
|
102
|
-
__name(killPid, "killPid");
|
|
103
78
|
function buildProcessTree(parentPid, tree, pidsToProcess, spawnChildProcessesList, cb) {
|
|
104
|
-
var ps = spawnChildProcessesList(parentPid);
|
|
105
|
-
var allData = "";
|
|
79
|
+
var ps = spawnChildProcessesList(parentPid), allData = "";
|
|
106
80
|
ps.stdout.on("data", function(data) {
|
|
107
81
|
var data = data.toString("ascii");
|
|
108
82
|
allData += data;
|
|
109
83
|
});
|
|
110
|
-
var onClose =
|
|
111
|
-
delete pidsToProcess[parentPid]
|
|
112
|
-
|
|
113
|
-
if (Object.keys(pidsToProcess).length == 0) {
|
|
114
|
-
cb();
|
|
115
|
-
}
|
|
84
|
+
var onClose = function(code) {
|
|
85
|
+
if (delete pidsToProcess[parentPid], code != 0) {
|
|
86
|
+
Object.keys(pidsToProcess).length == 0 && cb();
|
|
116
87
|
return;
|
|
117
88
|
}
|
|
118
89
|
allData.match(/\d+/g).forEach(function(pid) {
|
|
119
|
-
pid = parseInt(pid, 10);
|
|
120
|
-
tree[parentPid].push(pid);
|
|
121
|
-
tree[pid] = [];
|
|
122
|
-
pidsToProcess[pid] = 1;
|
|
123
|
-
buildProcessTree(pid, tree, pidsToProcess, spawnChildProcessesList, cb);
|
|
90
|
+
pid = parseInt(pid, 10), tree[parentPid].push(pid), tree[pid] = [], pidsToProcess[pid] = 1, buildProcessTree(pid, tree, pidsToProcess, spawnChildProcessesList, cb);
|
|
124
91
|
});
|
|
125
|
-
}
|
|
92
|
+
};
|
|
126
93
|
ps.on("close", onClose);
|
|
127
94
|
}
|
|
128
|
-
__name(buildProcessTree, "buildProcessTree");
|
|
129
95
|
}
|
|
130
96
|
});
|
|
131
97
|
|
|
@@ -133,70 +99,49 @@ var require_tree_kill = __commonJS({
|
|
|
133
99
|
var import_tree_kill = __toESM(require_tree_kill(), 1);
|
|
134
100
|
import { spawn } from "node:child_process";
|
|
135
101
|
import { logger } from "storybook/internal/node-logger";
|
|
136
|
-
var storybookProcess = null
|
|
137
|
-
var getIsVitestStandaloneRun = /* @__PURE__ */ __name(() => {
|
|
102
|
+
var storybookProcess = null, getIsVitestStandaloneRun = () => {
|
|
138
103
|
try {
|
|
139
104
|
return (import.meta.env || process?.env).STORYBOOK !== "true";
|
|
140
|
-
} catch
|
|
141
|
-
return
|
|
105
|
+
} catch {
|
|
106
|
+
return !1;
|
|
142
107
|
}
|
|
143
|
-
},
|
|
144
|
-
var isVitestStandaloneRun = getIsVitestStandaloneRun();
|
|
145
|
-
var checkStorybookRunning = /* @__PURE__ */ __name(async (storybookUrl) => {
|
|
108
|
+
}, isVitestStandaloneRun = getIsVitestStandaloneRun(), checkStorybookRunning = async (storybookUrl) => {
|
|
146
109
|
try {
|
|
147
|
-
|
|
148
|
-
return response.ok;
|
|
110
|
+
return (await fetch(`${storybookUrl}/iframe.html`, { method: "HEAD" })).ok;
|
|
149
111
|
} catch {
|
|
150
|
-
return
|
|
112
|
+
return !1;
|
|
151
113
|
}
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const storybookUrl = process.env.__STORYBOOK_URL__;
|
|
156
|
-
const isRunning = await checkStorybookRunning(storybookUrl);
|
|
157
|
-
if (isRunning) {
|
|
114
|
+
}, startStorybookIfNotRunning = async () => {
|
|
115
|
+
let storybookScript = process.env.__STORYBOOK_SCRIPT__, storybookUrl = process.env.__STORYBOOK_URL__;
|
|
116
|
+
if (await checkStorybookRunning(storybookUrl)) {
|
|
158
117
|
logger.verbose("Storybook is already running");
|
|
159
118
|
return;
|
|
160
119
|
}
|
|
161
120
|
logger.verbose(`Starting Storybook with command: ${storybookScript}`);
|
|
162
121
|
try {
|
|
163
|
-
storybookProcess = spawn(storybookScript,
|
|
122
|
+
storybookProcess = spawn(storybookScript, {
|
|
123
|
+
shell: !0,
|
|
164
124
|
stdio: process.env.DEBUG === "storybook" ? "pipe" : "ignore",
|
|
165
|
-
cwd: process.cwd()
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
storybookProcess.on("error", (error) => {
|
|
169
|
-
logger.verbose("Failed to start Storybook:" + error.message);
|
|
170
|
-
throw error;
|
|
125
|
+
cwd: process.cwd()
|
|
126
|
+
}), storybookProcess.on("error", (error) => {
|
|
127
|
+
throw logger.verbose("Failed to start Storybook:" + error.message), error;
|
|
171
128
|
});
|
|
172
129
|
} catch (error) {
|
|
173
|
-
logger.verbose("Failed to start Storybook:" + error.message);
|
|
174
|
-
throw error;
|
|
130
|
+
throw logger.verbose("Failed to start Storybook:" + error.message), error;
|
|
175
131
|
}
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
(0, import_tree_kill.default)(storybookProcess.pid, "SIGTERM", (error) => {
|
|
190
|
-
if (error) {
|
|
191
|
-
logger.error("Failed to stop Storybook process:");
|
|
192
|
-
reject(error);
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
resolve();
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}, "teardown");
|
|
132
|
+
}, setup = async ({ config }) => {
|
|
133
|
+
config.watch && isVitestStandaloneRun && await startStorybookIfNotRunning();
|
|
134
|
+
}, teardown = async () => {
|
|
135
|
+
storybookProcess && (logger.verbose("Stopping Storybook process"), await new Promise((resolve, reject) => {
|
|
136
|
+
storybookProcess?.pid && (0, import_tree_kill.default)(storybookProcess.pid, "SIGTERM", (error) => {
|
|
137
|
+
if (error) {
|
|
138
|
+
logger.error("Failed to stop Storybook process:"), reject(error);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
resolve();
|
|
142
|
+
});
|
|
143
|
+
}));
|
|
144
|
+
};
|
|
200
145
|
export {
|
|
201
146
|
setup,
|
|
202
147
|
teardown
|