Skip to content

Commit 0104178

Browse files
authored
docs: Upate React example usage with MSW to mention that fetch will require polyfill (#1418)
* Update example-intro.mdx Updates the example notes re: MSW to mention that jsdom doesn't include fetch and will require a polyfill * Fix link * Update example-intro.mdx * Update example-intro.mdx * Update example-intro.mdx
1 parent 2e99602 commit 0104178

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/react-testing-library/example-intro.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ declaratively mock API communication in your tests instead of stubbing
7474

7575
:::
7676

77+
:::note
78+
79+
Our example here uses axios to make its API calls. If your application uses [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch) to make its API calls, then be aware that by default JSDOM does not include fetch. If you are using vitest as your test runner, it will be included for you. For jest you may wish to manually polyfill `fetch()` or use the [jest-fixed-jsdom](https://github.com/mswjs/jest-fixed-jsdom) environment which includes fetch.
80+
81+
:::
82+
7783
```jsx title="__tests__/fetch.test.jsx"
7884
import React from 'react'
7985
import {http, HttpResponse} from 'msw'

0 commit comments

Comments
 (0)