storybook-addon-playwright 5.7.0 → 5.8.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
@@ -81,6 +81,46 @@ module.exports = function (router) {
81
81
  };
82
82
  ```
83
83
 
84
+ ### Story Readiness Before Screenshot
85
+
86
+ The addon will wait briefly for story readiness before taking screenshots.
87
+
88
+ Built-in readiness checks:
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;
109
+ ```
110
+
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.
123
+
84
124
  ## setConfig Options
85
125
 
86
126
  For a full list of available options with detailed descriptions, see the [`Config` interface in `src/typings/config.ts`](src/typings/config.ts).
package/decorator.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/decorator/index';
package/decorator.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/decorator/index');