Skip to content

Commit 1c49e37

Browse files
authored
Merge pull request #2609 from saucelabs/feat/storybook-doc-updates
Update Sauce Visual Storybook integration Docs
2 parents 812928b + 6a2a749 commit 1c49e37

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

docs/visual-testing/integrations/storybook.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,40 @@ Below are the environment variables available in the visual-storybook plugin:
140140
| `SAUCE_PROJECT_NAME` | | The label / project you would like to associated this build with. |
141141
| `SAUCE_VISUAL_BUILD_ID` | | For advanced users, a custom build ID. Can be used to create builds in advance. This can be used to parallelize tests, shard, or more. <br/> By default, this is not set and we create / finish a build during setup / teardown. |
142142

143+
## Story / Global Configuration
144+
145+
Additional configuration options are exposed via the `sauceVisual` [Storybook parameters](https://storybook.js.org/docs/writing-stories/parameters). You can use these to tweak settings on a global, component, or per-story basis -- see the Storybook docs for details on how to apply them to each.
146+
147+
The below configuration options are also exported as the type `SauceVisualParams` from `@saucelabs/visual-storybook` if you'd like TypeScript types for them.
148+
149+
Parameters key: `sauceVisual`
150+
151+
| Key | Type | Default | Description |
152+
|----------------|-----------|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
153+
| `clip` | `boolean` | `true` | If the story & layout supports it, will automatically clip to the `clipSelector` to remove extraneous whitespace. Recommended to be used in conjunction with [`centered` layout](https://storybook.js.org/docs/configure/story-layout#global-layout). Currently defaults to `false`, however, will default to `true` in a future version. |
154+
| `clipSelector` | `string` | `#storybook-root` | The selector to clip to when `clip = true`. Defaults to Storybook's default root element, `#storybook-root`. |
155+
| `delay` | `number` | `0` (no delay) | A number, in ms, that we should delay the snapshot by. Useful if the beginning of the story has unavoidable / javascript animations. |
156+
157+
Component-level Example:
158+
159+
```jsx
160+
const meta = {
161+
title: 'Example/Button',
162+
component: Button,
163+
parameters: {
164+
// ... Your other Storybook parameters here
165+
sauceVisual: {
166+
// Add storybook visual configuration options here
167+
clip: true,
168+
// clipSelector: '#custom-root-element',
169+
// delay: 200,
170+
},
171+
},
172+
};
173+
174+
export default meta;
175+
```
176+
143177
## Different Browsers and Devices
144178

145179
By default the tests are run on your local machine/in your pipeline with Chromium. You have the option to run them on different [browser and device configurations](https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/deviceDescriptorsSource.json) preconfigured by playwright or define your own device, a combination or all of them. To do so, you need to add the following to your `test-runner-jest.config.js` file:
@@ -177,3 +211,11 @@ module.exports = {
177211
```
178212
179213
If you'd like to configure your own devices, please follow the configuration steps inside the [playwright docs](https://playwright.dev/docs/emulation#devices).
214+
215+
## Auto Testing Variations
216+
217+
<div className="text--center">
218+
<img src={useBaseUrl('/img/sauce-visual/visual-variants.png')} alt="Visual variant grid example"/>
219+
</div>
220+
221+
We have a separate Storybook plugin, `@saucelabs/storybook-variants`, available for rendering all variants of a component in a grid to ease the testing and development process. Read the full [README on NPM](https://www.npmjs.com/package/@saucelabs/storybook-variants) for installation & usage.
29.9 KB
Loading

0 commit comments

Comments
 (0)