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: content/ui-testing-handbook/react/en/composition-testing.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -187,7 +187,7 @@ yarn init-msw
187
187
188
188
<divclass="aside">
189
189
190
-
💡 Public directory may differ depending on the project. For custom configurations, we recommend reading MSW's [documentation](https://mswjs.io/docs/getting-started/integrate/browser#where-is-my-public-directory) to learn more about them. To see the changes reflected in Storybook, you'll need to update the [`staticDirs`](https://storybook.js.org/docs/configure/images-and-assets#serving-static-files-via-storybook-configuration) configuration element in `.storybook/main.js`.
190
+
💡 Public directory may differ depending on the project. For custom configurations, we recommend reading MSW's [documentation](https://mswjs.io/docs/getting-started/integrate/browser#where-is-my-public-directory) to learn more about them. To see the changes reflected in Storybook, you'll need to update the [`staticDirs`](https://storybook.js.org/docs/configure/integration/images-and-assets#serving-static-files-via-storybook-configuration) configuration element in `.storybook/main.js`.
Copy file name to clipboardExpand all lines: content/ui-testing-handbook/react/en/interaction-testing.md
+9-9
Original file line number
Diff line number
Diff line change
@@ -57,9 +57,9 @@ Lastly, start up your Storybook (the test runner will run against your local Sto
57
57
yarn storybook
58
58
```
59
59
60
-
## Reuse stories as interaction test cases
60
+
## Reuse stories as component test cases
61
61
62
-
In the previous chapter, we catalogued all the use cases of the InboxScreen component in the `InboxScreen.stories.jsx` file. That allowed us to spot-check appearance during development and catch regressions via visual tests. These stories will now also power our interaction tests.
62
+
In the previous chapter, we catalogued all the use cases of the InboxScreen component in the `InboxScreen.stories.jsx` file. That allowed us to spot-check appearance during development and catch regressions via visual tests. These stories will now also power our component tests.
63
63
64
64
```javascript:title=src/InboxScreen.stories.jsx
65
65
import { http, HttpResponse } from'msw';
@@ -101,13 +101,13 @@ export const Error = {
101
101
};
102
102
```
103
103
104
-
### Write an interaction test using the play function
104
+
### Write a component test using the play function
105
105
106
-
[Testing Library](https://testing-library.com/) offers a convenient API for simulating user interactions—click, drag, tap, type, etc. Whereas [Jest](https://jestjs.io/) provides assertion utilities. We'll use Storybook-instrumented versions of these two tools to write the test. Therefore, you get a familiar developer-friendly syntax to interact with the DOM, but with extra telemetry to help with debugging.
106
+
[Testing Library](https://testing-library.com/) offers a convenient API for simulating user interactions—click, drag, tap, type, etc. Whereas [Vitest](https://vitest.dev/) provides assertion utilities. We'll use Storybook-instrumented versions of these two tools to write the test. Therefore, you get a familiar developer-friendly syntax to interact with the DOM, but with extra telemetry to help with debugging.
107
107
108
108
The test itself will be housed inside a [play function](https://storybook.js.org/docs/writing-stories/play-function). This snippet of code gets attached to a story and runs after the story is rendered.
109
109
110
-
Let's add in our first interaction test to verify that the user can pin a task:
110
+
Let's add in our first component test to verify that the user can pin a task:
111
111
112
112
```javascript:title=src/InboxScreen.stories.jsx
113
113
import { http, HttpResponse } from'msw';
@@ -152,7 +152,7 @@ Each play function receives the Canvas element—the top-level container of the
152
152
153
153
We're looking for the "Export logo" task in our case. Then find the pin button within it and click it. Finally, we check to see if the button has updated to the unpinned state.
154
154
155
-
When Storybook finishes rendering the story, it executes the steps defined within the play function, interacting with the component and pinning a task—similar to how a user would do it. If you check your [interactions panel](https://storybook.js.org/docs/writing-tests/interaction-testing#interactive-debugger), you'll see the step-by-step flow. It also offers a handy set of UI controls to pause, resume, rewind, and step through each interaction.
155
+
When Storybook finishes rendering the story, it executes the steps defined within the play function, interacting with the component and pinning a task—similar to how a user would do it. If you check your [interactions panel](https://storybook.js.org/docs/writing-tests/component-testing#interactive-debugger), you'll see the step-by-step flow. It also offers a handy set of UI controls to pause, resume, rewind, and step through each interaction.
156
156
157
157
<videoautoPlaymutedplaysInlineloop>
158
158
<source
@@ -202,9 +202,9 @@ export const EditTask = {
202
202
};
203
203
```
204
204
205
-
You should now see stories for these scenarios. Storybook only runs the interaction test when you’re viewing a story. Therefore, you'd have to go through each story to run all your checks.
205
+
You should now see stories for these scenarios. Storybook only runs the component test when you’re viewing a story. Therefore, you'd have to review each story to run all your checks.
206
206
207
-
It's unrealistic to manually review the entire Storybook whenever you make a change. Storybook test runner automates that process. It's a standalone utility—powered by [Playwright](https://playwright.dev/)—that runs all your interactions tests and catches broken stories.
207
+
It's unrealistic to manually review the entire Storybook whenever you make a change. Storybook test runner automates that process. It's a standalone utility—powered by [Playwright](https://playwright.dev/)—that runs all your tests and catches broken stories.
In summary, the setup code and test both collocated in the stories file. Using a play function, we interacted with the UI the way a user would. Storybook interaction tests combine the intuitive debugging environment of a live browser with the performance and scriptability of headless browsers.
223
+
In summary, the setup code and test are both located in the stories file. Using a play function, we interacted with the UI as a user would. Storybook component tests combine the intuitive debugging environment of a live browser with the performance and scriptability of headless browsers.
Copy file name to clipboardExpand all lines: content/ui-testing-handbook/react/en/introduction.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -56,7 +56,7 @@ The teams I interviewed all had similar tactics despite differences in their siz
56
56
57
57
- 📚 **Isolate components using**[Storybook](http://storybook.js.org/). Write test cases where each state is reproduced using props and mock data.
58
58
- ✅ **Catch visual bugs and verify composition** using [Chromatic](https://www.chromatic.com/?utm_source=storybook_website&utm_medium=link&utm_campaign=storybook).
59
-
- 🐙 **Verify interactions** with [Jest](https://jestjs.io/) and [Testing Library](https://testing-library.com/).
59
+
- 🐙 **Verify interactions** with [Vitest](https://vitest.dev/) and [Testing Library](https://testing-library.com/).
60
60
- ♿️ **Audit accessibility** of your components using [Axe](https://www.deque.com/axe/).
61
61
- 🔄 **Verify user flows** by writing end-to-end tests with [Cypress](https://www.cypress.io/).
62
62
- 🚥 **Catch regressions** by automatically running tests with [GitHub Actions](https://github.com/features/actions).
Copy file name to clipboardExpand all lines: content/ui-testing-handbook/react/en/workflow.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -84,7 +84,7 @@ To catch regressions you need to run on all your components. You can do that by
84
84
85
85

86
86
87
-
### Interaction tests
87
+
### Component tests
88
88
89
89
The user can delete a task by clicking on the _trash can_ button, we’ll need to add in a test to verify that behaviour.
90
90
@@ -97,7 +97,7 @@ The user can delete a task by clicking on the _trash can_ button, we’ll need t
97
97
98
98
#### During development
99
99
100
-
During development, manually verify the interaction using the InboxScreen stories. If it’s working as expected, you can add in an interaction test using a play function.
100
+
During development, manually verify the interaction using the InboxScreen stories. If it works as expected, you can add a component test using a play function.
0 commit comments