@cappa/plugin-storybook 0.1.2 → 0.2.0

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.
@@ -1,18 +1,18 @@
1
1
 
2
2
 
3
- > @cappa/plugin-storybook@0.1.1 build /home/tim/cappa/packages/plugins/plugin-storybook
3
+ > @cappa/plugin-storybook@0.2.0 build /home/tim/cappa/packages/plugins/plugin-storybook
4
4
  > tsup
5
5
 
6
6
  CLI Building entry: src/index.ts
7
- CLI Using tsconfig: ../../../tsconfig.json
7
+ CLI Using tsconfig: tsconfig.json
8
8
  CLI tsup v8.5.0
9
9
  CLI Using tsup config: /home/tim/cappa/packages/plugins/plugin-storybook/tsup.config.ts
10
10
  CLI Building entry: src/storybook/addon/preview.ts
11
- CLI Using tsconfig: ../../../tsconfig.json
11
+ CLI Using tsconfig: tsconfig.json
12
12
  CLI tsup v8.5.0
13
13
  CLI Using tsup config: /home/tim/cappa/packages/plugins/plugin-storybook/tsup.config.ts
14
14
  CLI Building entry: src/storybook/addon/browser.ts
15
- CLI Using tsconfig: ../../../tsconfig.json
15
+ CLI Using tsconfig: tsconfig.json
16
16
  CLI tsup v8.5.0
17
17
  CLI Using tsup config: /home/tim/cappa/packages/plugins/plugin-storybook/tsup.config.ts
18
18
  CLI Target: esnext
@@ -26,14 +26,14 @@
26
26
  CLI Cleaning output folder
27
27
  ESM Build start
28
28
  ESM dist/browser.mjs 138.00 B
29
- ESM ⚡️ Build success in 8ms
30
- ESM dist/preview.mjs 1.34 KB
31
29
  ESM ⚡️ Build success in 10ms
32
- ESM dist/index.mjs 9.40 KB
33
- ESM ⚡️ Build success in 14ms
34
- CJS dist/index.js 10.79 KB
35
- CJS ⚡️ Build success in 15ms
30
+ ESM dist/preview.mjs 1.35 KB
31
+ ESM ⚡️ Build success in 11ms
32
+ ESM dist/index.mjs 11.00 KB
33
+ ESM ⚡️ Build success in 16ms
34
+ CJS dist/index.js 12.33 KB
35
+ CJS ⚡️ Build success in 16ms
36
36
  DTS Build start
37
- DTS ⚡️ Build success in 937ms
38
- DTS dist/index.d.ts 593.00 B
39
- DTS dist/index.d.mts 593.00 B
37
+ DTS ⚡️ Build success in 1283ms
38
+ DTS dist/index.d.ts 905.00 B
39
+ DTS dist/index.d.mts 905.00 B
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @cappa/plugin-storybook
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5b1f66f: Add support for capturing screenshot variants and configure Storybook stories to request multiple viewport screenshots.
8
+ - 4cd0ee2: Allow configuring Storybook args and globals for captured screenshots.
9
+
10
+ ### Patch Changes
11
+
12
+ - a1d91c6: feat: add viewport options
13
+ - Updated dependencies [5b1f66f]
14
+ - Updated dependencies [87c8ab9]
15
+ - Updated dependencies [a1d91c6]
16
+ - Updated dependencies [88b3648]
17
+ - @cappa/core@0.2.0
18
+
19
+ ## 0.1.3
20
+
21
+ ### Patch Changes
22
+
23
+ - f6456fb: feat: add retry functionality
24
+ - Updated dependencies [f6456fb]
25
+ - @cappa/core@0.1.3
26
+ - @cappa/logger@0.0.3
27
+
3
28
  ## 0.1.2
4
29
 
5
30
  ### Patch Changes
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Tim Richter
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,94 +2,4 @@
2
2
 
3
3
  This plugin allows to take screenshots of Storybook stories with Cappa.
4
4
 
