@@ -18,14 +18,112 @@ You must use **Jest** or **Vitest** as the test runner and **React Testing Libra
1818- Practice testing user interactions and component state changes
1919- Prepare a solid test foundation for future refactoring (** Week 3 - Functional Routing** )
2020
21- ## Application Requirements
21+ ## Functional Requirements (max ** 100 points ** )
2222
23- 1 . ** Test Coverage** : Achieve at least ** 80% statement coverage** for all components, with minimum 50% coverage for branches, functions, and lines.
24- 2 . ** No Implementation Changes** : Write tests for existing class components without modifying their code
25- 3 . ** Behavior-Focused Testing** : Test what components do, not how they do it
26- 4 . ** API Mocking** : Mock all external API calls to ensure tests are isolated and fast
27- 5 . ** Error Handling** : Test both success and error scenarios
28- 6 . ** User Interactions** : Test all user interactions (clicks, form submissions, input changes)
23+ ### Feature 1: Test Coverage (** 20 points** )
24+
25+ ** As a** developer
26+ ** I want** to ensure high test coverage
27+ ** So that** my components are reliably tested
28+
29+ ** Scenario:** Achieve minimum coverage
30+
31+ - ** Given** I have written tests for all components
32+ - ** Then** statement coverage is at least 80%
33+ - ** And** branch, function, and line coverage are at least 50%
34+
35+ ** Acceptance Criteria:**
36+
37+ - The test suite achieves at least 80% statement coverage.
38+ - Branch, function, and line coverage are each at least 50%.
39+ - Coverage is measured and reported using Jest or Vitest coverage tools.
40+
41+ ### Feature 2: No Implementation Changes (** 10 points** )
42+
43+ ** As a** developer
44+ ** I want** to test class components without modifying their logic
45+ ** So that** I preserve original behavior
46+
47+ ** Scenario:** Write tests only
48+
49+ - ** Given** existing class components
50+ - ** When** I write tests
51+ - ** Then** I do not change component implementation
52+
53+ ** Acceptance Criteria:**
54+
55+ - No major changes are made to the logic or structure of class components during testing.
56+ - Conversion to functional components is not performed.
57+ - Only changes to improve testability are allowed, without altering behavior.
58+
59+ ### Feature 3: Behavior-Focused Testing (** 15 points** )
60+
61+ ** As a** developer
62+ ** I want** to test component behavior and public API
63+ ** So that** tests remain valid after refactoring
64+
65+ ** Scenario:** Focus on behavior
66+
67+ - ** Given** a component
68+ - ** When** I write tests
69+ - ** Then** I test what the component does, not how it does it
70+
71+ ** Acceptance Criteria:**
72+
73+ - Tests focus on user-visible behavior and component outputs, not internal implementation details.
74+
75+ ### Feature 4: API Mocking (** 15 points** )
76+
77+ ** As a** developer
78+ ** I want** to mock all external API calls
79+ ** So that** tests are isolated and fast
80+
81+ ** Scenario:** Mock APIs
82+
83+ - ** Given** a component that calls an API
84+ - ** When** I run tests
85+ - ** Then** all API calls are mocked
86+
87+ ** Acceptance Criteria:**
88+
89+ - All external API calls are mocked using Jest, Vitest, or MSW.
90+ - No real network requests are made during test execution.
91+ - Tests cover both successful and error API responses using mocks.
92+
93+ ### Feature 5: Error Handling (** 20 points** )
94+
95+ ** As a** developer
96+ ** I want** to test error scenarios
97+ ** So that** my components handle errors gracefully
98+
99+ ** Scenario:** Test errors
100+
101+ - ** Given** a component that can fail
102+ - ** When** an error occurs
103+ - ** Then** the error scenario is tested
104+
105+ ** Acceptance Criteria:**
106+
107+ - Tests simulate error conditions (e.g., failed API calls, thrown errors in components).
108+ - Error boundaries are tested to ensure they catch and handle errors as expected.
109+
110+ ### Feature 6: User Interactions (** 20 points** )
111+
112+ ** As a** developer
113+ ** I want** to test all user interactions
114+ ** So that** my components respond correctly
115+
116+ ** Scenario:** Test interactions
117+
118+ - ** Given** a component with user input
119+ - ** When** the user interacts (clicks, submits, changes input)
120+ - ** Then** the interaction is tested
121+
122+ ** Acceptance Criteria:**
123+
124+ - All user interactions (clicks, input changes, form submissions, etc.) are covered by tests.
125+ - Tests verify that components respond correctly to user actions (e.g., updating state, calling callbacks, rendering changes).
126+ - Edge cases and invalid inputs are tested to ensure robust handling of user interactions.
29127
30128## Technical Requirements
31129
@@ -68,6 +166,29 @@ You must use **Jest** or **Vitest** as the test runner and **React Testing Libra
68166 - Create ` .test.tsx ` or ` .spec.tsx ` files for each component
69167 - Set up test utilities and mocks in a separate ` __tests__ ` or ` test-utils ` directory
70168
169+ ### Penalties
170+
171+ - ** 1. TypeScript & Code Quality**
172+ - TypeScript isn't used: ** -95 points**
173+ - Usage of _ any_ : ** -20 points per each**
174+ - Usage of _ ts-ignore_ : ** -20 points per each**
175+ - Presence of _ code-smells_ (God-object, chunks of duplicate code), commented code sections: ** -10 points per each**
176+
177+ - ** 2. Test Coverage**
178+ - Statement coverage below 80% (≥70%): ** -10 points**
179+ - Statement coverage below 70% (≥50%): ** -30 points**
180+ - All coverage metrics below 50%: ** -50 points**
181+
182+ - ** 3. React Best Practices**
183+ - Direct DOM manipulations inside the React components: ** -50 points per each**
184+
185+ - ** 4. External Dependencies**
186+ - Usage of component libraries, e.g. Material UI, Ant Design: ** -100 points**
187+
188+ - ** 5. Project Management**
189+ - Commits after the deadline: ** -40 points**
190+ - Pull Request doesn't follow guideline (including checkboxes in Score) [ PR example] ( https://rs.school/docs/en/pull-request-review-process#pull-request-description-must-contain-the-following ) : ** -10 points**
191+
71192## Suggested Test Scenarios
72193
73194⚠️ You can use the following scenarios as a guide for writing your tests. Feel free to add more tests based on your components' specific behaviors and requirements. Your application may differ from these examples, so these scenarios are ** suggestions only** . Strive for ** 80% test statement coverage** as your target milestone.
@@ -159,10 +280,6 @@ You must use **Jest** or **Vitest** as the test runner and **React Testing Libra
1592804 . Tests must be deterministic (no flaky tests)
1602815 . All external dependencies must be properly mocked
161282
162- ## Points
163-
164- A student can achieve a maximum of 100 points.
165-
166283## 📚 FAQ (Frequently Asked Questions)
167284
168285### ❓ Am I allowed to modify existing components to make testing easier?
@@ -205,37 +322,3 @@ You don’t need to test main.tsx directly. Focus on components like App.tsx and
205322No, deployment is not mandatory for the unit testing task.
206323That 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.
207324If 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)
210-
211- - ** Test Runner Setup** (Jest/Vitest configured with RTL, coverage reporting works) - ** 15 points**
212- - ** Search Component Tests** (localStorage, user input, search functionality) - ** 20 points**
213- - ** Results/CardList Component Tests** (rendering, data display, loading states) - ** 15 points**
214- - ** Card Component Tests** (rendering) - ** 15 points**
215- - ** Error Boundary Tests** (error catching, fallback UI, test error button) - ** 15 points**
216- - ** API Integration Tests** (mocked API calls, success/error handling) - ** 15 points**
217- - ** Husky Pre-push Hook** (tests run automatically before push) - ** 5 points**
218-
219- ### Penalties
220-
221- - ** 1. TypeScript & Code Quality**
222- - TypeScript isn't used: ** -95 points**
223- - Usage of _ any_ : ** -20 points per each**
224- - Usage of _ ts-ignore_ : ** -20 points per each**
225- - Presence of _ code-smells_ (God-object, chunks of duplicate code), commented code sections: ** -10 points per each**
226-
227- - ** 2. Test Coverage**
228- - Statement coverage below 80% (≥70%): ** -10 points**
229- - Statement coverage below 70% (≥50%): ** -30 points**
230- - All coverage metrics below 50%: ** -50 points**
231-
232- - ** 3. React Best Practices**
233- - Direct DOM manipulations inside the React components: ** -50 points per each**
234-
235- - ** 4. External Dependencies**
236- - Usage of Redux or other state management libraries: ** -100 points**
237- - Usage of component libraries, e.g. Material UI, Ant Design: ** -100 points**
238-
239- - ** 5. Project Management**
240- - Commits after the deadline: ** -40 points**
241- - Pull Request doesn't follow guideline (including checkboxes in Score) [ PR example] ( https://rs.school/docs/en/pull-request-review-process#pull-request-description-must-contain-the-following ) : ** -10 points**
0 commit comments