storybook-addon-playwright 5.9.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -83,43 +83,30 @@ module.exports = function (router) {
83
83
 
84
84
  ### Story Readiness Before Screenshot
85
85
 
86
- The addon will wait briefly for story readiness before taking screenshots.
86
+ By default, the addon waits for Storybook to settle by checking `#storybook-root` before taking screenshots. This behavior is enabled by default because `waitForStoryRender` is `true`. Set `waitForStoryRender: false` to disable it.
87
87
 
88
- Built-in readiness checks:
88
+ If your story needs an extra selector wait, do it explicitly in `beforeScreenshot`:
89
89
 
90
- - If a marker is present at navigation time (`body[data-playwright-mounted]`), marker mode is enabled and the addon waits for mounted state.
91
- - In marker mode, readiness is:
92
- - `body[data-playwright-mounted="true"]`.
93
- - Otherwise, it checks Storybook preview render phases when available.
94
- - If Storybook internals are not available, it falls back to mounted content under `#storybook-root` or `#storybook-docs`.
95
-
96
- If you do not use a mount marker decorator, no marker wait is applied.
97
-
98
- For stricter post-mount readiness in React, use the built-in decorator helper from `storybook-addon-playwright/decorator`.
99
-
100
- ```tsx
101
- import type { Preview } from '@storybook/react';
102
- import { withReactMounted } from 'storybook-addon-playwright/decorator';
103
-
104
- const preview: Preview = {
105
- decorators: [withReactMounted()],
106
- };
107
-
108
- export default preview;
90
+ ```js
91
+ setConfig({
92
+ storybookEndpoint: 'http://localhost:6006/',
93
+ getPage: async (browserType, options) => {
94
+ await ready;
95
+ return await browsers[browserType].newPage(options);
96
+ },
97
+ beforeScreenshot: async (page, data) => {
98
+ await page
99
+ .frameLocator('iframe')
100
+ .locator('.my-selector')
101
+ .waitFor({ state: 'visible', timeout: 10000 });
102
+ },
103
+ afterScreenshot: async (page) => {
104
+ await page.close();
105
+ },
106
+ });
109
107
  ```
110
108
 
111
- This avoids JSX component typing issues that can happen in some projects when using `ReactMountedDecorator` directly in `preview.tsx`.
112
-
113
- What the React decorator does:
114
-
115
- - Sets `data-playwright-mounted="pending"` immediately so marker mode is enabled.
116
- - Updates the value to `"true"` after React mounts.
117
- - Removes the attribute on unmount.
118
-
119
- For non-React frameworks (Vue, Svelte, Angular, etc.), create a small framework-specific decorator/composable that follows the same marker contract:
120
-
121
- - Set `data-playwright-mounted="pending"` before mount.
122
- - Set `data-playwright-mounted="true"` when mounted.
109
+ This keeps the readiness logic in your config instead of relying on framework-specific mounting code.
123
110
 
124
111
  ## setConfig Options
125
112