ai-flow-dev 2.6.0 → 2.7.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.
Files changed (161) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +570 -570
  3. package/package.json +73 -73
  4. package/prompts/backend/flow-build-phase-0.md +535 -535
  5. package/prompts/backend/flow-build-phase-1.md +626 -626
  6. package/prompts/backend/flow-build-phase-10.md +340 -340
  7. package/prompts/backend/flow-build-phase-2.md +573 -573
  8. package/prompts/backend/flow-build-phase-3.md +834 -834
  9. package/prompts/backend/flow-build-phase-4.md +554 -554
  10. package/prompts/backend/flow-build-phase-5.md +703 -703
  11. package/prompts/backend/flow-build-phase-6.md +524 -524
  12. package/prompts/backend/flow-build-phase-7.md +1001 -1001
  13. package/prompts/backend/flow-build-phase-8.md +1407 -1407
  14. package/prompts/backend/flow-build-phase-9.md +477 -477
  15. package/prompts/backend/flow-build.md +137 -137
  16. package/prompts/backend/flow-check-review.md +20 -20
  17. package/prompts/backend/flow-check-test.md +14 -14
  18. package/prompts/backend/flow-check.md +67 -67
  19. package/prompts/backend/flow-commit.md +119 -119
  20. package/prompts/backend/flow-docs-sync.md +354 -354
  21. package/prompts/backend/flow-work-feature.md +61 -61
  22. package/prompts/backend/flow-work-fix.md +46 -46
  23. package/prompts/backend/flow-work-refactor.md +48 -48
  24. package/prompts/backend/flow-work-resume.md +34 -34
  25. package/prompts/backend/flow-work.md +1286 -1023
  26. package/prompts/desktop/flow-build-phase-0.md +359 -359
  27. package/prompts/desktop/flow-build-phase-1.md +295 -295
  28. package/prompts/desktop/flow-build-phase-10.md +357 -357
  29. package/prompts/desktop/flow-build-phase-2.md +282 -282
  30. package/prompts/desktop/flow-build-phase-3.md +291 -291
  31. package/prompts/desktop/flow-build-phase-4.md +308 -308
  32. package/prompts/desktop/flow-build-phase-5.md +269 -269
  33. package/prompts/desktop/flow-build-phase-6.md +350 -350
  34. package/prompts/desktop/flow-build-phase-7.md +297 -297
  35. package/prompts/desktop/flow-build-phase-8.md +541 -541
  36. package/prompts/desktop/flow-build-phase-9.md +439 -439
  37. package/prompts/desktop/flow-build.md +156 -156
  38. package/prompts/desktop/flow-check-review.md +20 -20
  39. package/prompts/desktop/flow-check-test.md +14 -14
  40. package/prompts/desktop/flow-check.md +67 -67
  41. package/prompts/desktop/flow-commit.md +119 -119
  42. package/prompts/desktop/flow-docs-sync.md +354 -354
  43. package/prompts/desktop/flow-work-feature.md +61 -61
  44. package/prompts/desktop/flow-work-fix.md +46 -46
  45. package/prompts/desktop/flow-work-refactor.md +48 -48
  46. package/prompts/desktop/flow-work-resume.md +34 -34
  47. package/prompts/desktop/flow-work.md +1390 -1023
  48. package/prompts/frontend/flow-build-phase-0.md +425 -425
  49. package/prompts/frontend/flow-build-phase-1.md +626 -626
  50. package/prompts/frontend/flow-build-phase-10.md +33 -33
  51. package/prompts/frontend/flow-build-phase-2.md +573 -573
  52. package/prompts/frontend/flow-build-phase-3.md +782 -782
  53. package/prompts/frontend/flow-build-phase-4.md +554 -554
  54. package/prompts/frontend/flow-build-phase-5.md +703 -703
  55. package/prompts/frontend/flow-build-phase-6.md +524 -524
  56. package/prompts/frontend/flow-build-phase-7.md +1001 -1001
  57. package/prompts/frontend/flow-build-phase-8.md +872 -872
  58. package/prompts/frontend/flow-build-phase-9.md +94 -94
  59. package/prompts/frontend/flow-build.md +137 -137
  60. package/prompts/frontend/flow-check-review.md +20 -20
  61. package/prompts/frontend/flow-check-test.md +14 -14
  62. package/prompts/frontend/flow-check.md +67 -67
  63. package/prompts/frontend/flow-commit.md +119 -119
  64. package/prompts/frontend/flow-docs-sync.md +550 -550
  65. package/prompts/frontend/flow-work-feature.md +61 -61
  66. package/prompts/frontend/flow-work-fix.md +38 -38
  67. package/prompts/frontend/flow-work-refactor.md +48 -48
  68. package/prompts/frontend/flow-work-resume.md +34 -34
  69. package/prompts/frontend/flow-work.md +1320 -1027
  70. package/prompts/mobile/flow-build-phase-0.md +425 -425
  71. package/prompts/mobile/flow-build-phase-1.md +626 -626
  72. package/prompts/mobile/flow-build-phase-10.md +32 -32
  73. package/prompts/mobile/flow-build-phase-2.md +573 -573
  74. package/prompts/mobile/flow-build-phase-3.md +782 -782
  75. package/prompts/mobile/flow-build-phase-4.md +554 -554
  76. package/prompts/mobile/flow-build-phase-5.md +703 -703
  77. package/prompts/mobile/flow-build-phase-6.md +524 -524
  78. package/prompts/mobile/flow-build-phase-7.md +1001 -1001
  79. package/prompts/mobile/flow-build-phase-8.md +888 -888
  80. package/prompts/mobile/flow-build-phase-9.md +90 -90
  81. package/prompts/mobile/flow-build.md +135 -135
  82. package/prompts/mobile/flow-check-review.md +20 -20
  83. package/prompts/mobile/flow-check-test.md +14 -14
  84. package/prompts/mobile/flow-check.md +67 -67
  85. package/prompts/mobile/flow-commit.md +119 -119
  86. package/prompts/mobile/flow-docs-sync.md +620 -620
  87. package/prompts/mobile/flow-work-feature.md +61 -61
  88. package/prompts/mobile/flow-work-fix.md +46 -46
  89. package/prompts/mobile/flow-work-refactor.md +48 -48
  90. package/prompts/mobile/flow-work-resume.md +34 -34
  91. package/prompts/mobile/flow-work.md +1329 -1023
  92. package/prompts/shared/mermaid-guidelines.md +102 -102
  93. package/prompts/shared/scope-levels.md +114 -114
  94. package/prompts/shared/smart-skip-preflight.md +214 -214
  95. package/prompts/shared/story-points.md +55 -55
  96. package/prompts/shared/task-format.md +74 -74
  97. package/prompts/shared/task-summary-template.md +277 -277
  98. package/templates/AGENT.template.md +443 -443
  99. package/templates/backend/.clauderules.template +112 -112
  100. package/templates/backend/.cursorrules.template +102 -102
  101. package/templates/backend/README.template.md +2 -2
  102. package/templates/backend/ai-instructions.template.md +2 -2
  103. package/templates/backend/copilot-instructions.template.md +2 -2
  104. package/templates/backend/docs/api.template.md +320 -320
  105. package/templates/backend/docs/business-flows.template.md +97 -97
  106. package/templates/backend/docs/code-standards.template.md +2 -2
  107. package/templates/backend/docs/contributing.template.md +3 -3
  108. package/templates/backend/docs/data-model.template.md +520 -520
  109. package/templates/backend/docs/testing.template.md +2 -2
  110. package/templates/backend/project-brief.template.md +2 -2
  111. package/templates/backend/specs/configuration.template.md +2 -2
  112. package/templates/backend/specs/security.template.md +2 -2
  113. package/templates/desktop/.clauderules.template +112 -112
  114. package/templates/desktop/.cursorrules.template +102 -102
  115. package/templates/desktop/README.template.md +170 -170
  116. package/templates/desktop/ai-instructions.template.md +366 -366
  117. package/templates/desktop/copilot-instructions.template.md +140 -140
  118. package/templates/desktop/docs/docs/api.template.md +320 -320
  119. package/templates/desktop/docs/docs/architecture.template.md +724 -724
  120. package/templates/desktop/docs/docs/business-flows.template.md +102 -102
  121. package/templates/desktop/docs/docs/code-standards.template.md +792 -792
  122. package/templates/desktop/docs/docs/contributing.template.md +149 -149
  123. package/templates/desktop/docs/docs/data-model.template.md +520 -520
  124. package/templates/desktop/docs/docs/operations.template.md +720 -720
  125. package/templates/desktop/docs/docs/testing.template.md +722 -722
  126. package/templates/desktop/project-brief.template.md +150 -150
  127. package/templates/desktop/specs/specs/configuration.template.md +121 -121
  128. package/templates/desktop/specs/specs/security.template.md +392 -392
  129. package/templates/frontend/README.template.md +2 -2
  130. package/templates/frontend/ai-instructions.template.md +2 -2
  131. package/templates/frontend/docs/api-integration.template.md +362 -362
  132. package/templates/frontend/docs/components.template.md +2 -2
  133. package/templates/frontend/docs/error-handling.template.md +360 -360
  134. package/templates/frontend/docs/operations.template.md +107 -107
  135. package/templates/frontend/docs/performance.template.md +124 -124
  136. package/templates/frontend/docs/pwa.template.md +119 -119
  137. package/templates/frontend/docs/state-management.template.md +2 -2
  138. package/templates/frontend/docs/styling.template.md +2 -2
  139. package/templates/frontend/docs/testing.template.md +2 -2
  140. package/templates/frontend/project-brief.template.md +2 -2
  141. package/templates/frontend/specs/accessibility.template.md +95 -95
  142. package/templates/frontend/specs/configuration.template.md +2 -2
  143. package/templates/frontend/specs/security.template.md +175 -175
  144. package/templates/fullstack/README.template.md +252 -252
  145. package/templates/fullstack/ai-instructions.template.md +444 -444
  146. package/templates/fullstack/project-brief.template.md +157 -157
  147. package/templates/fullstack/specs/configuration.template.md +340 -340
  148. package/templates/mobile/README.template.md +167 -167
  149. package/templates/mobile/ai-instructions.template.md +196 -196
  150. package/templates/mobile/docs/app-store.template.md +135 -135
  151. package/templates/mobile/docs/architecture.template.md +63 -63
  152. package/templates/mobile/docs/native-features.template.md +94 -94
  153. package/templates/mobile/docs/navigation.template.md +59 -59
  154. package/templates/mobile/docs/offline-strategy.template.md +65 -65
  155. package/templates/mobile/docs/permissions.template.md +56 -56
  156. package/templates/mobile/docs/state-management.template.md +85 -85
  157. package/templates/mobile/docs/testing.template.md +109 -109
  158. package/templates/mobile/project-brief.template.md +69 -69
  159. package/templates/mobile/specs/build-configuration.template.md +91 -91
  160. package/templates/mobile/specs/deployment.template.md +92 -92
  161. package/templates/work.template.md +47 -47
