@storybook/addon-vitest 0.0.0-pr-31819-sha-e4987461 → 0.0.0-pr-31819-sha-36ca675c
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/postinstall.js +272 -270
- package/dist/preset.js +68 -68
- package/package.json +2 -2
package/dist/preset.js
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
b as L
|
|
17
17
|
} from "./_node-chunks/chunk-XWQZZ2C3.js";
|
|
18
18
|
import {
|
|
19
|
-
a as
|
|
19
|
+
a as A,
|
|
20
20
|
b as P,
|
|
21
21
|
d as k,
|
|
22
22
|
f as R,
|
|
@@ -26,31 +26,31 @@ import {
|
|
|
26
26
|
l as F
|
|
27
27
|
} from "./_node-chunks/chunk-FMQIQP6D.js";
|
|
28
28
|
import {
|
|
29
|
-
a as
|
|
29
|
+
a as Y
|
|
30
30
|
} from "./_node-chunks/chunk-N3OFRDD3.js";
|
|
31
31
|
import {
|
|
32
32
|
b as x
|
|
33
33
|
} from "./_node-chunks/chunk-W26ZMSD3.js";
|
|
34
34
|
import {
|
|
35
35
|
a as c,
|
|
36
|
-
e as
|
|
36
|
+
e as B
|
|
37
37
|
} from "./_node-chunks/chunk-KVKHJ5OL.js";
|
|
38
38
|
|
|
39
39
|
// src/preset.ts
|
|
40
40
|
import { mkdir as J } from "node:fs/promises";
|
|
41
41
|
import {
|
|
42
42
|
createFileSystemCache as Z,
|
|
43
|
-
getFrameworkName as
|
|
44
|
-
loadPreviewOrConfigFile as
|
|
43
|
+
getFrameworkName as ee,
|
|
44
|
+
loadPreviewOrConfigFile as te,
|
|
45
45
|
resolvePathInStorybookCache as U
|
|
46
46
|
} from "storybook/internal/common";
|
|
47
47
|
import {
|
|
48
|
-
experimental_UniversalStore as
|
|
49
|
-
experimental_getTestProviderStore as
|
|
48
|
+
experimental_UniversalStore as re,
|
|
49
|
+
experimental_getTestProviderStore as oe
|
|
50
50
|
} from "storybook/internal/core-server";
|
|
51
|
-
import { cleanPaths as
|
|
52
|
-
var $ = Y(
|
|
53
|
-
import { dedent as
|
|
51
|
+
import { cleanPaths as se, oneWayHash as ae, sanitizeError as ne, telemetry as _ } from "storybook/internal/telemetry";
|
|
52
|
+
var $ = B(Y(), 1);
|
|
53
|
+
import { dedent as ie } from "ts-dedent";
|
|
54
54
|
|
|
55
55
|
// src/node/boot-test-runner.ts
|
|
56
56
|
import { fileURLToPath as q } from "node:url";
|
|
@@ -87,25 +87,25 @@ var G = 3e4, Q = q(F("@storybook/addon-vitest/vitest")), h = [], d, C = !1, M, V
|
|
|
87
87
|
STORYBOOK_CONFIG_DIR: x(s.configDir)
|
|
88
88
|
},
|
|
89
89
|
extendEnv: !0
|
|
90
|
-
}), m = [], d.stdout?.on("data", p), d.stderr?.on("data", (
|
|
91
|
-
|
|
90
|
+
}), m = [], d.stdout?.on("data", p), d.stderr?.on("data", (e) => {
|
|
91
|
+
e.toString().match(/^\u001B\[33m/) || (p(e), m.push(e.toString()));
|
|
92
92
|
}), M = r.subscribe(O(E)), V = z.subscribe(
|
|
93
93
|
O(I)
|
|
94
94
|
), H = K.subscribe(
|
|
95
95
|
O(D)
|
|
96
|
-
), d.on("message", (
|
|
97
|
-
if (
|
|
96
|
+
), d.on("message", (e) => {
|
|
97
|
+
if (e.type === "ready") {
|
|
98
98
|
for (; h.length; ) {
|
|
99
|
-
let { type: S, args:
|
|
100
|
-
d?.send({ type: S, args:
|
|
99
|
+
let { type: S, args: t } = h.shift();
|
|
100
|
+
d?.send({ type: S, args: t, from: "server" });
|
|
101
101
|
}
|
|
102
102
|
i();
|
|
103
|
-
} else
|
|
103
|
+
} else e.type === "uncaught-error" ? (r.send({
|
|
104
104
|
type: "FATAL_ERROR",
|
|
105
|
-
payload:
|
|
106
|
-
}), u()) : n.emit(
|
|
105
|
+
payload: e.payload
|
|
106
|
+
}), u()) : n.emit(e.type, ...e.args);
|
|
107
107
|
});
|
|
108
|
-
}), "startChildProcess"),
|
|
108
|
+
}), "startChildProcess"), T = new Promise(
|
|
109
109
|
(i, u) => setTimeout(
|
|
110
110
|
u,
|
|
111
111
|
G,
|
|
@@ -115,7 +115,7 @@ var G = 3e4, Q = q(F("@storybook/addon-vitest/vitest")), h = [], d, C = !1, M, V
|
|
|
115
115
|
)
|
|
116
116
|
)
|
|
117
117
|
);
|
|
118
|
-
await Promise.race([g(),
|
|
118
|
+
await Promise.race([g(), T]).catch((i) => {
|
|
119
119
|
throw r.send({
|
|
120
120
|
type: "FATAL_ERROR",
|
|
121
121
|
payload: {
|
|
@@ -140,28 +140,28 @@ var G = 3e4, Q = q(F("@storybook/addon-vitest/vitest")), h = [], d, C = !1, M, V
|
|
|
140
140
|
}, "runTestRunner");
|
|
141
141
|
|
|
142
142
|
// src/preset.ts
|
|
143
|
-
var
|
|
144
|
-
let s = await r.presets.apply("core"), m =
|
|
143
|
+
var Oe = /* @__PURE__ */ c(async (n, r) => {
|
|
144
|
+
let s = await r.presets.apply("core"), m = te({ configDir: r.configDir }), y = await r.presets.apply(
|
|
145
145
|
"previewAnnotations",
|
|
146
146
|
[],
|
|
147
147
|
r
|
|
148
|
-
), f = typeof s?.builder == "string" ? s.builder : s?.builder?.name, g = await
|
|
148
|
+
), f = typeof s?.builder == "string" ? s.builder : s?.builder?.name, g = await ee(r);
|
|
149
149
|
if (!f?.includes("vite"))
|
|
150
|
-
return g.includes("nextjs") && p(
|
|
150
|
+
return g.includes("nextjs") && p(ie`
|
|
151
151
|
You're using ${g}, which is a Webpack-based builder. In order to use Storybook Test, with your project, you need to use '@storybook/nextjs-vite', a high performance Vite-based equivalent.
|
|
152
152
|
|
|
153
153
|
Information on how to upgrade here: ${$.default.yellow("https://storybook.js.org/docs/get-started/frameworks/nextjs#with-vite")}\n
|
|
154
154
|
`), n;
|
|
155
|
-
let
|
|
156
|
-
basePath: U(
|
|
155
|
+
let T = Z({
|
|
156
|
+
basePath: U(A.replace("/", "-")),
|
|
157
157
|
ns: "storybook",
|
|
158
158
|
ttl: 14 * 24 * 60 * 60 * 1e3
|
|
159
159
|
// 14 days
|
|
160
|
-
}), i = await
|
|
160
|
+
}), i = await T.get("state", {
|
|
161
161
|
config: R.initialState.config
|
|
162
|
-
}), u = /* @__PURE__ */ c((
|
|
163
|
-
config:
|
|
164
|
-
}), "selectCachedState"),
|
|
162
|
+
}), u = /* @__PURE__ */ c((t) => ({
|
|
163
|
+
config: t.config
|
|
164
|
+
}), "selectCachedState"), e = re.create({
|
|
165
165
|
...R,
|
|
166
166
|
initialState: {
|
|
167
167
|
...R.initialState,
|
|
@@ -170,46 +170,46 @@ var Ot = /* @__PURE__ */ c(async (n, r) => {
|
|
|
170
170
|
},
|
|
171
171
|
leader: !0
|
|
172
172
|
});
|
|
173
|
-
|
|
174
|
-
N(u(
|
|
173
|
+
e.onStateChange((t, o) => {
|
|
174
|
+
N(u(t), u(o)) || T.set("state", u(t));
|
|
175
175
|
});
|
|
176
|
-
let S =
|
|
177
|
-
if (
|
|
178
|
-
S.setState("test-provider-state:running"),
|
|
176
|
+
let S = oe(A);
|
|
177
|
+
if (e.subscribe("TRIGGER_RUN", (t, o) => {
|
|
178
|
+
S.setState("test-provider-state:running"), e.setState((a) => ({
|
|
179
179
|
...a,
|
|
180
180
|
fatalError: void 0
|
|
181
181
|
})), w({
|
|
182
182
|
channel: n,
|
|
183
|
-
store:
|
|
183
|
+
store: e,
|
|
184
184
|
initEvent: E,
|
|
185
|
-
initArgs: [{ event:
|
|
185
|
+
initArgs: [{ event: t, eventInfo: o }],
|
|
186
186
|
options: r
|
|
187
187
|
});
|
|
188
|
-
}),
|
|
189
|
-
|
|
188
|
+
}), e.subscribe("TOGGLE_WATCHING", (t, o) => {
|
|
189
|
+
e.setState((a) => ({
|
|
190
190
|
...a,
|
|
191
|
-
watching:
|
|
191
|
+
watching: t.payload.to,
|
|
192
192
|
currentRun: {
|
|
193
193
|
...a.currentRun,
|
|
194
194
|
// when enabling watch mode, clear the coverage summary too
|
|
195
|
-
...
|
|
195
|
+
...t.payload.to && {
|
|
196
196
|
coverageSummary: void 0
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
})),
|
|
199
|
+
})), t.payload.to && w({
|
|
200
200
|
channel: n,
|
|
201
|
-
store:
|
|
201
|
+
store: e,
|
|
202
202
|
initEvent: E,
|
|
203
|
-
initArgs: [{ event:
|
|
203
|
+
initArgs: [{ event: t, eventInfo: o }],
|
|
204
204
|
options: r
|
|
205
205
|
});
|
|
206
|
-
}),
|
|
207
|
-
let { message: o, error: a } =
|
|
208
|
-
p(`${
|
|
209
|
-
function
|
|
210
|
-
l && (p(`Caused by: ${l.name ?? "Error"}: ${l.message}`), l.stack && p(l.stack), l.cause &&
|
|
206
|
+
}), e.subscribe("FATAL_ERROR", (t) => {
|
|
207
|
+
let { message: o, error: a } = t.payload, v = a.name || "Error";
|
|
208
|
+
p(`${v}: ${o}`), a.stack && p(a.stack);
|
|
209
|
+
function b(l) {
|
|
210
|
+
l && (p(`Caused by: ${l.name ?? "Error"}: ${l.message}`), l.stack && p(l.stack), l.cause && b(l.cause));
|
|
211
211
|
}
|
|
212
|
-
c(
|
|
212
|
+
c(b, "logErrorWithCauses"), a.cause && b(a.cause), e.setState((l) => ({
|
|
213
213
|
...l,
|
|
214
214
|
fatalError: {
|
|
215
215
|
message: o,
|
|
@@ -217,45 +217,45 @@ var Ot = /* @__PURE__ */ c(async (n, r) => {
|
|
|
217
217
|
}
|
|
218
218
|
})), S.setState("test-provider-state:crashed");
|
|
219
219
|
}), S.onClearAll(() => {
|
|
220
|
-
|
|
221
|
-
...
|
|
222
|
-
currentRun: { ...
|
|
220
|
+
e.setState((t) => ({
|
|
221
|
+
...t,
|
|
222
|
+
currentRun: { ...t.currentRun, coverageSummary: void 0, unhandledErrors: [] }
|
|
223
223
|
}));
|
|
224
224
|
}), !s.disableTelemetry) {
|
|
225
|
-
let
|
|
225
|
+
let t = s.enableCrashReports || r.enableCrashReports;
|
|
226
226
|
n.on(P, (o) => {
|
|
227
227
|
_("addon-test", {
|
|
228
228
|
...o,
|
|
229
229
|
payload: {
|
|
230
230
|
...o.payload,
|
|
231
|
-
storyId:
|
|
231
|
+
storyId: ae(o.payload.storyId)
|
|
232
232
|
}
|
|
233
233
|
});
|
|
234
|
-
}),
|
|
234
|
+
}), e.subscribe("TOGGLE_WATCHING", async (o) => {
|
|
235
235
|
await _("addon-test", {
|
|
236
236
|
watchMode: o.payload.to
|
|
237
237
|
});
|
|
238
|
-
}),
|
|
239
|
-
let { unhandledErrors: a, startedAt:
|
|
238
|
+
}), e.subscribe("TEST_RUN_COMPLETED", async (o) => {
|
|
239
|
+
let { unhandledErrors: a, startedAt: v, finishedAt: b, ...l } = o.payload;
|
|
240
240
|
await _("addon-test", {
|
|
241
241
|
...l,
|
|
242
|
-
duration: (
|
|
242
|
+
duration: (b ?? 0) - (v ?? 0),
|
|
243
243
|
unhandledErrorCount: a.length,
|
|
244
|
-
...
|
|
244
|
+
...t && a.length > 0 && {
|
|
245
245
|
unhandledErrors: a.map((W) => {
|
|
246
|
-
let { stacks:
|
|
247
|
-
return
|
|
246
|
+
let { stacks: ce, ...j } = W;
|
|
247
|
+
return ne(j);
|
|
248
248
|
})
|
|
249
249
|
}
|
|
250
250
|
});
|
|
251
|
-
}),
|
|
251
|
+
}), t && e.subscribe("FATAL_ERROR", async (o) => {
|
|
252
252
|
await _("addon-test", {
|
|
253
|
-
fatalError:
|
|
253
|
+
fatalError: se(o.payload.error.message)
|
|
254
254
|
});
|
|
255
255
|
});
|
|
256
256
|
}
|
|
257
257
|
return n;
|
|
258
|
-
}, "experimental_serverChannel"),
|
|
258
|
+
}, "experimental_serverChannel"), we = /* @__PURE__ */ c(async (n = [], r) => {
|
|
259
259
|
if (r.configType === "PRODUCTION")
|
|
260
260
|
return n;
|
|
261
261
|
let s = U(k);
|
|
@@ -268,6 +268,6 @@ var Ot = /* @__PURE__ */ c(async (n, r) => {
|
|
|
268
268
|
];
|
|
269
269
|
}, "staticDirs");
|
|
270
270
|
export {
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
Oe as experimental_serverChannel,
|
|
272
|
+
we as staticDirs
|
|
273
273
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-vitest",
|
|
3
|
-
"version": "0.0.0-pr-31819-sha-
|
|
3
|
+
"version": "0.0.0-pr-31819-sha-36ca675c",
|
|
4
4
|
"description": "Storybook addon for testing components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook-addons",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"peerDependencies": {
|
|
101
101
|
"@vitest/browser": "^3.0.0",
|
|
102
102
|
"@vitest/runner": "^3.0.0",
|
|
103
|
-
"storybook": "^0.0.0-pr-31819-sha-
|
|
103
|
+
"storybook": "^0.0.0-pr-31819-sha-36ca675c",
|
|
104
104
|
"vitest": "^3.0.0"
|
|
105
105
|
},
|
|
106
106
|
"peerDependenciesMeta": {
|