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: contributor_docs/testing.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -468,7 +468,7 @@ Some things to consider testing:
468
468
469
469
## How to Handle API Calls in Tests
470
470
471
-
Some tests throw errors if the client-side code tries to make an API call. This project uses the [Mock Service Worker library](https://mswjs.io/) to mock the API requests by intercepting requests on the network level [[2]](#References). It can handle API calls and return appropriate data (and you can see what shape of data gets returned by looking through the server files). There is some test data available in the `client/testData/testServerResponse.js` file, but you may need to edit the file to add a new JSON response if an appropriate one doesn't exist already. The example code below sets up a server to respond to a GET request at `/exampleendpoint` by returning `{data: foo}` You can see it in the context of a test [in the SketchList.test.jsx file](../client/modules/IDE/components/SketchList.unit.test.jsx).
471
+
Some tests throw errors if the client-side code tries to make an API call. This project uses the [Mock Service Worker library](https://mswjs.io/) to mock the API requests by intercepting requests on the network level [[2]](#References). It can handle API calls and return appropriate data (and you can see what shape of data gets returned by looking through the server files). There is some test data available in the `client/testData/testServerResponse.js` file, but you may need to edit the file to add a new JSON response if an appropriate one doesn't exist already. The example code below sets up a server to respond to a GET request at `/exampleendpoint` by returning `{data: foo}` You can see it in the context of a test [in the SketchList.test.jsx file](../client/modules/IDE/components/SketchList.test.jsx).
472
472
473
473
There's a longer explanation of the benefits of `msw` in [this article by Kent C Dodds](https://kentcdodds.com/blog/stop-mocking-fetch).
0 commit comments