5
- ## Install
6
-
7
- ```bash
8
- pnpm add -D @cappa/plugin-storybook
9
- ```
10
-
11
- ## Usage
12
-
13
- Add the plugin to your cappa config:
14
-
15
- ```ts
16
- import { defineConfig } from "@cappa/core";
17
- import { cappaPluginStorybook } from "@cappa/plugin-storybook";
18
-
19
- export default defineConfig({
20
- plugins: [cappaPluginStorybook({ storybookUrl: "http://localhost:8080" })],
21
- });
22
- ```
23
-
24
- > Make sure to have a running Storybook server on the given url.
25
-
26
- Add the plugin to your storybook config:
27
-
28
- ```ts
29
- const config: StorybookConfig = {
30
- addons: ["@cappa/plugin-storybook"],
31
- };
32
- ```
33
-
34
- Run cappa cli in the directory of your cappa config:
35
-
36
- ```bash
37
- cappa
38
- ```
39
-
40
- ## Options
41
-
42
- ## Storybook options
43
-
44
- Cappa uses a storybook addon that allows you to pass options from storybook into cappa.
45
-
46
- ### Parameters
47
-
48
- | Option | Description | Default |
49
- | -------- | ----------------------------------------------- | --------------- |
50
- | skip | Whether to skip the screenshot | false |
51
- | delay | The delay to wait before taking the screenshot | null (no delay) |
52
- | fullPage | Whether to take a full page screenshot | true |
53
- | mask | An array of selectors to mask in the screenshot | [] |
54
- | omitBackground | Whether to omit the background in the screenshot | false |
55
-
56
- #### Example
57
-
58
- ```ts
59
- export const Primary: Story = {
60
- parameters: {
61
- cappa: {
62
- skip: true,
63
- delay: 1000,
64
- fullPage: false,
65
- mask: ["#my-element", ".my-class"],
66
- },
67
- },
68
- };
69
- ```
70
-
71
- ## Flakiness
72
-
73
- To avoid flakiness, cappa disables css animations and transitions by default. For additional use cases or animation libraries, you can use the `isCappa` function to check if the current window is a cappa window. You can use it inside of your storybook preview file (`.storybook/preview.ts`):
74
-
75
- ```ts
76
- import { isCappa } from '@cappa/plugin-storybook/browser';
77
-
78
- if (isCappa()) {
79
- import("disable-animations.css");
80
- MotionGlobalConfig.disableAnimations = true;
81
- }
82
- ```
83
-
84
- ### DOM Mutations
85
-
86
- Cappa waits for DOM mutations to be idle before taking the screenshot. It does so by querying the DOM for mutations and waiting for a certain amount of time to pass, until the page is considered idle.
87
-
88
- ### Fonts & Images
89
-
90
- Cappa waits for fonts and images to be loaded before taking the screenshot.
91
-
92
- ### SVG's
93
-
94
- Cappa sets global css styles to render svg images more consistently. You might experience
95
- differences between actual browsers and cappa screenshots, but that is expected and wanted behavior, since browsers tend to render svg images differently.
5
+ For documentation, see the [Storybook Plugin documentation](https://tim-richter.github.io/cappa/storybook).
package/dist/index.d.mts CHANGED
@@ -1,5 +1,14 @@
1
1
  import { Plugin } from '@cappa/core';
2
2
 
3
+ interface StorybookRenderOptions {
4
+ viewMode?: "story" | "docs";
5
+ args?: Record<string, unknown>;
6
+ globals?: Record<string, string | number | boolean>;
7
+ query?: Record<string, string | number | boolean>;
8
+ fullscreen?: boolean;
9
+ singleStory?: boolean;
10
+ }
11
+
3
12
  interface StorybookPluginOptions {
4
13
  storybookUrl: string;
5
14
  includeStories?: string[];
@@ -10,6 +19,7 @@ interface StorybookPluginOptions {
10
19
  };
11
20
  waitForSelector?: string;
12
21
  waitForTimeout?: number;
22
+ storybook?: StorybookRenderOptions;
13
23
  }
14
24
  /**
15
25
  * Storybook Plugin for Cappa
package/dist/index.d.ts CHANGED
@@ -1,5 +1,14 @@
1
1
  import { Plugin } from '@cappa/core';
2
2
 
3
+ interface StorybookRenderOptions {
4
+ viewMode?: "story" | "docs";
5
+ args?: Record<string, unknown>;
6
+ globals?: Record<string, string | number | boolean>;
7
+ query?: Record<string, string | number | boolean>;
8
+ fullscreen?: boolean;
9
+ singleStory?: boolean;
10
+ }
11
+
3
12
  interface StorybookPluginOptions {
4
13
  storybookUrl: string;
5
14
  includeStories?: string[];
@@ -10,6 +19,7 @@ interface StorybookPluginOptions {
10
19
  };
11
20
  waitForSelector?: string;
12
21
  waitForTimeout?: number;
22
+ storybook?: StorybookRenderOptions;
13
23
  }
14
24
  /**
15
25
  * Storybook Plugin for Cappa
package/dist/index.js CHANGED
@@ -37,7 +37,42 @@ module.exports = __toCommonJS(index_exports);
37
37
 
38
38
  // src/cappa/plugin.ts
39
39
  var import_logger = require("@cappa/logger");
40
- var import_chalk = __toESM(require("chalk"));
40
+
41
+ // src/cappa/storybook-url.ts
42
+ function encodePairs(obj) {
43
+ if (!obj || !Object.keys(obj).length) return "";
44
+ return Object.entries(obj).filter(([, v]) => v !== void 0).map(([k, v]) => {
45
+ const val = typeof v === "string" ? encodeURIComponent(v) : typeof v === "number" || typeof v === "boolean" ? String(v) : encodeURIComponent(JSON.stringify(v));
46
+ return `${encodeURIComponent(k)}:${val}`;
47
+ }).join(";");
48
+ }
49
+ function buildStorybookIframeUrl({
50
+ baseUrl,
51
+ storyId,
52
+ viewMode = "story",
53
+ args,
54
+ globals,
55
+ query,
56
+ fullscreen = true,
57
+ singleStory = true
58
+ }) {
59
+ const u = new URL("/iframe.html", baseUrl);
60
+ u.searchParams.set("id", storyId);
61
+ u.searchParams.set("viewMode", viewMode);
62
+ const argPairs = encodePairs(args);
63
+ if (argPairs) u.searchParams.set("args", argPairs);
64
+ const globalPairs = encodePairs(globals);
65
+ if (globalPairs) u.searchParams.set("globals", globalPairs);
66
+ if (fullscreen) u.searchParams.set("full", "1");
67
+ if (singleStory) u.searchParams.set("singleStory", "true");
68
+ if (query) {
69
+ for (const [k, v] of Object.entries(query)) {
70
+ if (v === void 0) continue;
71
+ u.searchParams.set(k, String(v));
72
+ }
73
+ }
74
+ return u.toString();
75
+ }
41
76
 
42
77
  // src/cappa/util.ts
43
78
  var freezeUI = async (page) => {
@@ -123,8 +158,7 @@ var cappaPluginStorybook = (options) => {
123
158
  return {
124
159
  name: "StorybookPlugin",
125
160
  description: "Takes screenshots of Storybook stories with configurable options",
126
- version: "1.0.0",
127
- execute: async (screenshotTool) => {
161
+ discover: async () => {
128
162
  if (!options) {
129
163
  throw new Error("Storybook plugin options are required");
130
164
  }
@@ -135,7 +169,8 @@ var cappaPluginStorybook = (options) => {
135
169
  const {
136
170
  storybookUrl,
137
171
  includeStories = [],
138
- excludeStories = []
172
+ excludeStories = [],
173
+ storybook: defaultStorybookOptions
139
174
  } = options;
140
175
  const storiesUrl = `${storybookUrl}/index.json`;
141
176
  logger.debug(`Fetching stories from: ${storiesUrl}`);
@@ -145,159 +180,170 @@ var cappaPluginStorybook = (options) => {
145
180
  `Failed to fetch stories: ${response.status} ${response.statusText}`
146
181
  );
147
182
  }
148
- try {
149
- const data = await response.json();
150
- const stories = Object.values(data.entries);
151
- let filteredStories = stories;
152
- if (includeStories.length > 0) {
153
- filteredStories = filteredStories.filter(
154
- (story) => includeStories.some(
155
- (pattern) => story.title.includes(pattern) || story.name.includes(pattern)
156
- )
157
- );
158
- }
159
- if (excludeStories.length > 0) {
160
- filteredStories = filteredStories.filter(
161
- (story) => !excludeStories.some(
162
- (pattern) => story.title.includes(pattern) || story.name.includes(pattern)
163
- )
164
- );
165
- }
183
+ const data = await response.json();
184
+ const stories = Object.values(data.entries);
185
+ let filteredStories = stories;
186
+ if (includeStories.length > 0) {
166
187
  filteredStories = filteredStories.filter(
167
- (story) => story.type === "story"
188
+ (story) => includeStories.some(
189
+ (pattern) => story.title.includes(pattern) || story.name.includes(pattern)
190
+ )
168
191
  );
169
- logger.start(
170
- `Found ${filteredStories.length} stories to screenshot...`
171
- );
172
- const results = [];
173
- await screenshotTool.init();
174
- let currentLatch = createLatch();
175
- await screenshotTool.page?.exposeFunction(
176
- "__cappa_parameters",
177
- async (payload) => {
178
- currentLatch.resolve(payload);
179
- }
192
+ }
193
+ if (excludeStories.length > 0) {
194
+ filteredStories = filteredStories.filter(
195
+ (story) => !excludeStories.some(
196
+ (pattern) => story.title.includes(pattern) || story.name.includes(pattern)
197
+ )
180
198
  );
181
- for (const story of filteredStories) {
182
- try {
183
- const storyUrl = `${storybookUrl}/iframe.html?id=${story.id}&viewMode=story`;
184
- const page = screenshotTool.page;
185
- if (!page) {
186
- throw new Error("Page not initialized");
187
- }
188
- page.on("console", (message) => {
189
- logger.debug("console", message.text());
190
- });
191
- page.on("pageerror", (error) => {
192
- logger.debug("pageerror", error);
193
- });
194
- await page.goto(storyUrl);
195
- const options2 = await currentLatch.p;
196
- currentLatch = createLatch();
197
- if (options2.skip) {
198
- logger.warn(`Skipping story ${story.title} - ${story.name}`);
199
- results.push({
200
- storyId: story.id,
201
- storyName: `${story.title} - ${story.name}`,
202
- skipped: true
203
- });
204
- continue;
205
- }
206
- if (options2 && Object.keys(options2).length > 0) {
207
- logger.debug("Taking screenshot with options", options2);
208
- }
209
- await freezeUI(page);
210
- await waitForVisualIdle(page);
211
- if (options2.delay) {
212
- await page.waitForTimeout(options2.delay);
213
- }
214
- const filename = buildFilename(story);
215
- const expectedExists = screenshotTool.hasExpectedImage(filename);
216
- let actualFilepath;
217
- if (expectedExists) {
218
- const { screenshotPath, comparisonResult } = await screenshotTool.takeScreenshotWithComparison(
219
- page,
220
- filename,
221
- screenshotTool.getExpectedImageBuffer(filename),
222
- {
223
- fullPage: options2.fullPage,
224
- mask: options2.mask?.map(
225
- (selector) => page.locator(selector)
226
- ),
227
- omitBackground: options2.omitBackground,
228
- saveDiffImage: true
229
- }
230
- );
231
- actualFilepath = screenshotPath;
232
- results.push({
233
- storyId: story.id,
234
- storyName: `${story.title} - ${story.name}`,
235
- filepath: actualFilepath,
236
- success: comparisonResult.passed
237
- });
238
- } else {
239
- logger.info(
240
- `Expected image not found for story ${story.title} - ${story.name}, taking screenshot`
241
- );
242
- actualFilepath = await screenshotTool.takeScreenshot(
243
- page,
244
- filename,
245
- {
246
- fullPage: options2.fullPage,
247
- mask: options2.mask?.map((selector) => page.locator(selector)),
248
- omitBackground: options2.omitBackground
249
- }
250
- );
251
- results.push({
252
- storyId: story.id,
253
- storyName: `${story.title} - ${story.name}`,
254
- filepath: actualFilepath,
255
- success: true
256
- });
199
+ }
200
+ filteredStories = filteredStories.filter(
201
+ (story) => story.type === "story"
202
+ );
203
+ logger.start(`Found ${filteredStories.length} stories to screenshot...`);
204
+ return filteredStories.map((story) => ({
205
+ id: story.id,
206
+ url: buildStorybookIframeUrl({
207
+ baseUrl: storybookUrl,
208
+ storyId: story.id,
209
+ viewMode: defaultStorybookOptions?.viewMode,
210
+ args: defaultStorybookOptions?.args,
211
+ globals: defaultStorybookOptions?.globals,
212
+ query: defaultStorybookOptions?.query,
213
+ fullscreen: defaultStorybookOptions?.fullscreen,
214
+ singleStory: defaultStorybookOptions?.singleStory
215
+ }),
216
+ data: {
217
+ story
218
+ }
219
+ }));
220
+ },
221
+ initPage: async () => {
222
+ return {
223
+ latchMap: /* @__PURE__ */ new Map()
224
+ };
225
+ },
226
+ // Phase 2: Execute single story
227
+ execute: async (task, page, screenshotTool, context) => {
228
+ const { url, data } = task;
229
+ const { story } = data;
230
+ const logger = (0, import_logger.getLogger)();
231
+ try {
232
+ const currentLatch = createLatch();
233
+ context.latchMap.set(story.id, currentLatch);
234
+ if (await page.evaluate(() => {
235
+ return window.__cappa_parameters === void 0;
236
+ })) {
237
+ await page.exposeFunction(
238
+ "__cappa_parameters",
239
+ async (id, payload) => {
240
+ context.latchMap.get(id)?.resolve?.(payload);
257
241
  }
258
- } catch (error) {
259
- logger.error(
260
- `Error taking screenshot of story ${story.title} - ${story.name}:`,
261
- error.message
262
- );
263
- results.push({
264
- storyId: story.id,
265
- storyName: `${story.title} - ${story.name}`,
266
- error: error?.message ?? "Unknown error"
267
- });
268
- }
242
+ );
243
+ }
244
+ page.on("console", (message) => {
245
+ logger.debug("console", message.text());
246
+ });
247
+ page.on("pageerror", (error) => {
248
+ logger.debug("pageerror", error);
249
+ });
250
+ await page.goto(url);
251
+ const storyParameters = await context.latchMap.get(story.id)?.p;
252
+ context.latchMap.delete(story.id);
253
+ const variantParameters = storyParameters?.variants ?? [];
254
+ if (storyParameters?.skip) {
255
+ logger.warn(`Skipping story ${story.title} - ${story.name}`);
256
+ return {
257
+ storyId: story.id,
258
+ storyName: `${story.title} - ${story.name}`,
259
+ skipped: true
260
+ };
261
+ }
262
+ if (storyParameters && Object.keys(storyParameters).length > 0) {
263
+ logger.debug("Taking screenshot with options", storyParameters);
269
264
  }
270
- if (results.some((r) => r.error)) {
271
- logger.error(
272
- `Error report:
273
- ${results.filter((r) => r.error).map((r) => `${r.storyName}: ${r.error}`).join("\n")}`
265
+ const resolvedViewport = storyParameters?.viewport ?? screenshotTool.viewport;
266
+ await page.setViewportSize(resolvedViewport);
267
+ await freezeUI(page);
268
+ await waitForVisualIdle(page);
269
+ const toLocatorMask = (mask) => mask?.map((selector) => page.locator(selector));
270
+ const screenshotVariants = variantParameters.map(
271
+ (variant) => ({
272
+ id: variant.id,
273
+ label: variant.label,
274
+ filename: variant.filename,
275
+ options: variant.options ? {
276
+ ...variant.options,
277
+ mask: toLocatorMask(variant.options.mask)
278
+ } : void 0
279
+ })
280
+ );
281
+ const screenshotOptions = {
282
+ fullPage: storyParameters?.fullPage,
283
+ delay: storyParameters?.delay,
284
+ omitBackground: storyParameters?.omitBackground,
285
+ skip: storyParameters?.skip,
286
+ viewport: storyParameters?.viewport ?? screenshotTool.viewport,
287
+ mask: toLocatorMask(storyParameters?.mask),
288
+ variants: screenshotVariants.length ? screenshotVariants : void 0
289
+ };
290
+ const filename = buildFilename(story);
291
+ const expectedExists = screenshotTool.filesystem.hasExpectedFile(filename);
292
+ if (!expectedExists) {
293
+ logger.info(
294
+ `Expected image not found for story ${story.title} - ${story.name}, taking screenshot`
274
295
  );
275
296
  }
276
- if (results.some((r) => r.skipped)) {
277
- logger.warn(
278
- `Skipped stories:
279
- ${results.filter((r) => r.skipped).map((r) => `${r.storyName}`).join("\n")}`
297
+ const variantFilenameMap = /* @__PURE__ */ new Map();
298
+ for (const variant of screenshotVariants) {
299
+ const variantFilename = screenshotTool.getVariantFilename(
300
+ filename,
301
+ variant
280
302
  );
303
+ variantFilenameMap.set(variant.id, variantFilename);
304
+ if (!screenshotTool.filesystem.hasExpectedFile(variantFilename)) {
305
+ logger.info(
306
+ `Expected image not found for variant ${story.title} - ${story.name} [${variant.label ?? variant.id}], taking screenshot`
307
+ );
308
+ }
281
309
  }
282
- const skipped = results.filter((r) => r.skipped);
283
- const failed = results.filter(
284
- (r) => r.error || !r.skipped && !r.success
310
+ const variantExtrasEntries = screenshotVariants.map(
311
+ (variant) => [
312
+ variant.id,
313
+ {
314
+ saveDiffImage: true,
315
+ diffImageFilename: variantFilenameMap.get(variant.id) ?? filename
316
+ }
317
+ ]
285
318
  );
286
- const successful = results.filter((r) => r.success);
287
- const output = [
288
- `${import_chalk.default.yellow("Skipped stories:")} ${skipped.length}`,
289
- `${import_chalk.default.red("Failed stories:")} ${failed.length}`,
290
- `${import_chalk.default.green("Successful stories:")} ${successful.length}`,
291
- `${import_chalk.default.blue("Total stories:")} ${results.length}`
292
- ];
293
- logger.box({
294
- title: "Storybook Report",
295
- message: output.join("\n")
296
- });
297
- return results;
319
+ const captureExtras = {
320
+ saveDiffImage: true,
321
+ diffImageFilename: filename,
322
+ variants: variantExtrasEntries.length ? Object.fromEntries(variantExtrasEntries) : void 0
323
+ };
324
+ const captureResult = await screenshotTool.capture(
325
+ page,
326
+ filename,
327
+ screenshotOptions,
328
+ captureExtras
329
+ );
330
+ return {
331
+ storyId: story.id,
332
+ storyName: `${story.title} - ${story.name}`,
333
+ filepath: captureResult.base.filepath,
334
+ success: captureResult.base.skipped ? void 0 : captureResult.base.comparisonResult ? captureResult.base.comparisonResult.passed : Boolean(captureResult.base.filepath),
335
+ skipped: captureResult.base.skipped
336
+ };
298
337
  } catch (error) {
299
- logger.error("Error in Storybook plugin:", error.message);
300
- throw error;
338
+ logger.error(
339
+ `Error taking screenshot of story ${story.title} - ${story.name}:`,
340
+ error.message
341
+ );
342
+ return {
343
+ storyId: story.id,
344
+ storyName: `${story.title} - ${story.name}`,
345
+ error: error?.message ?? "Unknown error"
346
+ };
301
347
  }
302
348
  }
303
349
  };