Skip to content

Commit 12ec028

Browse files
feat: add ability to disable storybook globals with null
1 parent 1ba50d6 commit 12ec028

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/storybook/story-test-runner/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ function createTestplaneTests(
2727
story.autoScreenshotStorybookGlobals,
2828
autoScreenshotStorybookGlobals,
2929
);
30-
const screenshotGlobalSetNames = Object.keys(rawAutoScreenshotGlobalSets);
30+
31+
const screenshotGlobalSetNames = Object.keys(rawAutoScreenshotGlobalSets).filter(name =>
32+
Boolean(rawAutoScreenshotGlobalSets[name]),
33+
);
3134

3235
const autoScreenshotGlobalSets = screenshotGlobalSetNames.length
3336
? screenshotGlobalSetNames.map(name => ({ name, globals: rawAutoScreenshotGlobalSets[name] }))
@@ -41,7 +44,7 @@ function createTestplaneTests(
4144
async function (ctx: TestFunctionExtendedCtx) {
4245
ctx.expect = globalThis.expect;
4346

44-
const result = await openStoryStep(ctx.browser, story, globals);
47+
const result = await openStoryStep(ctx.browser, story, globals as Record<string, unknown>);
4548
const selector = story.autoscreenshotSelector || autoscreenshotSelector || result.rootSelector;
4649

4750
await autoScreenshotStep(ctx.browser, selector);

src/storybook/story-test-runner/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { TestplaneTestFunction } from "../../types";
33
import type { StorybookStoryExtended as StorybookStory } from "../get-stories";
44
import type { Inheritable } from "./inheritable-values";
55

6-
export type AutoScreenshotStorybookGlobals = Record<string, Record<string, unknown>>;
6+
export type AutoScreenshotStorybookGlobals = Record<string, null | Record<string, unknown>>;
77

88
export interface StorybookStoryExtraProperties {
99
skip: boolean;

0 commit comments

Comments
 (0)