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: developer_docs/testing.md
+15-44Lines changed: 15 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,6 +119,7 @@ For any type of component, you might want to consider testing:
119
119
expect(screen.queryByText('Does not exist')).not.toBeInTheDocument();
120
120
```
121
121
- If it's an integration test, you could consider testing the "happy path" flow. For example, in a login form, you would test how a user might enter their username and password and then enter that information.
122
+
- If it's a unit test, you could test possible error cases to ensure that the module being tested is robust and resistant to user or developer error.
122
123
- Generally, you want to focus your testing on "user input" -> "expected output" instead of making sure the middle steps work as you would expect. This might mean that you don't need to check that the state changes or class-specific methods occur. This is so that if some of the small details in the implementation of the component changes in the future, the tests can remain the same.
123
124
- more details on testing behavior in the component-specific sections
124
125
@@ -173,7 +174,7 @@ You can also see it used in the context of a test [in the SketchList.test.jsx fi
173
174
All tests are directly adjacent to the files that they are testing, as described in the [React docs](https://reactjs.org/docs/faq-structure.html#grouping-by-file-type). For example, if you're testing ``examplefolder/Sketchlist.test.jsx``, the test would be in ``examplefolder/Sketchlist.test.jsx``. This is so that the tests are as close as possible to the files. This also means that any snapshot files will be stored in the same folder, such as ``examplefolder/__snapshots__/Sketchlist.test.jsx.snap``
174
175
175
176
CASSIE-WHEREDOWEPUTTHEINTEGRATIONTESTS?
176
-
Integration tests can be placed in the ``__tests__`` folder that's at the root of the client folder. They should be called ``ComponentName.test.integration.jsx``
177
+
Integration tests should be adjacent to the components they're testing. They should be called ``ComponentName.integration.test.jsx``
177
178
178
179
Manual mocks are in ``__mocks__`` folders are adjacent to the modules that they're mocking.
179
180
@@ -271,13 +272,11 @@ If it doesn't contain ``connect(mapStateToProps, mapDispatchToProps)(ComponentNa
271
272
*MyComponent.test.jsx*
272
273
```js
273
274
import React from 'react';
274
-
import { unmountComponentAtNode } from 'react-dom';
275
275
import { act } from 'react-dom/test-utils';
276
276
import { fireEvent, render, screen } from '../../../../test-utils';
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)
0 commit comments