@storybook/addon-vitest 0.0.0-pr-32795-sha-81cf1f23 → 0.0.0-pr-32717-sha-f340a68b
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-JK72E6FR.js +6 -0
- package/dist/_browser-chunks/chunk-RPDOPHZX.js +77 -0
- package/dist/_node-chunks/chunk-724JPUHM.js +40 -0
- package/dist/_node-chunks/{chunk-KCHXXKAS.js → chunk-7ZCNTQXP.js} +24 -15
- package/dist/_node-chunks/chunk-A4VFZRVB.js +502 -0
- package/dist/_node-chunks/chunk-G6ASZ6US.js +69 -0
- package/dist/_node-chunks/{chunk-ML5LEYEM.js → chunk-K5BRNZW2.js} +19 -14
- package/dist/_node-chunks/chunk-KHNVQCL7.js +92 -0
- package/dist/_node-chunks/chunk-MLM43G3E.js +260 -0
- package/dist/_node-chunks/chunk-NGOGIT42.js +60 -0
- package/dist/_node-chunks/chunk-TXTKPPIA.js +247 -0
- package/dist/index.js +5 -1
- package/dist/manager.js +354 -163
- package/dist/node/coverage-reporter.js +864 -319
- package/dist/node/vitest.js +466 -190
- package/dist/postinstall.js +1276 -633
- package/dist/preset.js +354 -160
- package/dist/vitest-plugin/global-setup.js +105 -51
- package/dist/vitest-plugin/index.js +2381 -1161
- package/dist/vitest-plugin/setup-file.js +12 -6
- package/dist/vitest-plugin/test-utils.js +71 -31
- package/package.json +3 -7
- package/dist/_browser-chunks/chunk-ULSHVN74.js +0 -60
- package/dist/_node-chunks/chunk-43MIUCD6.js +0 -138
- package/dist/_node-chunks/chunk-NCYNCIBX.js +0 -1697
- package/dist/_node-chunks/chunk-NSF3UF7J.js +0 -339
- package/dist/_node-chunks/chunk-PYDFQUST.js +0 -35
- package/dist/_node-chunks/chunk-XTWQR354.js +0 -69
- package/dist/_node-chunks/chunk-ZI6UZG2P.js +0 -83
|
@@ -1,33 +1,46 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_xvr6gehai1p from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_xvr6gehai1p from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_xvr6gehai1p from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_xvr6gehai1p.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_xvr6gehai1p.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_xvr6gehai1p.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,
|
|
14
15
|
__require,
|
|
15
16
|
__toESM
|
|
16
|
-
} from "../_node-chunks/chunk-
|
|
17
|
+
} from "../_node-chunks/chunk-K5BRNZW2.js";
|
|
17
18
|
|
|
18
19
|
// ../../node_modules/tree-kill/index.js
|
|
19
20
|
var require_tree_kill = __commonJS({
|
|
20
21
|
"../../node_modules/tree-kill/index.js"(exports, module) {
|
|
21
22
|
"use strict";
|
|
22
|
-
var childProcess = __require("child_process")
|
|
23
|
+
var childProcess = __require("child_process");
|
|
24
|
+
var spawn2 = childProcess.spawn;
|
|
25
|
+
var exec = childProcess.exec;
|
|
23
26
|
module.exports = function(pid, signal, callback) {
|
|
24
|
-
if (typeof signal
|
|
25
|
-
|
|
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) {
|
|
26
34
|
return callback(new Error("pid must be a number"));
|
|
27
|
-
|
|
35
|
+
} else {
|
|
36
|
+
throw new Error("pid must be a number");
|
|
37
|
+
}
|
|
28
38
|
}
|
|
29
|
-
var tree = {}
|
|
30
|
-
|
|
39
|
+
var tree = {};
|
|
40
|
+
var pidsToProcess = {};
|
|
41
|
+
tree[pid] = [];
|
|
42
|
+
pidsToProcess[pid] = 1;
|
|
43
|
+
switch (process.platform) {
|
|
31
44
|
case "win32":
|
|
32
45
|
exec("taskkill /pid " + pid + " /T /F", callback);
|
|
33
46
|
break;
|
|
@@ -57,17 +70,28 @@ var require_tree_kill = __commonJS({
|
|
|
57
70
|
try {
|
|
58
71
|
Object.keys(tree).forEach(function(pid) {
|
|
59
72
|
tree[pid].forEach(function(pidpid) {
|
|
60
|
-
|
|
61
|
-
|
|
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
|
+
}
|
|
62
82
|
});
|
|
63
83
|
} catch (err) {
|
|
64
|
-
if (callback)
|
|
84
|
+
if (callback) {
|
|
65
85
|
return callback(err);
|
|
66
|
-
|
|
86
|
+
} else {
|
|
87
|
+
throw err;
|
|
88
|
+
}
|
|
67
89
|
}
|
|
68
|
-
if (callback)
|
|
90
|
+
if (callback) {
|
|
69
91
|
return callback();
|
|
92
|
+
}
|
|
70
93
|
}
|
|
94
|
+
__name(killAll, "killAll");
|
|
71
95
|
function killPid(pid, signal) {
|
|
72
96
|
try {
|
|
73
97
|
process.kill(parseInt(pid, 10), signal);
|
|
@@ -75,23 +99,33 @@ var require_tree_kill = __commonJS({
|
|
|
75
99
|
if (err.code !== "ESRCH") throw err;
|
|
76
100
|
}
|
|
77
101
|
}
|
|
102
|
+
__name(killPid, "killPid");
|
|
78
103
|
function buildProcessTree(parentPid, tree, pidsToProcess, spawnChildProcessesList, cb) {
|
|
79
|
-
var ps = spawnChildProcessesList(parentPid)
|
|
104
|
+
var ps = spawnChildProcessesList(parentPid);
|
|
105
|
+
var allData = "";
|
|
80
106
|
ps.stdout.on("data", function(data) {
|
|
81
107
|
var data = data.toString("ascii");
|
|
82
108
|
allData += data;
|
|
83
109
|
});
|
|
84
|
-
var onClose = function(code) {
|
|
85
|
-
|
|
86
|
-
|
|
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
|
+
}
|
|
87
116
|
return;
|
|
88
117
|
}
|
|
89
118
|
allData.match(/\d+/g).forEach(function(pid) {
|
|
90
|
-
pid = parseInt(pid, 10)
|
|
119
|
+
pid = parseInt(pid, 10);
|
|
120
|
+
tree[parentPid].push(pid);
|
|
121
|
+
tree[pid] = [];
|
|
122
|
+
pidsToProcess[pid] = 1;
|
|
123
|
+
buildProcessTree(pid, tree, pidsToProcess, spawnChildProcessesList, cb);
|
|
91
124
|
});
|
|
92
|
-
};
|
|
125
|
+
}, "onClose");
|
|
93
126
|
ps.on("close", onClose);
|
|
94
127
|
}
|
|
128
|
+
__name(buildProcessTree, "buildProcessTree");
|
|
95
129
|
}
|
|
96
130
|
});
|
|
97
131
|
|
|
@@ -99,21 +133,28 @@ var require_tree_kill = __commonJS({
|
|
|
99
133
|
var import_tree_kill = __toESM(require_tree_kill(), 1);
|
|
100
134
|
import { spawn } from "node:child_process";
|
|
101
135
|
import { logger } from "storybook/internal/node-logger";
|
|
102
|
-
var storybookProcess = null
|
|
136
|
+
var storybookProcess = null;
|
|
137
|
+
var getIsVitestStandaloneRun = /* @__PURE__ */ __name(() => {
|
|
103
138
|
try {
|
|
104
139
|
return (import.meta.env || process?.env).STORYBOOK !== "true";
|
|
105
|
-
} catch {
|
|
106
|
-
return
|
|
140
|
+
} catch (e) {
|
|
141
|
+
return false;
|
|
107
142
|
}
|
|
108
|
-
},
|
|
143
|
+
}, "getIsVitestStandaloneRun");
|
|
144
|
+
var isVitestStandaloneRun = getIsVitestStandaloneRun();
|
|
145
|
+
var checkStorybookRunning = /* @__PURE__ */ __name(async (storybookUrl) => {
|
|
109
146
|
try {
|
|
110
|
-
|
|
147
|
+
const response = await fetch(`${storybookUrl}/iframe.html`, { method: "HEAD" });
|
|
148
|
+
return response.ok;
|
|
111
149
|
} catch {
|
|
112
|
-
return
|
|
150
|
+
return false;
|
|
113
151
|
}
|
|
114
|
-
},
|
|
115
|
-
|
|
116
|
-
|
|
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) {
|
|
117
158
|
logger.verbose("Storybook is already running");
|
|
118
159
|
return;
|
|
119
160
|
}
|
|
@@ -121,27 +162,40 @@ var storybookProcess = null, getIsVitestStandaloneRun = () => {
|
|
|
121
162
|
try {
|
|
122
163
|
storybookProcess = spawn(storybookScript, [], {
|
|
123
164
|
stdio: process.env.DEBUG === "storybook" ? "pipe" : "ignore",
|
|
124
|
-
cwd: process.cwd()
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
165
|
+
cwd: process.cwd()
|
|
166
|
+
});
|
|
167
|
+
storybookProcess.on("error", (error) => {
|
|
168
|
+
logger.verbose("Failed to start Storybook:" + error.message);
|
|
169
|
+
throw error;
|
|
128
170
|
});
|
|
129
171
|
} catch (error) {
|
|
130
|
-
|
|
172
|
+
logger.verbose("Failed to start Storybook:" + error.message);
|
|
173
|
+
throw error;
|
|
131
174
|
}
|
|
132
|
-
},
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
175
|
+
}, "startStorybookIfNotRunning");
|
|
176
|
+
var setup = /* @__PURE__ */ __name(async ({ config }) => {
|
|
177
|
+
if (config.watch && isVitestStandaloneRun) {
|
|
178
|
+
await startStorybookIfNotRunning();
|
|
179
|
+
}
|
|
180
|
+
}, "setup");
|
|
181
|
+
var teardown = /* @__PURE__ */ __name(async () => {
|
|
182
|
+
if (!storybookProcess) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
logger.verbose("Stopping Storybook process");
|
|
186
|
+
await new Promise((resolve, reject) => {
|
|
187
|
+
if (storybookProcess?.pid) {
|
|
188
|
+
(0, import_tree_kill.default)(storybookProcess.pid, "SIGTERM", (error) => {
|
|
189
|
+
if (error) {
|
|
190
|
+
logger.error("Failed to stop Storybook process:");
|
|
191
|
+
reject(error);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
resolve();
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
}, "teardown");
|
|
145
199
|
export {
|
|
146
200
|
setup,
|
|
147
201
|
teardown
|