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: README.md
+25-42
Original file line number
Diff line number
Diff line change
@@ -117,57 +117,40 @@ There's no such thing as Service Workers in Node.js. Instead, MSW implements a [
117
117
118
118
### Usage example
119
119
120
-
Take a look at the example of an integration test in Vitest that uses [React Testing Library](https://github.com/testing-library/react-testing-library) and Mock Service Worker:
120
+
Here's an example of using Mock Service Worker while developing your Express server:
http.get<never, never, Post[]>('/posts', ({ request, params, cookies }) => {
137
-
returnHttpResponse.json([
138
-
{
139
-
id: 'f8dd058f-9006-4174-8d49-e3086bc39c21',
140
-
title: `Avoid Nesting When You're Testing`,
141
-
},
142
-
{
143
-
id: '8ac96078-6434-4959-80ed-cc834e7fef61',
144
-
title: `How I Built A Modern Website In 2021`,
145
-
},
146
-
])
147
+
// Continue with processing the checkout session.
148
+
handleSession(req, res)
147
149
}),
148
150
)
149
-
150
-
beforeAll(() =>server.listen())
151
-
afterEach(() =>server.resetHandlers())
152
-
afterAll(() =>server.close())
153
-
154
-
it('displays the list of recent posts', async () => {
155
-
render(<Dashboard />)
156
-
157
-
// ✅ Assert that the posts are visible.
158
-
awaitwaitFor(() => {
159
-
expect(
160
-
screen.getByRole('link', { name:/Avoid Nesting When You're Testing/ }),
161
-
).toBeVisible()
162
-
163
-
expect(
164
-
screen.getByRole('link', { name:/How I Built A Modern Website In 2021/ }),
165
-
).toBeVisible()
166
-
})
167
-
})
168
151
```
169
152
170
-
Don't get overwhelmed! There's a step-by-step [**Getting started**](https://mswjs.io/docs/getting-started) tutorial that you can follow to learn how to integrate Mock Service Worker into your project.
153
+
> This example showcases [`server.boundary()`](https://mswjs.io/docs/api/setup-server/boundary) to scope request interception to a particular closure, which is extremely handy!
0 commit comments