Skip to content

Commit 4759823

Browse files
committed
Update testing.md
1 parent 598095f commit 4759823

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

developer_docs/testing.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ Consider what you want to test. Some possible things might be:
334334
335335
## Testing Redux
336336
337-
When testing redux, the general guidance [1] seems to suggest splitting up testing between:
337+
When testing redux, the general guidance [[1]](#References) seems to suggest splitting up testing between:
338338
1. action creators
339339
2. reducers
340340
3. connected components
@@ -378,10 +378,9 @@ import { reduxRender, fireEvent, screen } from '../../../test-utils';
378378
import { initialTestState } from '../../../redux_test_stores/test_store';
379379

380380
describe(<MyComponent />, () => {
381-
let store;
382381
let container;
383382
const mockStore = configureStore([thunk]);
384-
store = mockStore(initialTestState);
383+
const store = mockStore(initialTestState);
385384

386385
beforeEach(() => {
387386
// setup a DOM element as a render target
@@ -445,7 +444,7 @@ Some things to consider testing:
445444
446445
Some tests throw errors if a part of the client-side code tries to make an API call or AJAX request. Our solution to this is to use jest to replace those functions with [mock functions](https://jestjs.io/docs/mock-functions).
447446
448-
The code in question for the client side is mostly related to the axios library. We mock the whole library - jest automatically does this since we have an ``axios.js`` file in the ``__mocks__`` folder at the root of the client folder. [1][2]
447+
The code in question for the client side is mostly related to the axios library. We mock the whole library - jest automatically does this since we have an ``axios.js`` file in the ``__mocks__`` folder at the root of the client folder. [[2]](#References)
449448
450449
The benefit of this is that you can control exactly what happens when any axios function gets called, and you can check how many times it's been called.
451450
@@ -466,7 +465,7 @@ Testing multiple components together. A small example is rendering a parent comp
466465
Most of our tests are of this type. In this, you're testing a the functionality of a single component and no more.
467466
468467
## Internationalization
469-
Project uses i18n.
468+
This project uses i18next for internationalization. If you import the render function with the i18n wrapper from ``test_utils.js``, it's set up to use English, so the components with be rendered with English text and you should be able to count on this to test for specific strings.
470469
471470
## Tips
472471
1. Make test fail at least once to make sure it was a meaningful test
@@ -477,6 +476,6 @@ Project uses i18n.
477476
- stuff
478477
479478
## References
480-
-https://willowtreeapps.com/ideas/best-practices-for-unit-testing-with-a-react-redux-approach
481-
- [More info on this method](https://stackoverflow.com/questions/51393952/mock-inner-axios-create/51414152#51414152)
482-
- [and this too](https://medium.com/asos-techblog/how-to-test-your-react-redux-application-48d90481a253)
479+
1. [Best practices for unit testing with a react redux approach](https://willowtreeapps.com/ideas/best-practices-for-unit-testing-with-a-react-redux-approach)
480+
481+
2. [How to test your react-redux application (this article also references axios)](https://medium.com/asos-techblog/how-to-test-your-react-redux-application-48d90481a253)

0 commit comments

Comments
 (0)