-
Notifications
You must be signed in to change notification settings - Fork 74
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
[Feature] Allow preventing smoke-tests on particular stories #74
Comments
I have another use case for needing to prevent test-runner from executing a particular story. This time, it's because of my |
Here's another situation where I need to disable a particular test. I have a story which sets a narrow viewport, which exposes a mobile menu button, which I use the play function to click on, and then I snapshot the result with chromatic. However, this doesn't work in the test runner, because there's no way to set the viewport size. (#85). Since I also can't disable the test-runner, I think I'll just need to weaken my |
I'd also love to be able to easily opt-out stories from test-runner as well, and I like the use of a parameter similar to how Storyshots allows this via I did find a way to achieve just that via a custom decorator. Add this decorator to your DisableTestRunnerDecorator: DecoratorFn = (Story, { parameters }) => {
if (parameters.testRunner?.disable === true && navigator.userAgent === 'Storybook Test Runner') {
return <>Disabled for Test Runner</>;
}
return <Story />;
};
export const decorators: DecoratorFn[] = [
DisableTestRunnerDecorator,
// any other decorators you might have
]; Then (use const { getJestConfig } = require('@storybook/test-runner');
// The default configuration comes from @storybook/test-runner
const defaultConfig = getJestConfig()
module.exports = {
...defaultConfig,
/** Add your own overrides below
* @see https://jestjs.io/docs/configuration
*/
testEnvironmentOptions: {
'jest-playwright': {
...defaultConfig['jest-playwright'],
contextOptions: {
userAgent: 'Storybook Test Runner',
}
}
}
}; |
What about skipping the render if the My use case is to exclude stories that have |
@FokkeZB in Storybook v7 it seems the condition has changed for the if (parameters.testRunner?.disable === true && navigator.userAgent.includes('StorybookTestRunner')) {
return <>Disabled for Test Runner</>;
} _(the user agent sent is now @yannbf any plan for this officially? |
Ran into this today, it'd be nice to be able to easily skip our error boundary test without a custom decorator. |
Our error boundary component is exactly why I want to be able to skip a story as well. It throws up the webpack veil locally. |
Hey everyone! We just released a test filtering feature in the test-runner v0.15.0, which you can read here. Please try it out and provide feedback! Thank you! |
Describe the Feature
I have a
Themed
story in many of my stories files which simply renders other stories together in a "light mode" and "dark mode". If I'm testing each of those other stories, then I would like to save the time and prevent myThemed
stories from being smoke-tested. As far as I know, there's no way to do this currently.One approach might be to add a parameter, like
If this approach was taken, it might also be a way to set the
it
description of the test (see #71), even though it's a little clunky. In addition, maybe it would be a cool way to add setup/teardown hooks for a particular story. Even though I haven't found that I need those so far, but I think that's because each test is a fresh page load. Which is great for isolation, but definitely slows things down. And the individual stories themselves are not new page loads, so there could need to be setup/teardown between them. But that's probably a separate issue.The text was updated successfully, but these errors were encountered: