Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: Use !test tag to disable test-runner tests #28747

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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