From 4f7bebc76443529b3716125c45236fdd0ae4fdf2 Mon Sep 17 00:00:00 2001 From: islml <155185075+islml@users.noreply.github.com> Date: Wed, 5 Mar 2025 20:21:56 +0200 Subject: [PATCH 1/4] Update testing.md --- contributor_docs/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributor_docs/testing.md b/contributor_docs/testing.md index 9ddc25dfc9..e6300d27d6 100644 --- a/contributor_docs/testing.md +++ b/contributor_docs/testing.md @@ -366,7 +366,7 @@ When testing redux, the general guidance [[1]](#References) seems to suggest spl 2. reducers 3. connected components -Testing reducers and action creators is covered pretty well in [Redux's documentation](https://redux.js.org/recipes/writing-tests). An example of testing an action creator can be found at [projects.test.js](../client/modules/IDE/components/actions/__tests__/projects.test.jsx) +Testing reducers and action creators is covered pretty well in [Redux's documentation](https://redux.js.org/recipes/writing-tests). An example of testing an action creator can be found at [projects.test.js](../client/modules/IDE/actions/projects.unit.test.js) ### Connected Components From 6211ae23166aa94de84b6a98578327a83871101f Mon Sep 17 00:00:00 2001 From: islml <155185075+islml@users.noreply.github.com> Date: Wed, 5 Mar 2025 20:28:53 +0200 Subject: [PATCH 2/4] Update testing.md --- contributor_docs/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributor_docs/testing.md b/contributor_docs/testing.md index e6300d27d6..a31866d453 100644 --- a/contributor_docs/testing.md +++ b/contributor_docs/testing.md @@ -468,7 +468,7 @@ Some things to consider testing: ## How to Handle API Calls in Tests -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). +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). There's a longer explanation of the benefits of `msw` in [this article by Kent C Dodds](https://kentcdodds.com/blog/stop-mocking-fetch). From d90b873c60220a311551026c1359853c043656e4 Mon Sep 17 00:00:00 2001 From: islml <155185075+islml@users.noreply.github.com> Date: Wed, 5 Mar 2025 20:37:16 +0200 Subject: [PATCH 3/4] Update testing.md --- contributor_docs/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributor_docs/testing.md b/contributor_docs/testing.md index a31866d453..e6300d27d6 100644 --- a/contributor_docs/testing.md +++ b/contributor_docs/testing.md @@ -468,7 +468,7 @@ Some things to consider testing: ## How to Handle API Calls in Tests -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). +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). There's a longer explanation of the benefits of `msw` in [this article by Kent C Dodds](https://kentcdodds.com/blog/stop-mocking-fetch). From dbd8a465f2c5819eddaf048dac2673762f8968e4 Mon Sep 17 00:00:00 2001 From: islml <155185075+islml@users.noreply.github.com> Date: Wed, 5 Mar 2025 20:43:14 +0200 Subject: [PATCH 4/4] Final update testing.md --- contributor_docs/testing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributor_docs/testing.md b/contributor_docs/testing.md index e6300d27d6..a107aa8da3 100644 --- a/contributor_docs/testing.md +++ b/contributor_docs/testing.md @@ -366,7 +366,7 @@ When testing redux, the general guidance [[1]](#References) seems to suggest spl 2. reducers 3. connected components -Testing reducers and action creators is covered pretty well in [Redux's documentation](https://redux.js.org/recipes/writing-tests). An example of testing an action creator can be found at [projects.test.js](../client/modules/IDE/actions/projects.unit.test.js) +Testing reducers and action creators is covered pretty well in [Redux's documentation](https://redux.js.org/recipes/writing-tests). An example of testing an action creator can be found at [projects.unit.test.js](../client/modules/IDE/actions/projects.unit.test.js) ### Connected Components