@storybook/addon-vitest 9.2.0-alpha.3 → 10.0.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/README.md +2 -0
- package/dist/_browser-chunks/chunk-JK72E6FR.js +6 -0
- package/dist/_browser-chunks/chunk-PMYV6BH2.js +76 -0
- package/dist/_node-chunks/chunk-2REKPEQ2.js +103 -0
- package/dist/_node-chunks/chunk-7BKJJYBS.js +295 -0
- package/dist/_node-chunks/chunk-HPGEHKZB.js +247 -0
- package/dist/_node-chunks/chunk-JXUNGTEW.js +50 -0
- package/dist/_node-chunks/chunk-MJQUUNLY.js +91 -0
- package/dist/_node-chunks/chunk-RCWLXKPJ.js +37 -0
- package/dist/_node-chunks/chunk-TL7KDPNQ.js +2264 -0
- package/dist/_node-chunks/chunk-ZY3KCBSS.js +481 -0
- package/dist/index.js +9 -6
- package/dist/manager.js +955 -8
- package/dist/node/coverage-reporter.js +1898 -4
- package/dist/node/vitest.js +871 -17
- package/dist/postinstall.js +2076 -88
- package/dist/preset.js +615 -35
- package/dist/vitest-plugin/global-setup.js +200 -6
- package/dist/vitest-plugin/index.js +3823 -43
- package/dist/vitest-plugin/setup-file.js +30 -8
- package/dist/vitest-plugin/test-utils.js +102 -8
- package/manager.js +1 -1
- package/package.json +27 -93
- package/preset.js +1 -1
- package/dist/chunk-55WZLVGN.mjs +0 -11
- package/dist/chunk-JKRQGT2U.mjs +0 -10
- package/dist/index.mjs +0 -5
- package/dist/node/coverage-reporter.d.ts +0 -184
- package/dist/node/coverage-reporter.mjs +0 -12
- package/dist/node/vitest.d.ts +0 -2
- package/dist/node/vitest.mjs +0 -19
- package/dist/vitest-plugin/global-setup.d.ts +0 -6
- package/dist/vitest-plugin/global-setup.mjs +0 -13
- package/dist/vitest-plugin/index.mjs +0 -28
- package/dist/vitest-plugin/setup-file.d.ts +0 -14
- package/dist/vitest-plugin/setup-file.mjs +0 -9
- package/dist/vitest-plugin/test-utils.d.ts +0 -20
- package/dist/vitest-plugin/test-utils.mjs +0 -8
- package/manager.mjs +0 -1
- package/postinstall.js +0 -1
- package/postinstall.mjs +0 -1
- package/preset.mjs +0 -1
|
@@ -1,9 +1,203 @@
|
|
|
1
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_3fqiy48f2ku from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_3fqiy48f2ku from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_3fqiy48f2ku from "node:module";
|
|
2
4
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_3fqiy48f2ku.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_3fqiy48f2ku.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_3fqiy48f2ku.createRequire(import.meta.url);
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
__commonJS,
|
|
14
|
+
__name,
|
|
15
|
+
__require,
|
|
16
|
+
__toESM
|
|
17
|
+
} from "../_node-chunks/chunk-JXUNGTEW.js";
|
|
7
18
|
|
|
8
|
-
|
|
9
|
-
|
|
19
|
+
// ../../node_modules/tree-kill/index.js
|
|
20
|
+
var require_tree_kill = __commonJS({
|
|
21
|
+
"../../node_modules/tree-kill/index.js"(exports, module) {
|
|
22
|
+
"use strict";
|
|
23
|
+
var childProcess = __require("child_process");
|
|
24
|
+
var spawn2 = childProcess.spawn;
|
|
25
|
+
var exec = childProcess.exec;
|
|
26
|
+
module.exports = function(pid, signal, callback) {
|
|
27
|
+
if (typeof signal === "function" && callback === void 0) {
|
|
28
|
+
callback = signal;
|
|
29
|
+
signal = void 0;
|
|
30
|
+
}
|
|
31
|
+
pid = parseInt(pid);
|
|
32
|
+
if (Number.isNaN(pid)) {
|
|
33
|
+
if (callback) {
|
|
34
|
+
return callback(new Error("pid must be a number"));
|
|
35
|
+
} else {
|
|
36
|
+
throw new Error("pid must be a number");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
var tree = {};
|
|
40
|
+
var pidsToProcess = {};
|
|
41
|
+
tree[pid] = [];
|
|
42
|
+
pidsToProcess[pid] = 1;
|
|
43
|
+
switch (process.platform) {
|
|
44
|
+
case "win32":
|
|
45
|
+
exec("taskkill /pid " + pid + " /T /F", callback);
|
|
46
|
+
break;
|
|
47
|
+
case "darwin":
|
|
48
|
+
buildProcessTree(pid, tree, pidsToProcess, function(parentPid) {
|
|
49
|
+
return spawn2("pgrep", ["-P", parentPid]);
|
|
50
|
+
}, function() {
|
|
51
|
+
killAll(tree, signal, callback);
|
|
52
|
+
});
|
|
53
|
+
break;
|
|
54
|
+
// case 'sunos':
|
|
55
|
+
// buildProcessTreeSunOS(pid, tree, pidsToProcess, function () {
|
|
56
|
+
// killAll(tree, signal, callback);
|
|
57
|
+
// });
|
|
58
|
+
// break;
|
|
59
|
+
default:
|
|
60
|
+
buildProcessTree(pid, tree, pidsToProcess, function(parentPid) {
|
|
61
|
+
return spawn2("ps", ["-o", "pid", "--no-headers", "--ppid", parentPid]);
|
|
62
|
+
}, function() {
|
|
63
|
+
killAll(tree, signal, callback);
|
|
64
|
+
});
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
function killAll(tree, signal, callback) {
|
|
69
|
+
var killed = {};
|
|
70
|
+
try {
|
|
71
|
+
Object.keys(tree).forEach(function(pid) {
|
|
72
|
+
tree[pid].forEach(function(pidpid) {
|
|
73
|
+
if (!killed[pidpid]) {
|
|
74
|
+
killPid(pidpid, signal);
|
|
75
|
+
killed[pidpid] = 1;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
if (!killed[pid]) {
|
|
79
|
+
killPid(pid, signal);
|
|
80
|
+
killed[pid] = 1;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
} catch (err) {
|
|
84
|
+
if (callback) {
|
|
85
|
+
return callback(err);
|
|
86
|
+
} else {
|
|
87
|
+
throw err;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (callback) {
|
|
91
|
+
return callback();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
__name(killAll, "killAll");
|
|
95
|
+
function killPid(pid, signal) {
|
|
96
|
+
try {
|
|
97
|
+
process.kill(parseInt(pid, 10), signal);
|
|
98
|
+
} catch (err) {
|
|
99
|
+
if (err.code !== "ESRCH") throw err;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
__name(killPid, "killPid");
|
|
103
|
+
function buildProcessTree(parentPid, tree, pidsToProcess, spawnChildProcessesList, cb) {
|
|
104
|
+
var ps = spawnChildProcessesList(parentPid);
|
|
105
|
+
var allData = "";
|
|
106
|
+
ps.stdout.on("data", function(data) {
|
|
107
|
+
var data = data.toString("ascii");
|
|
108
|
+
allData += data;
|
|
109
|
+
});
|
|
110
|
+
var onClose = /* @__PURE__ */ __name(function(code) {
|
|
111
|
+
delete pidsToProcess[parentPid];
|
|
112
|
+
if (code != 0) {
|
|
113
|
+
if (Object.keys(pidsToProcess).length == 0) {
|
|
114
|
+
cb();
|
|
115
|
+
}
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
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);
|
|
124
|
+
});
|
|
125
|
+
}, "onClose");
|
|
126
|
+
ps.on("close", onClose);
|
|
127
|
+
}
|
|
128
|
+
__name(buildProcessTree, "buildProcessTree");
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// src/vitest-plugin/global-setup.ts
|
|
133
|
+
var import_tree_kill = __toESM(require_tree_kill(), 1);
|
|
134
|
+
import { spawn } from "node:child_process";
|
|
135
|
+
import { logger } from "storybook/internal/node-logger";
|
|
136
|
+
var storybookProcess = null;
|
|
137
|
+
var getIsVitestStandaloneRun = /* @__PURE__ */ __name(() => {
|
|
138
|
+
try {
|
|
139
|
+
return (import.meta.env || process?.env).STORYBOOK !== "true";
|
|
140
|
+
} catch (e) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
}, "getIsVitestStandaloneRun");
|
|
144
|
+
var isVitestStandaloneRun = getIsVitestStandaloneRun();
|
|
145
|
+
var checkStorybookRunning = /* @__PURE__ */ __name(async (storybookUrl) => {
|
|
146
|
+
try {
|
|
147
|
+
const response = await fetch(`${storybookUrl}/iframe.html`, { method: "HEAD" });
|
|
148
|
+
return response.ok;
|
|
149
|
+
} catch {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}, "checkStorybookRunning");
|
|
153
|
+
var startStorybookIfNotRunning = /* @__PURE__ */ __name(async () => {
|
|
154
|
+
const storybookScript = process.env.__STORYBOOK_SCRIPT__;
|
|
155
|
+
const storybookUrl = process.env.__STORYBOOK_URL__;
|
|
156
|
+
const isRunning = await checkStorybookRunning(storybookUrl);
|
|
157
|
+
if (isRunning) {
|
|
158
|
+
logger.verbose("Storybook is already running");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
logger.verbose(`Starting Storybook with command: ${storybookScript}`);
|
|
162
|
+
try {
|
|
163
|
+
storybookProcess = spawn(storybookScript, [], {
|
|
164
|
+
stdio: process.env.DEBUG === "storybook" ? "pipe" : "ignore",
|
|
165
|
+
cwd: process.cwd(),
|
|
166
|
+
shell: true
|
|
167
|
+
});
|
|
168
|
+
storybookProcess.on("error", (error) => {
|
|
169
|
+
logger.verbose("Failed to start Storybook:" + error.message);
|
|
170
|
+
throw error;
|
|
171
|
+
});
|
|
172
|
+
} catch (error) {
|
|
173
|
+
logger.verbose("Failed to start Storybook:" + error.message);
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
176
|
+
}, "startStorybookIfNotRunning");
|
|
177
|
+
var setup = /* @__PURE__ */ __name(async ({ config }) => {
|
|
178
|
+
if (config.watch && isVitestStandaloneRun) {
|
|
179
|
+
await startStorybookIfNotRunning();
|
|
180
|
+
}
|
|
181
|
+
}, "setup");
|
|
182
|
+
var teardown = /* @__PURE__ */ __name(async () => {
|
|
183
|
+
if (!storybookProcess) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
logger.verbose("Stopping Storybook process");
|
|
187
|
+
await new Promise((resolve, reject) => {
|
|
188
|
+
if (storybookProcess?.pid) {
|
|
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");
|
|
200
|
+
export {
|
|
201
|
+
setup,
|
|
202
|
+
teardown
|
|
203
|
+
};
|