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: contributing.md
+26-5Lines changed: 26 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,8 +19,8 @@ If you want to look at our setup, check out the "Actions" tab in Github, as well
19
19
20
20
In addition to status checks, PR's are required to have at least one reviewer before being merged into `main`.
21
21
22
-
## Testing (to be implemented)
23
-
CI Is driven by tests, they help instill confidence in pull requests because a developer can say "All the status checks pass and my new tests pass so the PR is safe to merge". When contributing new features, it is most ideal to write at least 4 tests targeting your code.
22
+
## Testing
23
+
Tests help instill confidence in pull requests because a developer can say "All the status checks pass and my new tests pass so the PR is safe to merge". When contributing new features, it is most ideal to write at least 4 tests targeting your code.
24
24
- One for the "happy path"
25
25
- Test the endpoint/feature in the way it is intended to be used
26
26
- One for the "extreme path"
@@ -29,6 +29,27 @@ CI Is driven by tests, they help instill confidence in pull requests because a d
29
29
- Test with strange input, (What if I send characters to a function that expects integers)
30
30
- One for the "null path"
31
31
- Test with empty params/nothing/emptiness
32
-
33
-
34
-
Our front end tests are run through Jest and RTL.
32
+
33
+
### Frontend testing
34
+
Our frontend tests are run through [Vitest](https://vitest.dev/) and [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/). Vitest serves as a drop-in replacement for [Jest](https://jestjs.io/).
35
+
36
+
#### Intro
37
+
If you're unfamiliar with writing UI tests, we recommend reading docs for React Testing Library and [Redux](https://redux.js.org/usage/writing-tests) to learn the basic concepts of integration testing a Redux app.
38
+
39
+
The structure of a frontend integration test is "arrange, act, assert":
40
+
41
+
1. Arrange: Render some UI
42
+
2. Act: Simulate user interactions
43
+
3. Assert: Expect certain state changes in the UI
44
+
45
+
#### In 311-Data
46
+
Frontend testing for 311-Data is currently a work in progress. Example tests are provided in two files:
47
+
48
+
1. utils.test.js demonstrates unit testing non-UI code.
49
+
2. FilterMenu.test.jsx demonstrates integration testing UI code. This follows the "arrange, act, assert" procedure mentioned above.
50
+
51
+
You can refer to these files as examples of how to write additional tests for 311-Data with Vitest and React Testing Library.
52
+
53
+
#### Where to put test files
54
+
55
+
Test files are placed in the same directory as the file that they test. This makes the association between application code and test code clear.
0 commit comments