You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/visual-testing/integrations/storybook.md
+42Lines changed: 42 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -140,6 +140,40 @@ Below are the environment variables available in the visual-storybook plugin:
140
140
|`SAUCE_PROJECT_NAME`|| The label / project you would like to associated this build with. |
141
141
|`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. |
142
142
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.
|`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
+
constmeta= {
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
+
exportdefaultmeta;
175
+
```
176
+
143
177
## Different Browsers and Devices
144
178
145
179
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 = {
177
211
```
178
212
179
213
If you'd like to configure your own devices, please follow the configuration steps inside the [playwright docs](https://playwright.dev/docs/emulation#devices).
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.
0 commit comments