Skip to content

Commit

Permalink
Build: Use !test tag to disable test-runner tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Jul 29, 2024
1 parent df101c4 commit 04c4751
Show file tree
Hide file tree
Showing 15 changed files with 16 additions and 24 deletions.
7 changes: 2 additions & 5 deletions code/addons/docs/template/stories/docspage/error.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { global as globalThis } from '@storybook/global';

export default {
component: globalThis.Components.Button,
tags: ['autodocs'],
tags: ['autodocs', '!test'],
args: { label: 'Click Me!' },
parameters: { chromatic: { disable: true } },
};
Expand All @@ -12,10 +12,7 @@ export default {
*/
export const ErrorStory = {
decorators: [
(storyFn) => {
// Don't throw in the test runner; there's no easy way to skip (yet)
if (window?.navigator?.userAgent?.match(/StorybookTestRunner/)) return storyFn();

() => {
throw new Error('Story did something wrong');
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default {
actions: { argTypesRegex: '^on[A-Z].*' },
chromatic: { disable: true },
},
tags: ['test-skip'],
tags: ['!test'],
};

export const Default = {
Expand Down
4 changes: 1 addition & 3 deletions code/core/template/stories/rendering.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ export const ForceRemount = {
*/
parameters: { chromatic: { disableSnapshot: true } },
play: async ({ canvasElement, id }: PlayFunctionContext<any>) => {
if (window?.navigator.userAgent.match(/StorybookTestRunner/)) {
return;
}
const channel = globalThis.__STORYBOOK_ADDONS_CHANNEL__;
const button = await within(canvasElement).findByRole('button');

Expand All @@ -39,6 +36,7 @@ export const ForceRemount = {
// By forcing the component to remount, we reset the focus state
await channel.emit(FORCE_REMOUNT, { storyId: id });
},
tags: ['!test'],
};

export const ChangeArgs = {
Expand Down
4 changes: 2 additions & 2 deletions code/frameworks/nextjs/template/stories/RSC.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ export default {
export const Default = {};

export const DisableRSC = {
tags: ['test-skip'],
tags: ['!test'],
parameters: {
chromatic: { disable: true },
nextjs: { rsc: false },
},
};

export const Error = {
tags: ['test-skip'],
tags: ['!test'],
parameters: {
chromatic: { disable: true },
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default {
},
},
},
tags: ['!test'],
} as Meta;

export const SingletonStateGetsInvalidatedAfterRedirecting: StoryObj = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function Component() {

export default {
component: Component,
tags: ['test-skip'],
tags: ['!test'],
parameters: {
nextjs: {
appDirectory: true,
Expand Down
2 changes: 1 addition & 1 deletion code/lib/blocks/src/blocks/ArgTypes.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const OfUndefined: Story = {
of: ExampleStories.NotDefined,
},
parameters: { chromatic: { disableSnapshot: true } },
decorators: [(s) => (window?.navigator.userAgent.match(/StorybookTestRunner/) ? <div /> : s())],
tags: ['!test'],
};

export const OfStoryUnattached: Story = {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/blocks/src/blocks/Canvas.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const OfUndefined: Story = {
of: ButtonStories.NotDefined,
},
parameters: { chromatic: { disableSnapshot: true } },
decorators: [(s) => (window?.navigator.userAgent.match(/StorybookTestRunner/) ? <div /> : s())],
tags: ['!test'],
};

export const PropWithToolbar: Story = {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/blocks/src/blocks/Controls.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const OfUndefined: Story = {
of: ExampleStories.NotDefined,
},
parameters: { chromatic: { disableSnapshot: true } },
decorators: [(s) => (window?.navigator.userAgent.match(/StorybookTestRunner/) ? <div /> : s())],
tags: ['!test'],
};

export const IncludeProp: Story = {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/blocks/src/blocks/Description.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const OfUndefinedAttached: Story = {
relativeCsfPaths: ['../examples/Button.stories'],
attached: true,
},
decorators: [(s) => (window?.navigator.userAgent.match(/StorybookTestRunner/) ? <div /> : s())],
tags: ['!test'],
};
export const OfStringComponentAttached: Story = {
name: 'Of "component" Attached',
Expand Down
2 changes: 1 addition & 1 deletion code/lib/blocks/src/blocks/Source.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const OfUndefined: Story = {
of: ParametersStories.NotDefined,
},
parameters: { chromatic: { disableSnapshot: true } },
decorators: [(s) => (window?.navigator.userAgent.match(/StorybookTestRunner/) ? <div /> : s())],
tags: ['!test'],
};

export const OfTypeProp: Story = {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/blocks/src/blocks/Story.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const OfUndefined: Story = {
of: ButtonStories.NotDefined,
},
parameters: { chromatic: { disableSnapshot: true } },
decorators: [(s) => (window?.navigator.userAgent.match(/StorybookTestRunner/) ? <div /> : s())],
tags: ['!test'],
};

export const Inline: Story = {
Expand Down
2 changes: 1 addition & 1 deletion code/lib/blocks/src/blocks/Subtitle.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const OfUndefinedAttached: Story = {
relativeCsfPaths: ['../examples/Button.stories'],
attached: true,
},
decorators: [(s) => (window?.navigator.userAgent.match(/StorybookTestRunner/) ? <div /> : s())],
tags: ['!test'],
};
export const OfStringMetaAttached: Story = {
name: 'Of "meta" Attached',
Expand Down
5 changes: 1 addition & 4 deletions code/renderers/react/template/stories/errors.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ export default {
parameters: {
chromatic: { disable: true },
},
decorators: [
// Skip errors if we are running in the test runner
(storyFn: any) => window?.navigator?.userAgent?.match(/StorybookTestRunner/) || storyFn(),
],
tags: ['!test'],
};

export const RenderThrows = {
Expand Down
1 change: 0 additions & 1 deletion scripts/tasks/test-runner-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const testRunnerBuild: Task & { port: number } = {
'--junit',
'--maxWorkers=2',
'--failOnConsole',
'--skipTags="test-skip"',
'--index-json',
];

Expand Down

0 comments on commit 04c4751

Please sign in to comment.