front-end-dev-standards 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,399 @@
1
+ # Testing Standards
2
+
3
+ Version: 1.0
4
+ Framework: Angular 20+
5
+ Test Runner: Vitest
6
+ Goal: Reliable, Maintainable, Fast Tests
7
+
8
+ ---
9
+
10
+ # 1. Testing Principles
11
+
12
+ ## Core Principles
13
+
14
+ 1. Test Behavior, Not Implementation
15
+ 2. Fast Feedback
16
+ 3. Deterministic Tests
17
+ 4. Independent Tests
18
+ 5. Readable Tests
19
+ 6. High Value Coverage
20
+
21
+ ---
22
+
23
+ # 2. Testing Pyramid
24
+
25
+ ```text
26
+ E2E
27
+ / \
28
+ Integration
29
+ / \
30
+ Unit Tests
31
+ ```
32
+
33
+ Target Distribution:
34
+
35
+ * Unit Tests: 70%
36
+ * Integration Tests: 20%
37
+ * E2E Tests: 10%
38
+
39
+ ---
40
+
41
+ # 3. Test Stack
42
+
43
+ | Tool | Purpose |
44
+ | ------------------- | ----------------- |
45
+ | Vitest | Test Runner |
46
+ | Angular TestBed | Integration |
47
+ | Testing Library | User Interactions |
48
+ | Playwright | E2E |
49
+ | Mock Service Worker | API Mocking |
50
+
51
+ ---
52
+
53
+ # 4. File Naming
54
+
55
+ ```text
56
+ employee.service.spec.ts
57
+
58
+ employee-list.page.spec.ts
59
+
60
+ timesheet-calendar.component.spec.ts
61
+ ```
62
+
63
+ Tests live beside source files.
64
+
65
+ ---
66
+
67
+ # 5. Test Structure
68
+
69
+ Use AAA Pattern.
70
+
71
+ ```typescript
72
+ it('should calculate weekly hours', () => {
73
+ // Arrange
74
+
75
+ // Act
76
+
77
+ // Assert
78
+ });
79
+ ```
80
+
81
+ ---
82
+
83
+ # 6. Unit Testing Standards
84
+
85
+ Test:
86
+
87
+ ✓ Services
88
+
89
+ ✓ Guards
90
+
91
+ ✓ Pipes
92
+
93
+ ✓ Validators
94
+
95
+ ✓ Utility Functions
96
+
97
+ ✓ Signal Computations
98
+
99
+ ---
100
+
101
+ # 7. Component Testing Standards
102
+
103
+ Focus on:
104
+
105
+ * Rendered Output
106
+ * User Actions
107
+ * State Changes
108
+
109
+ Avoid testing:
110
+
111
+ * Private Methods
112
+ * Internal Variables
113
+
114
+ ---
115
+
116
+ # 8. Service Testing Standards
117
+
118
+ Every service must test:
119
+
120
+ * Success Path
121
+ * Error Path
122
+ * Edge Cases
123
+ * Retry Logic
124
+
125
+ Coverage Target:
126
+
127
+ ```text
128
+ 90%
129
+ ```
130
+
131
+ ---
132
+
133
+ # 9. Signal Testing
134
+
135
+ Preferred:
136
+
137
+ ```typescript
138
+ component.loading.set(true);
139
+
140
+ expect(
141
+ component.loading()
142
+ ).toBe(true);
143
+ ```
144
+
145
+ Test public signals only.
146
+
147
+ ---
148
+
149
+ # 10. Form Testing
150
+
151
+ Verify:
152
+
153
+ ✓ Required Validation
154
+
155
+ ✓ Custom Validation
156
+
157
+ ✓ Submission
158
+
159
+ ✓ Error Messages
160
+
161
+ ✓ Disabled States
162
+
163
+ ---
164
+
165
+ # 11. HTTP Testing
166
+
167
+ Use:
168
+
169
+ ```typescript
170
+ HttpTestingController
171
+ ```
172
+
173
+ Never call real APIs.
174
+
175
+ Verify:
176
+
177
+ * Method
178
+ * URL
179
+ * Headers
180
+ * Request Body
181
+
182
+ ---
183
+
184
+ # 12. Guard Testing
185
+
186
+ Must verify:
187
+
188
+ * Authorized User
189
+ * Unauthorized User
190
+ * Redirect Logic
191
+
192
+ Coverage:
193
+
194
+ ```text
195
+ 100%
196
+ ```
197
+
198
+ ---
199
+
200
+ # 13. Interceptor Testing
201
+
202
+ Must verify:
203
+
204
+ * Header Injection
205
+ * Error Handling
206
+ * Token Refresh
207
+
208
+ Coverage:
209
+
210
+ ```text
211
+ 100%
212
+ ```
213
+
214
+ ---
215
+
216
+ # 14. Integration Testing
217
+
218
+ Test interactions between:
219
+
220
+ * Components
221
+ * Services
222
+ * Routing
223
+ * Forms
224
+
225
+ Focus on workflows.
226
+
227
+ ---
228
+
229
+ # 15. E2E Testing
230
+
231
+ Critical Flows:
232
+
233
+ ✓ Login
234
+
235
+ ✓ Logout
236
+
237
+ ✓ Timesheet Submission
238
+
239
+ ✓ Attendance
240
+
241
+ ✓ Payroll Access
242
+
243
+ ✓ Leave Request
244
+
245
+ Use Playwright.
246
+
247
+ ---
248
+
249
+ # 16. Mocking Standards
250
+
251
+ Mock:
252
+
253
+ * HTTP Calls
254
+ * External APIs
255
+ * Browser APIs
256
+
257
+ Do Not Mock:
258
+
259
+ * Business Logic Under Test
260
+
261
+ ---
262
+
263
+ # 17. Test Data Standards
264
+
265
+ Use factories.
266
+
267
+ ```typescript
268
+ createEmployee()
269
+
270
+ createPayroll()
271
+
272
+ createTimesheet()
273
+ ```
274
+
275
+ Avoid inline mock duplication.
276
+
277
+ ---
278
+
279
+ # 18. Coverage Requirements
280
+
281
+ | Layer | Coverage |
282
+ | -------------- | -------- |
283
+ | Services | 90% |
284
+ | Guards | 100% |
285
+ | Interceptors | 100% |
286
+ | Utilities | 95% |
287
+ | Components | 80% |
288
+ | Critical Logic | 95% |
289
+
290
+ ---
291
+
292
+ # 19. Performance Testing
293
+
294
+ Measure:
295
+
296
+ * Initial Load
297
+ * Route Navigation
298
+ * API Response Handling
299
+
300
+ Performance regressions block releases.
301
+
302
+ ---
303
+
304
+ # 20. Accessibility Testing
305
+
306
+ Verify:
307
+
308
+ ✓ Keyboard Navigation
309
+
310
+ ✓ Focus States
311
+
312
+ ✓ Screen Readers
313
+
314
+ ✓ ARIA Labels
315
+
316
+ Accessibility defects are bugs.
317
+
318
+ ---
319
+
320
+ # 21. Snapshot Testing
321
+
322
+ Allowed only for:
323
+
324
+ * Design System Components
325
+ * Shared UI Components
326
+
327
+ Avoid large page snapshots.
328
+
329
+ ---
330
+
331
+ # 22. Flaky Test Policy
332
+
333
+ A flaky test:
334
+
335
+ * Must be fixed immediately
336
+ * Must not be ignored
337
+ * Must not be retried indefinitely
338
+
339
+ ---
340
+
341
+ # 23. CI Quality Gates
342
+
343
+ Required before merge:
344
+
345
+ ✓ Lint Pass
346
+
347
+ ✓ Unit Tests Pass
348
+
349
+ ✓ Integration Tests Pass
350
+
351
+ ✓ Coverage Threshold Met
352
+
353
+ ✓ Security Scan Pass
354
+
355
+ ---
356
+
357
+ # 24. AI Generated Test Standards
358
+
359
+ AI-generated tests must:
360
+
361
+ ✓ Test real behavior
362
+
363
+ ✓ Use factories
364
+
365
+ ✓ Cover success and failure paths
366
+
367
+ ✓ Avoid implementation details
368
+
369
+ Reject tests that:
370
+
371
+ ✗ Test private methods
372
+
373
+ ✗ Assert internal state unnecessarily
374
+
375
+ ✗ Use arbitrary delays
376
+
377
+ ✗ Depend on execution order
378
+
379
+ ---
380
+
381
+ # 25. Definition of Test Quality
382
+
383
+ Tests are considered production-ready when:
384
+
385
+ ✓ Reliable
386
+
387
+ ✓ Fast
388
+
389
+ ✓ Deterministic
390
+
391
+ ✓ Maintainable
392
+
393
+ ✓ Readable
394
+
395
+ ✓ Independent
396
+
397
+ ✓ High Value
398
+
399
+ ✓ CI Verified