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: react/modules/tasks/tests.md
+47-2Lines changed: 47 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -159,9 +159,54 @@ You must use **Jest** or **Vitest** as the test runner and **React Testing Libra
159
159
4. Tests must be deterministic (no flaky tests)
160
160
5. All external dependencies must be properly mocked
161
161
162
-
## Points Distribution
162
+
## Points
163
163
164
-
### Student can get 100 points
164
+
A student can achieve a maximum of 100 points.
165
+
166
+
## 📚 FAQ (Frequently Asked Questions)
167
+
168
+
### ❓ Am I allowed to modify existing components to make testing easier?
169
+
170
+
Yes — if necessary, you are allowed to modify the component code to improve testability. Just make sure you don’t change the logic or convert class components to functional ones.
171
+
172
+
### ❓ Can I add data-testid attributes?
173
+
174
+
Yes. You may add data-testid attributes if necessary, but prefer semantic queries such as getByRole, getByLabelText, or getByText, following Testing Library’s query priority.
175
+
176
+
### ❓ Can I use real API calls in tests?
177
+
178
+
No. You must test your code, not the backend. All API calls should be mocked using `jest.mock`, `vi.mock`, or tools like Mock Service Worker (MSW). Tests should not rely on external services.
179
+
180
+
### ❓ If one file has low coverage but overall project coverage is fine, will I lose points?
181
+
182
+
No. The rule applies to the total (global) coverage only.
183
+
184
+
### ❓ How do I set up coverage threshold?
185
+
186
+
In your test config (e.g., jest.config.js):
187
+
188
+
```
189
+
coverageThreshold: {
190
+
global: {
191
+
statements: 80,
192
+
branches: 50,
193
+
functions: 50,
194
+
lines: 50,
195
+
},
196
+
},
197
+
```
198
+
199
+
### ❓ Should I test main.tsx or App.tsx?
200
+
201
+
You don’t need to test main.tsx directly. Focus on components like App.tsx and everything rendered within it.
202
+
203
+
### ❓ Is deployment required for this task?
204
+
205
+
No, deployment is not mandatory for the unit testing task.
206
+
That said, deploying your app (e.g., to GitHub Pages, Vercel, or Netlify) is highly recommended — it makes the review process easier and demonstrates good development practice.
207
+
If you'd like to deploy, feel free to do so, but it won’t affect your score.
208
+
209
+
### Cross-check (score can be less if some parts of the functionality don't work)
0 commit comments