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
Mounts a component story and returns a [Locator] pointing to the root element the story was rendered into. Scope your queries from the returned locator: `component.getByRole('button')`, not `page.getByRole('button')`.
77
+
78
+
A **story** is a small wrapper component that embeds the component under test in one specific scenario: hard-coded props, mock data, providers, recorded callbacks. Stories are rendered by a **gallery** page that you implement and serve at [`property: TestOptions.baseURL`]. The gallery exposes `window.mount(params)` and `window.unmount()` functions that render a story into its root element. Each call to [`method: Fixtures.mount`] navigates to [`property: TestOptions.baseURL`] and calls `window.mount()` with the story id and props, so tests are fully isolated from each other.
79
+
80
+
**Usage**
81
+
82
+
```js
83
+
test('click should expand', async ({ mount }) => {
The returned locator is augmented with two methods:
102
+
*`update(props)` - re-renders the same story with new props without remounting, preserving component state;
103
+
*`unmount()` - unmounts the story.
104
+
105
+
### param: Fixtures.mount.storyId
106
+
* since: v1.62
107
+
-`storyId` <[string]>
108
+
109
+
Identifier of the story to mount, as resolved by the gallery page. Conventionally, the story file path plus the exported story name, for example `'components/Button/Primary'`.
110
+
111
+
### param: Fixtures.mount.props
112
+
* since: v1.62
113
+
-`props` ?<[Object]>
114
+
115
+
Optional plain, serializable props passed to the story.
0 commit comments