@@ -1,722 +1,722 @@
1
- # Testing Strategy
2
-
3
- > Testing approach, standards, and quality requirements for {{PROJECT_NAME}}
4
- ---
5
- ## 🎯 Testing Philosophy
6
-
7
- {{TESTING_PHILOSOPHY}}
8
-
9
- **Quality Gates:**
10
- - Minimum {{MIN_COVERAGE}}% code coverage
11
- - All tests must pass before merge
12
- - No skipped tests in main branch
13
- - Critical paths require integration tests
14
- ---
15
- ## 🧪 Testing Framework
16
-
17
- **Primary Framework:** {{TEST_FRAMEWORK}}
18
-
19
- **Assertion Library:** {{ASSERTION_LIBRARY}}
20
-
21
- **Mocking Library:** {{MOCKING_LIBRARY}}
22
-
23
- **Test Runner:** {{TEST_RUNNER}}
24
- ---
25
- ## 📊 Test Types
26
-
27
- ### Unit Tests ({{UNIT_TEST_PERCENTAGE}}% of tests)
28
-
29
- **Purpose:** Test individual functions/methods in isolation
30
-
31
- **Characteristics:**
32
- - Fast execution (milliseconds)
33
- - No external dependencies
34
- - Mock all dependencies
35
- - Test single responsibility
36
-
37
- **Coverage Target:** {{UNIT_COVERAGE_TARGET}}%+
38
-
39
- **What to test:**
40
- - ✅ Services and business logic
41
- - ✅ Utilities and helpers
42
- - ✅ Pure functions
43
- - ✅ Validation logic
44
- - ✅ Transformations and calculations
45
-
46
- **What NOT to test:**
47
- - ❌ Framework code
48
- - ❌ Third-party libraries
49
- - ❌ Simple getters/setters
50
- - ❌ DTOs without logic
51
-
52
- **Example:**
53
- ```{{LANGUAGE}}
54
- {{UNIT_TEST_EXAMPLE}}
55
- ```
56
-
57
- ### Integration Tests ({{INTEGRATION_TEST_PERCENTAGE}}% of tests)
58
-
59
- **Purpose:** Test multiple components working together
60
-
61
- **Characteristics:**
62
- - Slower than unit tests (seconds)
63
- - Real database {{#IF_TEST_DB}}({{TEST_DB_TYPE}}){{/IF_TEST_DB}}
64
- - Real external service connections (or reliable mocks)
65
- - Test data flow through layers
66
-
67
- **Coverage Target:** {{INTEGRATION_COVERAGE_TARGET}}%+
68
-
69
- **What to test:**
70
- - ✅ Controller → Service → Repository flow
71
- - ✅ Database queries and transactions
72
- - ✅ Authentication/Authorization flows
73
- - ✅ Critical business workflows
74
- - ✅ External API integrations
75
-
76
- **Example:**
77
- ```{{LANGUAGE}}
78
- {{INTEGRATION_TEST_EXAMPLE}}
79
- ```
80
-
81
- ### End-to-End Tests ({{E2E_TEST_PERCENTAGE}}% of tests)
82
-
83
- **Purpose:** Test complete user flows from API request to response
84
-
85
- **Characteristics:**
86
- - Slowest (seconds to minutes)
87
- - Full application stack
88
- - Real database
89
- - Real HTTP requests
90
-
91
- **Coverage Target:** {{E2E_COVERAGE_TARGET}}%+
92
-
93
- **What to test:**
94
- - ✅ Critical user journeys
95
- - ✅ Authentication flows (login, signup, password reset)
96
- - ✅ Core business processes
97
- - ✅ Payment flows
98
- - ✅ Data export/import
99
-
100
- **Tool:** {{E2E_TOOL}}
101
-
102
- **Example:**
103
- ```{{LANGUAGE}}
104
- {{E2E_TEST_EXAMPLE}}
105
- ```
106
-
107
- {{#IF CONTRACT_TESTS}}
108
- ### Contract Tests
109
-
110
- **Purpose:** Verify API contracts between services/consumers
111
-
112
- **Tool:** {{CONTRACT_TEST_TOOL}}
113
-
114
- **When to use:**
115
- - Microservices architecture
116
- - External API consumers
117
- - Frontend/Backend contracts
118
-
119
- **Strategy:**
120
- - Consumer-driven contracts (CDC)
121
- - Provider contracts verification
122
- - Contract versioning
123
-
124
- **Example:**
125
- ```{{LANGUAGE}}
126
- {{CONTRACT_TEST_EXAMPLE}}
127
- ```
128
-
129
- **Contract Management:**
130
- - Contract storage: {{CONTRACT_STORAGE}}
131
- - Versioning: {{CONTRACT_VERSIONING}}
132
- - Breaking changes: {{CONTRACT_BREAKING_CHANGES}}
133
-
134
- {{/IF}}
135
-
136
- {{#IF PERFORMANCE_TESTS}}
137
- ### Performance Tests
138
-
139
- **Purpose:** Verify system performance under load
140
-
141
- **Tool:** {{PERFORMANCE_TEST_TOOL}}
142
-
143
- **Test Types:**
144
- - **Load Testing**: Normal expected load
145
- - **Stress Testing**: Beyond normal capacity
146
- - **Spike Testing**: Sudden load increases
147
- - **Endurance Testing**: Sustained load over time
148
-
149
- **Metrics:**
150
- - Response time (p50, p95, p99)
151
- - Throughput (requests/second)
152
- - Error rate
153
- - Resource usage (CPU, memory, disk, network)
154
-
155
- **Thresholds:**
156
- {{#EACH PERFORMANCE_THRESHOLD}}
157
- - {{METRIC_NAME}}: {{THRESHOLD_VALUE}}
158
- {{/EACH}}
159
-
160
- **Test Scenarios:**
161
- {{#EACH PERFORMANCE_SCENARIO}}
162
- #### {{SCENARIO_NAME}}
163
-
164
- - Load: {{SCENARIO_LOAD}}
165
- - Duration: {{SCENARIO_DURATION}}
166
- - Expected: {{SCENARIO_EXPECTED}}
167
- - Actual: {{SCENARIO_ACTUAL}}
168
-
169
- {{/EACH}}
170
-
171
- **Example:**
172
- ```{{LANGUAGE}}
173
- {{PERFORMANCE_TEST_EXAMPLE}}
174
- ```
175
-
176
- {{/IF}}
177
-
178
- {{#IF CHAOS_ENGINEERING}}
179
- ### Chaos Engineering
180
-
181
- **Purpose:** Test system resilience to failures
182
-
183
- **Tool:** {{CHAOS_TOOL}}
184
-
185
- **Chaos Experiments:**
186
- {{#EACH CHAOS_EXPERIMENT}}
187
- #### {{EXPERIMENT_NAME}}
188
-
189
- **Type:** {{EXPERIMENT_TYPE}}
190
-
191
- **Hypothesis:** {{EXPERIMENT_HYPOTHESIS}}
192
-
193
- **Method:**
194
- {{#EACH EXPERIMENT_STEP}}
195
- {{STEP_NUMBER}}. {{STEP_DESCRIPTION}}
196
- {{/EACH}}
197
-
198
- **Expected Behavior:** {{EXPERIMENT_EXPECTED}}
199
-
200
- **Results:** {{EXPERIMENT_RESULTS}}
201
-
202
- {{/EACH}}
203
-
204
- **Common Scenarios:**
205
- - Network latency injection
206
- - Service failures
207
- - Database connection failures
208
- - CPU/memory exhaustion
209
- - Disk space issues
210
-
211
- **Safety Rules:**
212
- - ✅ Run in staging first
213
- - ✅ Have rollback plan ready
214
- - ✅ Monitor metrics during experiments
215
- - ✅ Limit blast radius
216
- - ❌ Never run in production without approval
217
-
218
- {{/IF}}
219
- ---
220
- ## 📁 Test Organization
221
-
222
- ### File Structure
223
-
224
- **Pattern:** {{TEST_FILE_PATTERN}}
225
-
226
- {{#IF COLOCATED}}
227
- ### Co-located Tests
228
-
229
- ```
230
- src/
231
- users/
232
- user.service.ts
233
- user.service.spec.ts ← Unit tests
234
- user.controller.ts
235
- user.controller.spec.ts
236
- user.integration.spec.ts ← Integration tests
237
- ```
238
-
239
- {{ELSE}}
240
- ### Separate Test Directory
241
-
242
- ```
243
- src/
244
- users/
245
- user.service.ts
246
- user.controller.ts
247
-
248
- tests/
249
- unit/
250
- users/
251
- user.service.test.ts
252
- integration/
253
- users/
254
- user.integration.test.ts
255
- e2e/
256
- users/
257
- user.e2e.test.ts
258
- ```
259
-
260
- {{/IF}}
261
-
262
- ### Naming Conventions
263
-
264
- **Test Files:**
265
- ```
266
- {{TEST_FILE_NAMING_EXAMPLES}}
267
- ```
268
-
269
- **Test Descriptions:**
270
- ```{{LANGUAGE}}
271
- describe('{{DESCRIBE_EXAMPLE}}', () => {
272
- describe('{{METHOD_NAME}}', () => {
273
- it('should {{EXPECTED_BEHAVIOR}} when {{CONDITION}}', () => {
274
- // test implementation
275
- });
276
- });
277
- });
278
- ```
279
- ---
280
- ## 🎭 Mocking Strategy
281
-
282
- ### What to Mock
283
-
284
- ✅ **Always mock:**
285
- - External APIs (third-party services)
286
- - Payment gateways
287
- - Email/SMS services
288
- - File system operations (in unit tests)
289
- - Time/Date functions
290
- - Random number generators
291
-
292
- ❌ **Never mock:**
293
- - Internal business logic
294
- - Domain models
295
- - Value objects
296
- - Simple utilities
297
-
298
- ### Mocking Patterns
299
-
300
- #### Database Mocking (Unit Tests)
301
-
302
- ```{{LANGUAGE}}
303
- {{DATABASE_MOCK_EXAMPLE}}
304
- ```
305
-
306
- #### External API Mocking
307
-
308
- ```{{LANGUAGE}}
309
- {{EXTERNAL_API_MOCK_EXAMPLE}}
310
- ```
311
-
312
- #### Time Mocking
313
-
314
- ```{{LANGUAGE}}
315
- {{TIME_MOCK_EXAMPLE}}
316
- ```
317
- ---
318
- ## 🗄️ Test Database
319
-
320
- ### Strategy
321
-
322
- {{TEST_DB_STRATEGY}}
323
-
324
- {{#IF IN_MEMORY_DB}}
325
- ### In-Memory Database
326
-
327
- **Type:** {{IN_MEMORY_DB_TYPE}}
328
-
329
- **Benefits:**
330
- - Fast test execution
331
- - Isolated tests
332
- - No cleanup needed
333
-
334
- **Limitations:**
335
- - Different DB from production
336
- - Some features may not work identically
337
-
338
- {{/IF}}
339
-
340
- {{#IF DOCKER_TEST_DB}}
341
- ### Docker Test Database
342
-
343
- **Image:** {{TEST_DB_IMAGE}}
344
-
345
- **Tool:** {{TEST_CONTAINER_TOOL}}
346
-
347
- **Benefits:**
348
- - Same database as production
349
- - Realistic testing
350
- - Isolated per test run
351
-
352
- **Setup:**
353
- ```bash
354
- {{TEST_DB_SETUP_COMMAND}}
355
- ```
356
-
357
- {{/IF}}
358
-
359
- ### Database Seeding
360
-
361
- **Strategy:** {{DB_SEED_STRATEGY}}
362
-
363
- ```{{LANGUAGE}}
364
- {{DB_SEED_EXAMPLE}}
365
- ```
366
-
367
- ### Database Cleanup
368
-
369
- **When:** {{DB_CLEANUP_WHEN}}
370
-
371
- ```{{LANGUAGE}}
372
- {{DB_CLEANUP_EXAMPLE}}
373
- ```
374
- ---
375
- ## 🏭 Test Data Factories
376
-
377
- **Library:** {{FACTORY_LIBRARY}}
378
-
379
- **Location:** `{{FACTORY_LOCATION}}`
380
-
381
- ### Factory Example
382
-
383
- ```{{LANGUAGE}}
384
- {{FACTORY_EXAMPLE}}
385
- ```
386
-
387
- ### Usage
388
-
389
- ```{{LANGUAGE}}
390
- {{FACTORY_USAGE_EXAMPLE}}
391
- ```
392
-
393
- ### Factory Rules
394
-
395
- - ✅ Use factories for all test entities
396
- - ✅ Provide sensible defaults
397
- - ✅ Allow overrides for specific tests
398
- - ✅ Keep factories DRY
399
- - ❌ Don't hardcode test data in tests
400
- ---
401
- ## ✅ Test Structure
402
-
403
- ### AAA Pattern (Arrange, Act, Assert)
404
-
405
- ```{{LANGUAGE}}
406
- {{AAA_PATTERN_EXAMPLE}}
407
- ```
408
-
409
- ### Given-When-Then (BDD)
410
-
411
- ```{{LANGUAGE}}
412
- {{GIVEN_WHEN_THEN_EXAMPLE}}
413
- ```
414
- ---
415
- ## 🎯 Testing Best Practices
416
-
417
- ### General
418
-
419
- - ✅ Tests should be independent (no test order dependency)
420
- - ✅ Tests should be deterministic (same result every time)
421
- - ✅ Tests should be fast (especially unit tests)
422
- - ✅ Test names should clearly describe what they test
423
- - ✅ One assertion per test (when possible)
424
- - ✅ Test edge cases and error conditions
425
- - ❌ Don't test implementation details
426
- - ❌ Don't write tests that depend on each other
427
- - ❌ Don't test external libraries
428
-
429
- ### Test Coverage
430
-
431
- **Minimum Requirements:**
432
- - Overall: {{MIN_COVERAGE}}%
433
- - Services: {{SERVICE_COVERAGE}}%
434
- - Controllers: {{CONTROLLER_COVERAGE}}%
435
- - Repositories: {{REPOSITORY_COVERAGE}}%
436
- - Utilities: {{UTILITY_COVERAGE}}%
437
-
438
- **Exceptions (don't need 100% coverage):**
439
- - Configuration files
440
- - DTOs without logic
441
- - Simple CRUD operations
442
- - Type definitions
443
-
444
- ### What to Test
445
-
446
- ✅ **Do test:**
447
- - Happy path (expected behavior)
448
- - Error cases (validation, not found, unauthorized)
449
- - Edge cases (empty arrays, null values, boundaries)
450
- - Security (authentication, authorization)
451
- - Business rules
452
- - Data transformations
453
-
454
- ❌ **Don't test:**
455
- - Framework behavior
456
- - External libraries
457
- - Getters/setters without logic
458
- - Auto-generated code
459
- ---
460
- ## 🔧 Test Configuration
461
-
462
- ### Jest Configuration
463
-
464
- **File:** `{{JEST_CONFIG_FILE}}`
465
-
466
- ```javascript
467
- {{JEST_CONFIG_EXAMPLE}}
468
- ```
469
-
470
- ### Test Scripts
471
-
472
- ```json
473
- {
474
- "scripts": {
475
- "test": "{{TEST_COMMAND}}",
476
- "test:unit": "{{TEST_UNIT_COMMAND}}",
477
- "test:integration": "{{TEST_INTEGRATION_COMMAND}}",
478
- "test:e2e": "{{TEST_E2E_COMMAND}}",
479
- "test:watch": "{{TEST_WATCH_COMMAND}}",
480
- "test:coverage": "{{TEST_COVERAGE_COMMAND}}",
481
- "test:debug": "{{TEST_DEBUG_COMMAND}}"
482
- }
483
- }
484
- ```
485
- ---
486
- ## 🚀 Running Tests
487
-
488
- ### Local Development
489
-
490
- ```bash
491
- # Run all tests
492
- {{RUN_ALL_TESTS}}
493
-
494
- # Run tests in watch mode
495
- {{RUN_TESTS_WATCH}}
496
-
497
- # Run specific test file
498
- {{RUN_SPECIFIC_TEST}}
499
-
500
- # Run tests matching pattern
501
- {{RUN_TESTS_PATTERN}}
502
-
503
- # Run with coverage
504
- {{RUN_TESTS_COVERAGE}}
505
-
506
- # Debug tests
507
- {{DEBUG_TESTS}}
508
- ```
509
-
510
- ### CI/CD
511
-
512
- **Platform:** {{CICD_PLATFORM}}
513
-
514
- **When tests run:**
515
- {{#EACH TEST_TRIGGER}}
516
- - {{TRIGGER_DESCRIPTION}}
517
- {{/EACH}}
518
-
519
- **Pipeline configuration:**
520
- ```yaml
521
- {{CICD_TEST_CONFIG}}
522
- ```
523
- ---
524
- ## 📊 Coverage Reports
525
-
526
- ### Viewing Coverage
527
-
528
- ```bash
529
- {{COVERAGE_COMMAND}}
530
- ```
531
-
532
- **Coverage Report Location:** `{{COVERAGE_OUTPUT_DIR}}`
533
-
534
- **Formats:**
535
- - HTML: `{{COVERAGE_HTML_PATH}}`
536
- - LCOV: `{{COVERAGE_LCOV_PATH}}`
537
- - Text: Console output
538
-
539
- ### Coverage Thresholds
540
-
541
- ```javascript
542
- {
543
- "coverageThreshold": {
544
- "global": {
545
- "branches": {{BRANCH_COVERAGE}},
546
- "functions": {{FUNCTION_COVERAGE}},
547
- "lines": {{LINE_COVERAGE}},
548
- "statements": {{STATEMENT_COVERAGE}}
549
- }
550
- }
551
- }
552
- ```
553
-
554
- **Enforcement:** Tests fail if coverage drops below thresholds
555
- ---
556
- ## 🧬 Test Examples
557
-
558
- ### Service Test
559
-
560
- ```{{LANGUAGE}}
561
- {{SERVICE_TEST_FULL_EXAMPLE}}
562
- ```
563
-
564
- ### Controller Test
565
-
566
- ```{{LANGUAGE}}
567
- {{CONTROLLER_TEST_FULL_EXAMPLE}}
568
- ```
569
-
570
- ### Repository Test
571
-
572
- ```{{LANGUAGE}}
573
- {{REPOSITORY_TEST_FULL_EXAMPLE}}
574
- ```
575
-
576
- ### E2E Test
577
-
578
- ```{{LANGUAGE}}
579
- {{E2E_TEST_FULL_EXAMPLE}}
580
- ```
581
- ---
582
- ## 🔒 Testing Security
583
-
584
- ### Authentication Tests
585
-
586
- ```{{LANGUAGE}}
587
- {{AUTH_TEST_EXAMPLE}}
588
- ```
589
-
590
- ### Authorization Tests
591
-
592
- ```{{LANGUAGE}}
593
- {{AUTHZ_TEST_EXAMPLE}}
594
- ```
595
-
596
- ### Input Validation Tests
597
-
598
- ```{{LANGUAGE}}
599
- {{INPUT_VALIDATION_TEST_EXAMPLE}}
600
- ```
601
- ---
602
- ## 🐛 Debugging Tests
603
-
604
- ### Debug Configuration
605
-
606
- **VS Code:**
607
- ```json
608
- {{VSCODE_DEBUG_CONFIG}}
609
- ```
610
-
611
- ### Debug Commands
612
-
613
- ```bash
614
- # Debug specific test
615
- {{DEBUG_SPECIFIC_TEST}}
616
-
617
- # Debug with breakpoints
618
- {{DEBUG_WITH_BREAKPOINTS}}
619
- ```
620
- ---
621
- ## 📝 Test Documentation
622
-
623
- ### When to Document Tests
624
-
625
- - ✅ Complex test setups
626
- - ✅ Non-obvious mocking strategies
627
- - ✅ Performance test configurations
628
- - ✅ Flaky test explanations
629
-
630
- ### Example
631
-
632
- ```{{LANGUAGE}}
633
- /**
634
- * Tests the order calculation logic with multiple edge cases.
635
- *
636
- * This test verifies:
637
- * 1. Basic order total calculation
638
- * 2. Tax application
639
- * 3. Discount code validation
640
- * 4. Edge case: zero-price items
641
- * 5. Edge case: 100% discount
642
- *
643
- * Mock strategy:
644
- * - DiscountService is mocked to avoid external API calls
645
- * - TaxService uses real implementation for accuracy
646
- */
647
- describe('Order Total Calculation', () => {
648
- // tests...
649
- });
650
- ```
651
- ---
652
- ## 🚨 Continuous Testing
653
-
654
- ### Pre-commit Hooks
655
-
656
- ```bash
657
- {{PRE_COMMIT_HOOK_CONFIG}}
658
- ```
659
-
660
- **Runs:**
661
- - Linting
662
- - Unit tests
663
- - Type checking
664
-
665
- ### Pre-push Hooks
666
-
667
- ```bash
668
- {{PRE_PUSH_HOOK_CONFIG}}
669
- ```
670
-
671
- **Runs:**
672
- - Full test suite
673
- - Coverage check
674
- ---
675
- ## 📈 Test Metrics
676
-
677
- ### Tracked Metrics
678
-
679
- - Test count (unit, integration, e2e)
680
- - Test execution time
681
- - Code coverage (overall, per type)
682
- - Flaky test rate
683
- - Test failure rate
684
-
685
- ### Goals
686
-
687
- {{#EACH TEST_GOAL}}
688
- - **{{GOAL_NAME}}**: {{GOAL_TARGET}}
689
- {{/EACH}}
690
- ---
691
- ## 🔄 Test Maintenance
692
-
693
- ### Regular Tasks
694
-
695
- - ✅ Update tests when code changes
696
- - ✅ Remove obsolete tests
697
- - ✅ Fix flaky tests immediately
698
- - ✅ Refactor tests alongside code
699
- - ✅ Update test data periodically
700
-
701
- ### Code Review Checklist
702
-
703
- - [ ] New code has tests
704
- - [ ] Tests are meaningful (not just for coverage)
705
- - [ ] Tests pass locally
706
- - [ ] Coverage meets threshold
707
- - [ ] No skipped/disabled tests (without reason)
708
- - [ ] Test names are descriptive
709
- ---
710
- ## 📚 Resources
711
-
712
- {{#EACH TESTING_RESOURCE}}
713
- - [{{RESOURCE_NAME}}]({{RESOURCE_URL}})
714
- {{/EACH}}
715
- ---
716
- **Document Version:** 1.0
717
-
718
- **Last Updated:** {{GENERATION_DATE}}
719
-
720
- **Generated by:** AI Flow v1.0.0
721
-
722
-
1
+ # Testing Strategy
2
+
3
+ > Testing approach, standards, and quality requirements for {{PROJECT_NAME}}
4
+ ---
5
+ ## 🎯 Testing Philosophy
6
+
7
+ {{TESTING_PHILOSOPHY}}
8
+
9
+ **Quality Gates:**
10
+ - Minimum {{MIN_COVERAGE}}% code coverage
11
+ - All tests must pass before merge
12
+ - No skipped tests in main branch
13
+ - Critical paths require integration tests
14
+ ---
15
+ ## 🧪 Testing Framework
16
+
17
+ **Primary Framework:** {{TEST_FRAMEWORK}}
18
+
19
+ **Assertion Library:** {{ASSERTION_LIBRARY}}
20
+
21
+ **Mocking Library:** {{MOCKING_LIBRARY}}
22
+
23
+ **Test Runner:** {{TEST_RUNNER}}
24
+ ---
25
+ ## 📊 Test Types
26
+
27
+ ### Unit Tests ({{UNIT_TEST_PERCENTAGE}}% of tests)
28
+
29
+ **Purpose:** Test individual functions/methods in isolation
30
+
31
+ **Characteristics:**
32
+ - Fast execution (milliseconds)
33
+ - No external dependencies
34
+ - Mock all dependencies
35
+ - Test single responsibility
36
+
37
+ **Coverage Target:** {{UNIT_COVERAGE_TARGET}}%+
38
+
39
+ **What to test:**
40
+ - ✅ Services and business logic
41
+ - ✅ Utilities and helpers
42
+ - ✅ Pure functions
43
+ - ✅ Validation logic
44
+ - ✅ Transformations and calculations
45
+
46
+ **What NOT to test:**
47
+ - ❌ Framework code
48
+ - ❌ Third-party libraries
49
+ - ❌ Simple getters/setters
50
+ - ❌ DTOs without logic
51
+
52
+ **Example:**
53
+ ```{{LANGUAGE}}
54
+ {{UNIT_TEST_EXAMPLE}}
55
+ ```
56
+
57
+ ### Integration Tests ({{INTEGRATION_TEST_PERCENTAGE}}% of tests)
58
+
59
+ **Purpose:** Test multiple components working together
60
+
61
+ **Characteristics:**
62
+ - Slower than unit tests (seconds)
63
+ - Real database {{#IF_TEST_DB}}({{TEST_DB_TYPE}}){{/IF_TEST_DB}}
64
+ - Real external service connections (or reliable mocks)
65
+ - Test data flow through layers
66
+
67
+ **Coverage Target:** {{INTEGRATION_COVERAGE_TARGET}}%+
68
+
69
+ **What to test:**
70
+ - ✅ Controller → Service → Repository flow
71
+ - ✅ Database queries and transactions
72
+ - ✅ Authentication/Authorization flows
73
+ - ✅ Critical business workflows
74
+ - ✅ External API integrations
75
+
76
+ **Example:**
77
+ ```{{LANGUAGE}}
78
+ {{INTEGRATION_TEST_EXAMPLE}}
79
+ ```
80
+
81
+ ### End-to-End Tests ({{E2E_TEST_PERCENTAGE}}% of tests)
82
+
83
+ **Purpose:** Test complete user flows from API request to response
84
+
85
+ **Characteristics:**
86
+ - Slowest (seconds to minutes)
87
+ - Full application stack
88
+ - Real database
89
+ - Real HTTP requests
90
+
91
+ **Coverage Target:** {{E2E_COVERAGE_TARGET}}%+
92
+
93
+ **What to test:**
94
+ - ✅ Critical user journeys
95
+ - ✅ Authentication flows (login, signup, password reset)
96
+ - ✅ Core business processes
97
+ - ✅ Payment flows
98
+ - ✅ Data export/import
99
+
100
+ **Tool:** {{E2E_TOOL}}
101
+
102
+ **Example:**
103
+ ```{{LANGUAGE}}
104
+ {{E2E_TEST_EXAMPLE}}
105
+ ```
106
+
107
+ {{#IF CONTRACT_TESTS}}
108
+ ### Contract Tests
109
+
110
+ **Purpose:** Verify API contracts between services/consumers
111
+
112
+ **Tool:** {{CONTRACT_TEST_TOOL}}
113
+
114
+ **When to use:**
115
+ - Microservices architecture
116
+ - External API consumers
117
+ - Frontend/Backend contracts
118
+
119
+ **Strategy:**
120
+ - Consumer-driven contracts (CDC)
121
+ - Provider contracts verification
122
+ - Contract versioning
123
+
124
+ **Example:**
125
+ ```{{LANGUAGE}}
126
+ {{CONTRACT_TEST_EXAMPLE}}
127
+ ```
128
+
129
+ **Contract Management:**
130
+ - Contract storage: {{CONTRACT_STORAGE}}
131
+ - Versioning: {{CONTRACT_VERSIONING}}
132
+ - Breaking changes: {{CONTRACT_BREAKING_CHANGES}}
133
+
134
+ {{/IF}}
135
+
136
+ {{#IF PERFORMANCE_TESTS}}
137
+ ### Performance Tests
138
+
139
+ **Purpose:** Verify system performance under load
140
+
141
+ **Tool:** {{PERFORMANCE_TEST_TOOL}}
142
+
143
+ **Test Types:**
144
+ - **Load Testing**: Normal expected load
145
+ - **Stress Testing**: Beyond normal capacity
146
+ - **Spike Testing**: Sudden load increases
147
+ - **Endurance Testing**: Sustained load over time
148
+
149
+ **Metrics:**
150
+ - Response time (p50, p95, p99)
151
+ - Throughput (requests/second)
152
+ - Error rate
153
+ - Resource usage (CPU, memory, disk, network)
154
+
155
+ **Thresholds:**
156
+ {{#EACH PERFORMANCE_THRESHOLD}}
157
+ - {{METRIC_NAME}}: {{THRESHOLD_VALUE}}
158
+ {{/EACH}}
159
+
160
+ **Test Scenarios:**
161
+ {{#EACH PERFORMANCE_SCENARIO}}
162
+ #### {{SCENARIO_NAME}}
163
+
164
+ - Load: {{SCENARIO_LOAD}}
165
+ - Duration: {{SCENARIO_DURATION}}
166
+ - Expected: {{SCENARIO_EXPECTED}}
167
+ - Actual: {{SCENARIO_ACTUAL}}
168
+
169
+ {{/EACH}}
170
+
171
+ **Example:**
172
+ ```{{LANGUAGE}}
173
+ {{PERFORMANCE_TEST_EXAMPLE}}
174
+ ```
175
+
176
+ {{/IF}}
177
+
178
+ {{#IF CHAOS_ENGINEERING}}
179
+ ### Chaos Engineering
180
+
181
+ **Purpose:** Test system resilience to failures
182
+
183
+ **Tool:** {{CHAOS_TOOL}}
184
+
185
+ **Chaos Experiments:**
186
+ {{#EACH CHAOS_EXPERIMENT}}
187
+ #### {{EXPERIMENT_NAME}}
188
+
189
+ **Type:** {{EXPERIMENT_TYPE}}
190
+
191
+ **Hypothesis:** {{EXPERIMENT_HYPOTHESIS}}
192
+
193
+ **Method:**
194
+ {{#EACH EXPERIMENT_STEP}}
195
+ {{STEP_NUMBER}}. {{STEP_DESCRIPTION}}
196
+ {{/EACH}}
197
+
198
+ **Expected Behavior:** {{EXPERIMENT_EXPECTED}}
199
+
200
+ **Results:** {{EXPERIMENT_RESULTS}}
201
+
202
+ {{/EACH}}
203
+
204
+ **Common Scenarios:**
205
+ - Network latency injection
206
+ - Service failures
207
+ - Database connection failures
208
+ - CPU/memory exhaustion
209
+ - Disk space issues
210
+
211
+ **Safety Rules:**
212
+ - ✅ Run in staging first
213
+ - ✅ Have rollback plan ready
214
+ - ✅ Monitor metrics during experiments
215
+ - ✅ Limit blast radius
216
+ - ❌ Never run in production without approval
217
+
218
+ {{/IF}}
219
+ ---
220
+ ## 📁 Test Organization
221
+
222
+ ### File Structure
223
+
224
+ **Pattern:** {{TEST_FILE_PATTERN}}
225
+
226
+ {{#IF COLOCATED}}
227
+ ### Co-located Tests
228
+
229
+ ```
230
+ src/
231
+ users/
232
+ user.service.ts
233
+ user.service.spec.ts ← Unit tests
234
+ user.controller.ts
235
+ user.controller.spec.ts
236
+ user.integration.spec.ts ← Integration tests
237
+ ```
238
+
239
+ {{ELSE}}
240
+ ### Separate Test Directory
241
+
242
+ ```
243
+ src/
244
+ users/
245
+ user.service.ts
246
+ user.controller.ts
247
+
248
+ tests/
249
+ unit/
250
+ users/
251
+ user.service.test.ts
252
+ integration/
253
+ users/
254
+ user.integration.test.ts
255
+ e2e/
256
+ users/
257
+ user.e2e.test.ts
258
+ ```
259
+
260
+ {{/IF}}
261
+
262
+ ### Naming Conventions
263
+
264
+ **Test Files:**
265
+ ```
266
+ {{TEST_FILE_NAMING_EXAMPLES}}
267
+ ```
268
+
269
+ **Test Descriptions:**
270
+ ```{{LANGUAGE}}
271
+ describe('{{DESCRIBE_EXAMPLE}}', () => {
272
+ describe('{{METHOD_NAME}}', () => {
273
+ it('should {{EXPECTED_BEHAVIOR}} when {{CONDITION}}', () => {
274
+ // test implementation
275
+ });
276
+ });
277
+ });
278
+ ```
279
+ ---
280
+ ## 🎭 Mocking Strategy
281
+
282
+ ### What to Mock
283
+
284
+ ✅ **Always mock:**
285
+ - External APIs (third-party services)
286
+ - Payment gateways
287
+ - Email/SMS services
288
+ - File system operations (in unit tests)
289
+ - Time/Date functions
290
+ - Random number generators
291
+
292
+ ❌ **Never mock:**
293
+ - Internal business logic
294
+ - Domain models
295
+ - Value objects
296
+ - Simple utilities
297
+
298
+ ### Mocking Patterns
299
+
300
+ #### Database Mocking (Unit Tests)
301
+
302
+ ```{{LANGUAGE}}
303
+ {{DATABASE_MOCK_EXAMPLE}}
304
+ ```
305
+
306
+ #### External API Mocking
307
+
308
+ ```{{LANGUAGE}}
309
+ {{EXTERNAL_API_MOCK_EXAMPLE}}
310
+ ```
311
+
312
+ #### Time Mocking
313
+
314
+ ```{{LANGUAGE}}
315
+ {{TIME_MOCK_EXAMPLE}}
316
+ ```
317
+ ---
318
+ ## 🗄️ Test Database
319
+
320
+ ### Strategy
321
+
322
+ {{TEST_DB_STRATEGY}}
323
+
324
+ {{#IF IN_MEMORY_DB}}
325
+ ### In-Memory Database
326
+
327
+ **Type:** {{IN_MEMORY_DB_TYPE}}
328
+
329
+ **Benefits:**
330
+ - Fast test execution
331
+ - Isolated tests
332
+ - No cleanup needed
333
+
334
+ **Limitations:**
335
+ - Different DB from production
336
+ - Some features may not work identically
337
+
338
+ {{/IF}}
339
+
340
+ {{#IF DOCKER_TEST_DB}}
341
+ ### Docker Test Database
342
+
343
+ **Image:** {{TEST_DB_IMAGE}}
344
+
345
+ **Tool:** {{TEST_CONTAINER_TOOL}}
346
+
347
+ **Benefits:**
348
+ - Same database as production
349
+ - Realistic testing
350
+ - Isolated per test run
351
+
352
+ **Setup:**
353
+ ```bash
354
+ {{TEST_DB_SETUP_COMMAND}}
355
+ ```
356
+
357
+ {{/IF}}
358
+
359
+ ### Database Seeding
360
+
361
+ **Strategy:** {{DB_SEED_STRATEGY}}
362
+
363
+ ```{{LANGUAGE}}
364
+ {{DB_SEED_EXAMPLE}}
365
+ ```
366
+
367
+ ### Database Cleanup
368
+
369
+ **When:** {{DB_CLEANUP_WHEN}}
370
+
371
+ ```{{LANGUAGE}}
372
+ {{DB_CLEANUP_EXAMPLE}}
373
+ ```
374
+ ---
375
+ ## 🏭 Test Data Factories
376
+
377
+ **Library:** {{FACTORY_LIBRARY}}
378
+
379
+ **Location:** `{{FACTORY_LOCATION}}`
380
+
381
+ ### Factory Example
382
+
383
+ ```{{LANGUAGE}}
384
+ {{FACTORY_EXAMPLE}}
385
+ ```
386
+
387
+ ### Usage
388
+
389
+ ```{{LANGUAGE}}
390
+ {{FACTORY_USAGE_EXAMPLE}}
391
+ ```
392
+
393
+ ### Factory Rules
394
+
395
+ - ✅ Use factories for all test entities
396
+ - ✅ Provide sensible defaults
397
+ - ✅ Allow overrides for specific tests
398
+ - ✅ Keep factories DRY
399
+ - ❌ Don't hardcode test data in tests
400
+ ---
401
+ ## ✅ Test Structure
402
+
403
+ ### AAA Pattern (Arrange, Act, Assert)
404
+
405
+ ```{{LANGUAGE}}
406
+ {{AAA_PATTERN_EXAMPLE}}
407
+ ```
408
+
409
+ ### Given-When-Then (BDD)
410
+
411
+ ```{{LANGUAGE}}
412
+ {{GIVEN_WHEN_THEN_EXAMPLE}}
413
+ ```
414
+ ---
415
+ ## 🎯 Testing Best Practices
416
+
417
+ ### General
418
+
419
+ - ✅ Tests should be independent (no test order dependency)
420
+ - ✅ Tests should be deterministic (same result every time)
421
+ - ✅ Tests should be fast (especially unit tests)
422
+ - ✅ Test names should clearly describe what they test
423
+ - ✅ One assertion per test (when possible)
424
+ - ✅ Test edge cases and error conditions
425
+ - ❌ Don't test implementation details
426
+ - ❌ Don't write tests that depend on each other
427
+ - ❌ Don't test external libraries
428
+
429
+ ### Test Coverage
430
+
431
+ **Minimum Requirements:**
432
+ - Overall: {{MIN_COVERAGE}}%
433
+ - Services: {{SERVICE_COVERAGE}}%
434
+ - Controllers: {{CONTROLLER_COVERAGE}}%
435
+ - Repositories: {{REPOSITORY_COVERAGE}}%
436
+ - Utilities: {{UTILITY_COVERAGE}}%
437
+
438
+ **Exceptions (don't need 100% coverage):**
439
+ - Configuration files
440
+ - DTOs without logic
441
+ - Simple CRUD operations
442
+ - Type definitions
443
+
444
+ ### What to Test
445
+
446
+ ✅ **Do test:**
447
+ - Happy path (expected behavior)
448
+ - Error cases (validation, not found, unauthorized)
449
+ - Edge cases (empty arrays, null values, boundaries)
450
+ - Security (authentication, authorization)
451
+ - Business rules
452
+ - Data transformations
453
+
454
+ ❌ **Don't test:**
455
+ - Framework behavior
456
+ - External libraries
457
+ - Getters/setters without logic
458
+ - Auto-generated code
459
+ ---
460
+ ## 🔧 Test Configuration
461
+
462
+ ### Jest Configuration
463
+
464
+ **File:** `{{JEST_CONFIG_FILE}}`
465
+
466
+ ```javascript
467
+ {{JEST_CONFIG_EXAMPLE}}
468
+ ```
469
+
470
+ ### Test Scripts
471
+
472
+ ```json
473
+ {
474
+ "scripts": {
475
+ "test": "{{TEST_COMMAND}}",
476
+ "test:unit": "{{TEST_UNIT_COMMAND}}",
477
+ "test:integration": "{{TEST_INTEGRATION_COMMAND}}",
478
+ "test:e2e": "{{TEST_E2E_COMMAND}}",
479
+ "test:watch": "{{TEST_WATCH_COMMAND}}",
480
+ "test:coverage": "{{TEST_COVERAGE_COMMAND}}",
481
+ "test:debug": "{{TEST_DEBUG_COMMAND}}"
482
+ }
483
+ }
484
+ ```
485
+ ---
486
+ ## 🚀 Running Tests
487
+
488
+ ### Local Development
489
+
490
+ ```bash
491
+ # Run all tests
492
+ {{RUN_ALL_TESTS}}
493
+
494
+ # Run tests in watch mode
495
+ {{RUN_TESTS_WATCH}}
496
+
497
+ # Run specific test file
498
+ {{RUN_SPECIFIC_TEST}}
499
+
500
+ # Run tests matching pattern
501
+ {{RUN_TESTS_PATTERN}}
502
+
503
+ # Run with coverage
504
+ {{RUN_TESTS_COVERAGE}}
505
+
506
+ # Debug tests
507
+ {{DEBUG_TESTS}}
508
+ ```
509
+
510
+ ### CI/CD
511
+
512
+ **Platform:** {{CICD_PLATFORM}}
513
+
514
+ **When tests run:**
515
+ {{#EACH TEST_TRIGGER}}
516
+ - {{TRIGGER_DESCRIPTION}}
517
+ {{/EACH}}
518
+
519
+ **Pipeline configuration:**
520
+ ```yaml
521
+ {{CICD_TEST_CONFIG}}
522
+ ```
523
+ ---
524
+ ## 📊 Coverage Reports
525
+
526
+ ### Viewing Coverage
527
+
528
+ ```bash
529
+ {{COVERAGE_COMMAND}}
530
+ ```
531
+
532
+ **Coverage Report Location:** `{{COVERAGE_OUTPUT_DIR}}`
533
+
534
+ **Formats:**
535
+ - HTML: `{{COVERAGE_HTML_PATH}}`
536
+ - LCOV: `{{COVERAGE_LCOV_PATH}}`
537
+ - Text: Console output
538
+
539
+ ### Coverage Thresholds
540
+
541
+ ```javascript
542
+ {
543
+ "coverageThreshold": {
544
+ "global": {
545
+ "branches": {{BRANCH_COVERAGE}},
546
+ "functions": {{FUNCTION_COVERAGE}},
547
+ "lines": {{LINE_COVERAGE}},
548
+ "statements": {{STATEMENT_COVERAGE}}
549
+ }
550
+ }
551
+ }
552
+ ```
553
+
554
+ **Enforcement:** Tests fail if coverage drops below thresholds
555
+ ---
556
+ ## 🧬 Test Examples
557
+
558
+ ### Service Test
559
+
560
+ ```{{LANGUAGE}}
561
+ {{SERVICE_TEST_FULL_EXAMPLE}}
562
+ ```
563
+
564
+ ### Controller Test
565
+
566
+ ```{{LANGUAGE}}
567
+ {{CONTROLLER_TEST_FULL_EXAMPLE}}
568
+ ```
569
+
570
+ ### Repository Test
571
+
572
+ ```{{LANGUAGE}}
573
+ {{REPOSITORY_TEST_FULL_EXAMPLE}}
574
+ ```
575
+
576
+ ### E2E Test
577
+
578
+ ```{{LANGUAGE}}
579
+ {{E2E_TEST_FULL_EXAMPLE}}
580
+ ```
581
+ ---
582
+ ## 🔒 Testing Security
583
+
584
+ ### Authentication Tests
585
+
586
+ ```{{LANGUAGE}}
587
+ {{AUTH_TEST_EXAMPLE}}
588
+ ```
589
+
590
+ ### Authorization Tests
591
+
592
+ ```{{LANGUAGE}}
593
+ {{AUTHZ_TEST_EXAMPLE}}
594
+ ```
595
+
596
+ ### Input Validation Tests
597
+
598
+ ```{{LANGUAGE}}
599
+ {{INPUT_VALIDATION_TEST_EXAMPLE}}
600
+ ```
601
+ ---
602
+ ## 🐛 Debugging Tests
603
+
604
+ ### Debug Configuration
605
+
606
+ **VS Code:**
607
+ ```json
608
+ {{VSCODE_DEBUG_CONFIG}}
609
+ ```
610
+
611
+ ### Debug Commands
612
+
613
+ ```bash
614
+ # Debug specific test
615
+ {{DEBUG_SPECIFIC_TEST}}
616
+
617
+ # Debug with breakpoints
618
+ {{DEBUG_WITH_BREAKPOINTS}}
619
+ ```
620
+ ---
621
+ ## 📝 Test Documentation
622
+
623
+ ### When to Document Tests
624
+
625
+ - ✅ Complex test setups
626
+ - ✅ Non-obvious mocking strategies
627
+ - ✅ Performance test configurations
628
+ - ✅ Flaky test explanations
629
+
630
+ ### Example
631
+
632
+ ```{{LANGUAGE}}
633
+ /**
634
+ * Tests the order calculation logic with multiple edge cases.
635
+ *
636
+ * This test verifies:
637
+ * 1. Basic order total calculation
638
+ * 2. Tax application
639
+ * 3. Discount code validation
640
+ * 4. Edge case: zero-price items
641
+ * 5. Edge case: 100% discount
642
+ *
643
+ * Mock strategy:
644
+ * - DiscountService is mocked to avoid external API calls
645
+ * - TaxService uses real implementation for accuracy
646
+ */
647
+ describe('Order Total Calculation', () => {
648
+ // tests...
649
+ });
650
+ ```
651
+ ---
652
+ ## 🚨 Continuous Testing
653
+
654
+ ### Pre-commit Hooks
655
+
656
+ ```bash
657
+ {{PRE_COMMIT_HOOK_CONFIG}}
658
+ ```
659
+
660
+ **Runs:**
661
+ - Linting
662
+ - Unit tests
663
+ - Type checking
664
+
665
+ ### Pre-push Hooks
666
+
667
+ ```bash
668
+ {{PRE_PUSH_HOOK_CONFIG}}
669
+ ```
670
+
671
+ **Runs:**
672
+ - Full test suite
673
+ - Coverage check
674
+ ---
675
+ ## 📈 Test Metrics
676
+
677
+ ### Tracked Metrics
678
+
679
+ - Test count (unit, integration, e2e)
680
+ - Test execution time
681
+ - Code coverage (overall, per type)
682
+ - Flaky test rate
683
+ - Test failure rate
684
+
685
+ ### Goals
686
+
687
+ {{#EACH TEST_GOAL}}
688
+ - **{{GOAL_NAME}}**: {{GOAL_TARGET}}
689
+ {{/EACH}}
690
+ ---
691
+ ## 🔄 Test Maintenance
692
+
693
+ ### Regular Tasks
694
+
695
+ - ✅ Update tests when code changes
696
+ - ✅ Remove obsolete tests
697
+ - ✅ Fix flaky tests immediately
698
+ - ✅ Refactor tests alongside code
699
+ - ✅ Update test data periodically
700
+
701
+ ### Code Review Checklist
702
+
703
+ - [ ] New code has tests
704
+ - [ ] Tests are meaningful (not just for coverage)
705
+ - [ ] Tests pass locally
706
+ - [ ] Coverage meets threshold
707
+ - [ ] No skipped/disabled tests (without reason)
708
+ - [ ] Test names are descriptive
709
+ ---
710
+ ## 📚 Resources
711
+
712
+ {{#EACH TESTING_RESOURCE}}
713
+ - [{{RESOURCE_NAME}}]({{RESOURCE_URL}})
714
+ {{/EACH}}
715
+ ---
716
+ **Document Version:** 1.0
717
+
718
+ **Last Updated:** {{GENERATION_DATE}}
719
+
720
+ **Generated by:** AI Flow v1.0.0
721
+
722
+