@cappa/plugin-storybook 0.0.17 → 0.0.18
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/CHANGELOG.md +8 -0
- package/package.json +2 -2
- package/src/cappa/plugin.ts +21 -5
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cappa/plugin-storybook",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "Storybook plugin for Cappa - takes screenshots of Storybook stories",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@swc/core": "^1.13.5",
|
|
32
32
|
"storybook": "^9.1.5",
|
|
33
|
-
"@cappa/core": "0.0.
|
|
33
|
+
"@cappa/core": "0.0.18"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"playwright-core": "^1.55.0",
|
package/src/cappa/plugin.ts
CHANGED
|
@@ -111,9 +111,10 @@ export const cappaPluginStorybook: Plugin<StorybookPluginOptions> = (
|
|
|
111
111
|
const results: Array<{
|
|
112
112
|
storyId: string;
|
|
113
113
|
storyName: string;
|
|
114
|
-
success: boolean;
|
|
115
114
|
filepath?: string;
|
|
115
|
+
success?: boolean;
|
|
116
116
|
error?: string;
|
|
117
|
+
skipped?: boolean;
|
|
117
118
|
}> = [];
|
|
118
119
|
|
|
119
120
|
await screenshotTool.init();
|
|
@@ -161,6 +162,12 @@ export const cappaPluginStorybook: Plugin<StorybookPluginOptions> = (
|
|
|
161
162
|
|
|
162
163
|
if (options.skip) {
|
|
163
164
|
console.log(`Skipping story ${story.title} - ${story.name}`);
|
|
165
|
+
results.push({
|
|
166
|
+
storyId: story.id,
|
|
167
|
+
storyName: `${story.title} - ${story.name}`,
|
|
168
|
+
skipped: true,
|
|
169
|
+
});
|
|
170
|
+
continue;
|
|
164
171
|
}
|
|
165
172
|
|
|
166
173
|
await freezeUI(page);
|
|
@@ -190,8 +197,8 @@ export const cappaPluginStorybook: Plugin<StorybookPluginOptions> = (
|
|
|
190
197
|
results.push({
|
|
191
198
|
storyId: story.id,
|
|
192
199
|
storyName: `${story.title} - ${story.name}`,
|
|
193
|
-
success: true,
|
|
194
200
|
filepath: actualFilepath,
|
|
201
|
+
success: true,
|
|
195
202
|
});
|
|
196
203
|
} catch (error) {
|
|
197
204
|
console.error(
|
|
@@ -201,22 +208,31 @@ export const cappaPluginStorybook: Plugin<StorybookPluginOptions> = (
|
|
|
201
208
|
results.push({
|
|
202
209
|
storyId: story.id,
|
|
203
210
|
storyName: `${story.title} - ${story.name}`,
|
|
204
|
-
success: false,
|
|
205
211
|
error: (error as Error)?.message ?? "Unknown error",
|
|
206
212
|
});
|
|
207
213
|
}
|
|
208
214
|
}
|
|
209
215
|
|
|
210
216
|
// Print error report if there are any errors
|
|
211
|
-
if (results.some((r) =>
|
|
217
|
+
if (results.some((r) => r.error)) {
|
|
212
218
|
console.log(
|
|
213
219
|
`Error report: \n${results
|
|
214
|
-
.filter((r) =>
|
|
220
|
+
.filter((r) => r.error)
|
|
215
221
|
.map((r) => `${r.storyName}: ${r.error}`)
|
|
216
222
|
.join("\n")}`,
|
|
217
223
|
);
|
|
218
224
|
}
|
|
219
225
|
|
|
226
|
+
// Print skipped stories if there are any
|
|
227
|
+
if (results.some((r) => r.skipped)) {
|
|
228
|
+
console.log(
|
|
229
|
+
`Skipped stories: \n${results
|
|
230
|
+
.filter((r) => r.skipped)
|
|
231
|
+
.map((r) => `${r.storyName}`)
|
|
232
|
+
.join("\n")}`,
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
220
236
|
console.log(
|
|
221
237
|
`Completed screenshots: ${results.filter((r) => r.success).length}/${results.length} successful`,
|
|
222
238
|
);
|