ai-flow-dev 2.2.0 → 2.2.4

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 (74) hide show
  1. package/README.md +28 -24
  2. package/dist/cli.js +228 -418
  3. package/dist/cli.js.map +1 -1
  4. package/package.json +1 -1
  5. package/prompts/backend/flow-build-phase-0.md +286 -4
  6. package/prompts/backend/flow-build-phase-1.md +19 -0
  7. package/prompts/backend/flow-build-phase-2.md +19 -0
  8. package/prompts/backend/flow-build-phase-3.md +19 -0
  9. package/prompts/backend/flow-build-phase-4.md +19 -0
  10. package/prompts/backend/flow-build-phase-5.md +19 -0
  11. package/prompts/backend/flow-build-phase-6.md +19 -0
  12. package/prompts/backend/flow-build-phase-7.md +19 -0
  13. package/prompts/backend/flow-build-phase-9.md +14 -0
  14. package/prompts/backend/flow-build.md +2 -0
  15. package/prompts/backend/flow-check-review.md +20 -0
  16. package/prompts/backend/flow-check-test.md +14 -0
  17. package/prompts/backend/flow-check.md +67 -0
  18. package/prompts/backend/flow-commit.md +53 -0
  19. package/prompts/backend/flow-docs-sync.md +55 -53
  20. package/prompts/backend/flow-work-feature.md +42 -0
  21. package/prompts/backend/flow-work-fix.md +33 -0
  22. package/prompts/backend/flow-work-refactor.md +32 -0
  23. package/prompts/backend/flow-work-resume.md +32 -0
  24. package/prompts/backend/flow-work.md +129 -0
  25. package/prompts/frontend/flow-build-phase-0.md +363 -35
  26. package/prompts/frontend/flow-build-phase-1.md +433 -404
  27. package/prompts/frontend/flow-build-phase-2.md +508 -872
  28. package/prompts/frontend/flow-build-phase-3.md +629 -562
  29. package/prompts/frontend/flow-build-phase-4.md +438 -382
  30. package/prompts/frontend/flow-build-phase-5.md +559 -362
  31. package/prompts/frontend/flow-build-phase-6.md +383 -452
  32. package/prompts/frontend/flow-build-phase-7.md +818 -392
  33. package/prompts/frontend/flow-build-phase-9.md +14 -0
  34. package/prompts/frontend/flow-build.md +2 -0
  35. package/prompts/frontend/flow-check-review.md +20 -0
  36. package/prompts/frontend/flow-check-test.md +14 -0
  37. package/prompts/frontend/flow-check.md +67 -0
  38. package/prompts/frontend/flow-commit.md +53 -0
  39. package/prompts/frontend/flow-docs-sync.md +39 -35
  40. package/prompts/frontend/flow-work-feature.md +42 -0
  41. package/prompts/frontend/flow-work-fix.md +33 -0
  42. package/prompts/frontend/flow-work-refactor.md +32 -0
  43. package/prompts/frontend/flow-work-resume.md +32 -0
  44. package/prompts/frontend/flow-work.md +129 -0
  45. package/prompts/mobile/flow-build-phase-0.md +366 -37
  46. package/prompts/mobile/flow-build-phase-1.md +438 -493
  47. package/prompts/mobile/flow-build-phase-2.md +458 -464
  48. package/prompts/mobile/flow-build-phase-3.md +613 -487
  49. package/prompts/mobile/flow-build-phase-4.md +439 -258
  50. package/prompts/mobile/flow-build-phase-5.md +582 -250
  51. package/prompts/mobile/flow-build-phase-6.md +389 -359
  52. package/prompts/mobile/flow-build-phase-7.md +871 -285
  53. package/prompts/mobile/flow-build-phase-9.md +14 -0
  54. package/prompts/mobile/flow-build.md +2 -0
  55. package/prompts/mobile/flow-check-review.md +20 -0
  56. package/prompts/mobile/flow-check-test.md +14 -0
  57. package/prompts/mobile/flow-check.md +67 -0
  58. package/prompts/mobile/flow-commit.md +53 -0
  59. package/prompts/mobile/flow-docs-sync.md +39 -40
  60. package/prompts/mobile/flow-work-feature.md +42 -0
  61. package/prompts/mobile/flow-work-fix.md +33 -0
  62. package/prompts/mobile/flow-work-refactor.md +32 -0
  63. package/prompts/mobile/flow-work-resume.md +32 -0
  64. package/prompts/mobile/flow-work.md +129 -0
  65. package/prompts/shared/smart-skip-preflight.md +214 -0
  66. package/templates/AGENT.template.md +13 -3
  67. package/templates/backend/.clauderules.template +5 -4
  68. package/templates/backend/.cursorrules.template +1 -1
  69. package/prompts/backend/flow-dev-commit.md +0 -829
  70. package/prompts/backend/flow-dev-feature.md +0 -1948
  71. package/prompts/backend/flow-dev-fix.md +0 -952
  72. package/prompts/backend/flow-dev-refactor.md +0 -690
  73. package/prompts/backend/flow-dev-review.md +0 -372
  74. package/prompts/backend/flow-dev-work.md +0 -1081
@@ -1,593 +1,524 @@
1
- # Phase 6: Testing Strategy
1
+ ## PHASE 6: Testing Strategy (15-20 min)
2
2
 
3
- **Duration:** 15-25 minutes
4
- **Questions:** ~12 questions
5
- **Output:** docs/testing.md, parts of ai-instructions.md
6
- ---
7
- ## 🎯 Objective
3
+ > **Order for this phase:**
4
+ >
5
+ > - **MVP:** 6.1 6.2 (smoke tests) → 6.7 (CI basics)
6
+ > - **Production-Ready:** 6.1 → 6.1b → 6.2 → 6.3 → 6.4 → 6.5 → 6.6 → 6.7
7
+ > - **Enterprise:** 6.1 → 6.1b → 6.2 → 6.3 → 6.4 → 6.5 → 6.6 → 6.7 → 6.8 → 6.9
8
8
 
9
- Define your testing strategy:
9
+ > **📌 Scope-based behavior:**
10
+ >
11
+ > - **MVP:** Ask 6.1 (framework), 6.2 (smoke tests only), 6.7 (CI basics) - **Target: 15-25% coverage**
12
+ > - **Production-Ready:** Ask all questions 6.1-6.7 - **Target: 60-80% coverage**
13
+ > - **Enterprise:** Ask all questions 6.1-6.9 - **Target: 80-95% coverage + contract/load tests**
10
14
 
11
- 1. What testing frameworks will you use?
12
- 2. What types of tests will you write?
13
- 3. What coverage targets?
14
- 4. How will tests run in CI/CD?
15
- ---
16
- ## 📋 Questions
15
+ ### Objective
17
16
 
18
- ### Question 6.1: Unit Testing Framework
17
+ Define testing approach, tools, and quality gates.
19
18
 
20
- **What unit test framework will you use?**
19
+ **🚨 Important: All projects require basic testing. Scope determines depth, not whether to test.**
21
20
 
22
- A) ⭐ **Vitest** (Recommended for most)
21
+ ---
23
22
 
24
- - Features: Fast, Vite-native, compatible with Jest API
25
- - Best for: Vite projects, modern apps
26
- - Speed: Very fast (ESM native)
27
- - Bundle: N/A (dev dependency)
23
+ ## 🔍 Pre-Flight Check (Smart Skip Logic)
28
24
 
29
- B) 🔥 **Jest**
25
+ > 📎 **Reference:** See [prompts/shared/smart-skip-preflight.md](../shared/smart-skip-preflight.md) for the complete smart skip logic.
30
26
 
31
- - Features: Mature, widely used, snapshot testing
32
- - Best for: React apps, large ecosystem
33
- - Speed: Fast (with SWC/ESBuild)
34
- - Bundle: N/A (dev dependency)
27
+ **Execute Pre-Flight Check for Phase 6:**
35
28
 
36
- C) **Testing Library + Node Test Runner**
29
+ - **Target File**: `docs/testing.md`
30
+ - **Phase Name**: "TESTING STRATEGY"
31
+ - **Key Items**: Test framework, coverage targets, test types, CI/CD integration
32
+ - **Typical Gaps**: E2E strategy, load testing, performance testing
37
33
 
38
- - Features: Node.js built-in test runner (Node 18+)
39
- - Best for: Zero-dependency testing
40
- - Speed: Fast
34
+ **Proceed with appropriate scenario based on audit data from `.ai-flow/cache/audit-data.json`**
41
35
 
42
- D) **Mocha + Chai**
36
+ ---
43
37
 
44
- - Features: Flexible, BDD-style
45
- - Best for: Legacy projects
38
+ ## Phase 6 Questions (Full Mode)
46
39
 
47
- **Your answer:**
48
- ---
49
- ### Question 6.2: Component Testing Library
40
+ **6.1 Testing Framework**
50
41
 
51
- **How will you test components?**
52
-
53
- #### React
54
-
55
- A) ⭐ **React Testing Library** (Recommended)
56
-
57
- - Philosophy: Test user behavior, not implementation
58
- - Features: Accessible queries, user-centric
59
- - Best for: All React apps
42
+ ```
60
43
 
61
- B) **Enzyme**
44
+ Which testing tools will you use?
62
45
 
63
- - Features: Shallow rendering, instance testing
64
- - Best for: Legacy React apps
65
- - Note: Not recommended for new projects
46
+ JavaScript/TypeScript:
47
+ A) ⭐ Jest - Most popular, great ecosystem
48
+ B) Vitest - Modern, fast, Vite-compatible
49
+ C) Mocha + Chai
50
+ D) AVA
66
51
 
67
- #### Vue
52
+ Python:
53
+ E) ⭐ pytest - Modern, feature-rich
54
+ F) unittest - Built-in
55
+ G) nose2
68
56
 
69
- A) ⭐ **Vue Test Utils** (Official)
57
+ Java:
58
+ H) ⭐ JUnit 5 + Mockito
59
+ I) TestNG
70
60
 
71
- - Features: Vue-specific testing utilities
72
- - Best for: All Vue apps
61
+ Your choice: \_\_
73
62
 
74
- #### Angular
63
+ Assertion library: **
64
+ Mocking library: **
75
65
 
76
- A) ⭐ **Angular Testing Utilities** (Built-in)
66
+ ```
77
67
 
78
- - Features: TestBed, ComponentFixture
79
- - Best for: All Angular apps
68
+ **6.1b Testing Philosophy** (Production-Ready and Enterprise only)
80
69
 
81
- #### Svelte
70
+ ```
71
+ What is your testing philosophy?
82
72
 
83
- A) ⭐ **Svelte Testing Library**
73
+ A) ⭐ Test-First (TDD) - Write tests before code
74
+ - Red-Green-Refactor cycle
75
+ - Higher initial effort, better design
76
+ - Best for: Complex business logic, critical systems
84
77
 
85
- - Features: User-centric testing
86
- - Best for: All Svelte apps
78
+ B) 🔥 Test-After - Write tests after implementation
79
+ - Faster initial development
80
+ - Risk of untested edge cases
81
+ - Best for: Rapid prototyping, time-sensitive features
87
82
 
88
- #### Solid
83
+ C) ⚡ Behavior-Driven (BDD) - Write tests as specifications
84
+ - Given/When/Then format
85
+ - Business-readable tests
86
+ - Best for: Domain-heavy applications
89
87
 
90
- A) **Solid Testing Library**
88
+ D) 🏆 Hybrid - TDD for core logic, test-after for simple features
89
+ - Balance of speed and quality
90
+ - Pragmatic approach
91
91
 
92
- - Features: Similar to React Testing Library
93
- - Best for: All Solid apps
92
+ Your choice: __
93
+ ```
94
94
 
95
- **Your answer:**
96
- ---
97
- ### Question 6.3: E2E Testing Framework
95
+ **6.2 Test Types**
98
96
 
99
- **What E2E testing tool will you use?**
97
+ ```
98
+ [If MVP scope selected, ask simplified version:]
100
99
 
101
- A) **Playwright** (Recommended)
100
+ For MVP, we'll focus on smoke tests (critical path verification).
101
+ Which critical flows should be tested?
102
102
 
103
- - Features: Cross-browser, fast, modern API, auto-waiting
104
- - Browsers: Chromium, Firefox, WebKit
105
- - Best for: Most apps, CI/CD friendly
106
- - Speed: Very fast
103
+ Select 3-5 most important endpoints/features:
104
+ A) Authentication (login/register)
105
+ B) Main business operation (e.g., create order, post article)
106
+ C) User profile/account management
107
+ D) Payment processing (if applicable)
108
+ E) Data retrieval (main GET endpoints)
107
109
 
108
- B) 🔥 **Cypress**
110
+ Selected: __
109
111
 
110
- - Features: Great DX, time-travel debugging, visual testing
111
- - Browsers: Chrome, Firefox, Edge, Electron
112
- - Best for: Developer experience, visual regression
113
- - Speed: Fast
112
+ Test approach: Integration tests covering happy path of selected flows
113
+ Coverage target: 15-25%
114
+ Test type: Integration/E2E only (no unit tests required for MVP)
114
115
 
115
- C) **Puppeteer**
116
+ [If Production-Ready or Enterprise scope selected, ask full version:]
116
117
 
117
- - Features: Chrome/Chromium only, powerful API
118
- - Best for: Chrome-only testing, scraping
118
+ Which test types will you implement?
119
119
 
120
- D) **WebDriverIO**
120
+ A) ✅ Unit Tests
121
+ - Test individual functions/methods in isolation
122
+ - Fast, numerous
123
+ - Mock all dependencies
121
124
 
122
- - Features: WebDriver protocol, cross-platform
123
- - Best for: Mobile testing, Appium integration
125
+ B) Integration Tests
126
+ - Test multiple components together
127
+ - Database, external APIs
128
+ - Slower but more realistic
124
129
 
125
- E) **No E2E tests**
130
+ C) E2E (End-to-End) Tests
131
+ - Test full user flows
132
+ - API endpoints from request to response
133
+ - Tool: Supertest (Node.js), pytest with TestClient (Python)
126
134
 
127
- - Best for: MVPs, small apps
135
+ D) 🏆 Contract Tests (Advanced - Enterprise recommended)
136
+ - Verify API contracts between services
137
+ - Tool: Pact, Spring Cloud Contract
128
138
 
129
- **Your answer:**
130
- ---
131
- ### Question 6.4: Testing Pyramid Distribution
139
+ E) ⚡ Load/Performance Tests (Enterprise recommended)
140
+ - Tool: Artillery, K6, JMeter
132
141
 
133
- **What test distribution will you target?**
142
+ F) 🔬 Chaos Engineering (Enterprise only)
143
+ - Test system resilience to failures
144
+ - Tool: Chaos Monkey, Litmus, Gremlin
134
145
 
135
- A) ⭐ **Standard Pyramid** (Recommended)
146
+ Selected: __
136
147
 
148
+ Pyramid distribution:
137
149
  - 70% Unit tests
138
150
  - 20% Integration tests
139
151
  - 10% E2E tests
140
- - Best for: Most apps, balanced approach
141
-
142
- B) **Heavy Unit**
143
-
144
- - 85% Unit tests
145
- - 10% Integration tests
146
- - 5% E2E tests
147
- - Best for: Logic-heavy apps, libraries
148
-
149
- C) **Heavy Integration**
150
-
151
- - 50% Unit tests
152
- - 40% Integration tests
153
- - 10% E2E tests
154
- - Best for: UI-heavy apps, component libraries
155
-
156
- D) **Testing Trophy** (Kent C. Dodds)
157
-
158
- - 30% Unit tests
159
- - 50% Integration tests
160
- - 20% E2E tests
161
- - Best for: User-centric apps
162
-
163
- **Your answer:**
164
- ---
165
- #### 🎨 TESTING PYRAMID VISUALIZATION
166
-
167
- **Use this diagram format** to visualize test distribution strategy:
168
-
169
- ```mermaid
170
- graph TB
171
- subgraph "Testing Pyramid"
172
- E2E["🌐 E2E Tests (10%)<br/>Slow, Expensive<br/>Full user flows"]
173
- INT["🔗 Integration Tests (20%)<br/>Medium Speed<br/>Component interaction"]
174
- UNIT["⚡ Unit Tests (70%)<br/>Fast, Cheap<br/>Individual functions/components"]
175
- end
176
-
177
- E2E --> INT
178
- INT --> UNIT
179
-
180
- style E2E fill:#fce4ec,stroke:#c2185b,stroke-width:2px
181
- style INT fill:#fff4e6,stroke:#f57c00,stroke-width:2px
182
- style UNIT fill:#e8f5e9,stroke:#388e3c,stroke-width:3px
152
+ (Adjust as needed)
183
153
 
184
- classDef note fill:#f5f5f5,stroke:#666,stroke-dasharray: 5 5
185
-
186
- note1["Cost ↑<br/>Speed ↓<br/>Confidence ↑"]:::note
187
- note2["Cost ↓<br/>Speed ↑<br/>Confidence varies"]:::note
188
-
189
- E2E -.-> note1
190
- UNIT -.-> note2
191
154
  ```
192
155
 
193
- **Alternative: Testing Trophy (Kent C. Dodds)**
194
-
195
- For apps prioritizing integration tests over unit tests:
196
-
197
- ```mermaid
198
- graph TB
199
- subgraph "Testing Trophy"
200
- E2E["🌐 E2E Tests (20%)<br/>Critical user paths"]
201
- INT["🔗 Integration Tests (50%)<br/>⭐ Focus here<br/>Component + API interaction"]
202
- UNIT["⚡ Unit Tests (30%)<br/>Complex logic only"]
203
- STATIC["📝 Static Analysis (Base)<br/>TypeScript + ESLint"]
204
- end
205
-
206
- E2E --> INT
207
- INT --> UNIT
208
- UNIT --> STATIC
156
+ **6.3 Test Database** [Skip if MVP scope]
209
157
 
210
- style E2E fill:#fce4ec,stroke:#c2185b,stroke-width:2px
211
- style INT fill:#fff4e6,stroke:#f57c00,stroke-width:4px
212
- style UNIT fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
213
- style STATIC fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
214
158
  ```
159
+ [Production-Ready/Enterprise only]
215
160
 
216
- **When to Use Each Visualization:**
161
+ How will you handle database in tests?
217
162
 
218
- - **Testing Pyramid**: Best for traditional apps, backend-heavy logic, libraries
219
- - **Testing Trophy**: Best for React apps, user-centric products, component-driven UIs
163
+ A) In-memory database
164
+ - SQLite for testing, PostgreSQL for prod
165
+ - Fast, isolated
220
166
 
221
- **Diagram Guidelines:**
167
+ B) 🏆 Docker test database
168
+ - Same DB as production
169
+ - More realistic
170
+ - Tool: Testcontainers
222
171
 
223
- - Color code by test type (E2E=pink, Integration=orange, Unit=green)
224
- - Show percentages clearly
225
- - Include speed/cost trade-offs
226
- - Update percentages based on selected strategy (A, B, C, or D)
227
- ---
228
- ---
229
- ### Question 6.5: Code Coverage Targets
172
+ C) 🔄 Shared test database
173
+ - One DB for all tests
174
+ - Reset between test suites
230
175
 
231
- **What coverage percentage will you target?**
176
+ D) 🎭 Mock database
177
+ - Mock all DB calls
178
+ - Fastest, but less realistic
232
179
 
233
- A) **80% / 75% / 80% / 80%** (Recommended)
180
+ Your choice: __
234
181
 
235
- - Statements: 80%
236
- - Branches: 75%
237
- - Functions: 80%
238
- - Lines: 80%
239
- - Best for: Most production apps
182
+ Test data strategy:
183
+ A) ⭐ Factories/Fixtures - Generate test data programmatically
184
+ B) Seed files - Load from JSON/SQL files
185
+ C) Inline - Create data in each test
240
186
 
241
- B) **100% / 100% / 100% / 100%** (Strict)
242
-
243
- - All coverage at 100%
244
- - Best for: Critical apps (finance, healthcare)
245
- - Note: May be impractical
246
-
247
- C) **60% / 60% / 60% / 60%** (Lenient)
248
-
249
- - Best for: MVPs, startups
187
+ ```
250
188
 
251
- D) **No coverage targets**
189
+ **6.4 Test Data Management** [Skip if MVP scope]
252
190
 
253
- - Best for: Prototypes only
191
+ ```
192
+ [Production-Ready/Enterprise only]
254
193
 
255
- **Your answer:**
194
+ How will you create test data?
256
195
 
257
- **Enforce coverage in CI?**
258
- A) Yes - Fail CI if below threshold
259
- B) No - Report only, no enforcement
260
- ---
261
- ### Question 6.6: Snapshot Testing
196
+ A) Factory pattern
197
+ - Libraries: factory_boy (Python), Fishery (TypeScript)
198
+ - Generate realistic data on demand
262
199
 
263
- **Will you use snapshot testing?**
200
+ B) Fixtures
201
+ - Predefined test data
202
+ - Loaded before tests
264
203
 
265
- Snapshot testing = Capture component output, detect unexpected changes
204
+ C) Faker
205
+ - Random realistic data
206
+ - Library: @faker-js/faker, Faker (Python)
266
207
 
267
- A) **Yes, for components**
208
+ Your approach: __
268
209
 
269
- - Test component output snapshots
270
- - Best for: Preventing regressions
271
- - Tools: Jest/Vitest snapshots
210
+ Example test data needs:
211
+ - Users with various roles
212
+ - Products with different states
213
+ - Orders in different stages
214
+ - Payment records
215
+ - [Add your specific needs]
272
216
 
273
- B) **Yes, for components + visual regression**
217
+ ```
274
218
 
275
- - Add visual snapshot testing (screenshot comparison)
276
- - Best for: UI-critical apps
277
- - Tools: Percy, Chromatic, Playwright screenshots
219
+ **6.5 Mocking Strategy** [Skip if MVP scope]
278
220
 
279
- C) **No snapshot testing**
221
+ ```
222
+ [Production-Ready/Enterprise only]
280
223
 
281
- - Best for: Avoiding brittle tests
224
+ What will you mock?
282
225
 
283
- **Your answer:**
284
- ---
285
- ### Question 6.7: Test Data & Fixtures
226
+ A) ✅ External APIs - Third-party services
227
+ B) ✅ Database - In unit tests
228
+ C) File system - S3, local storage
229
+ D) ✅ Time/Date - For deterministic tests
230
+ E) ✅ Email/SMS - Sending services
231
+ F) ✅ Payment gateways
286
232
 
287
- **How will you manage test data?**
233
+ Mocking approach:
234
+ A) ⭐ Manual mocks - jest.fn(), unittest.mock
235
+ B) Library - MSW (Mock Service Worker), nock
236
+ C) Test doubles - Stubs, spies, mocks
288
237
 
289
- A) **Factory functions** (Recommended)
238
+ When NOT to mock:
239
+ - Internal business logic
240
+ - Simple utilities
241
+ - Value objects
290
242
 
291
- ```typescript
292
- const createUser = (overrides = {}) => ({
293
- id: '1',
294
- name: 'John Doe',
295
- email: 'john@example.com',
296
- ...overrides,
297
- });
298
243
  ```
299
244
 
300
- - Best for: Flexible, reusable test data
301
-
302
- B) **Static fixtures**
245
+ **6.6 Test Organization** [Skip if MVP scope]
303
246
 
304
- ```typescript
305
- // fixtures/users.json
306
- {
307
- "user1": { "id": "1", "name": "John Doe" }
308
- }
309
247
  ```
248
+ [Production-Ready/Enterprise only]
310
249
 
311
- - Best for: Consistent test data
250
+ Test file structure:
312
251
 
313
- C) **Faker.js / @faker-js/faker**
252
+ A) Co-located with source
253
+ ```
314
254
 
315
- - Generate random realistic data
316
- - Best for: Large datasets, avoiding hardcoding
255
+ src/
256
+ users/
257
+ user.service.ts
258
+ user.service.spec.ts
317
259
 
318
- D) **Inline data**
260
+ ```
319
261
 
320
- - Define data directly in tests
321
- - Best for: Simple tests
262
+ B) Separate test directory
263
+ ```
322
264
 
323
- **Your answer:**
324
- ---
325
- ### Question 6.8: Mocking Strategy
265
+ src/users/user.service.ts
266
+ tests/users/user.service.test.ts
326
267
 
327
- **How will you mock dependencies?**
268
+ ````
328
269
 
329
- A) ⭐ **Mock Service Worker (MSW)** (Recommended for API mocking)
270
+ Test naming:
330
271
 
331
- - Features: Intercept network requests, works in tests and browser
332
- - Best for: API mocking, realistic tests
333
- - Example:
334
- ```typescript
335
- rest.get('/api/users', (req, res, ctx) => {
336
- return res(ctx.json({ users: [...] }));
272
+ ```typescript
273
+ describe('UserService', () => {
274
+ describe('createUser', () => {
275
+ it('should create a new user with valid data', async () => {
276
+ // Arrange
277
+ const userData = { email: 'test@example.com', name: 'Test' };
278
+
279
+ // Act
280
+ const result = await userService.createUser(userData);
281
+
282
+ // Assert
283
+ expect(result).toBeDefined();
284
+ expect(result.email).toBe(userData.email);
285
+ });
286
+
287
+ it('should throw error when email is duplicated', async () => {
288
+ // ...
289
+ });
337
290
  });
338
- ```
339
-
340
- B) **Vitest/Jest mocks**
341
-
342
- - Features: `vi.mock()` / `jest.mock()` for modules
343
- - Best for: Module/function mocking
344
- - Example:
345
- ```typescript
346
- vi.mock('./api', () => ({
347
- fetchUser: vi.fn(() => Promise.resolve({ id: '1' })),
348
- }));
349
- ```
350
-
351
- C) **Manual mocks**
352
-
353
- - Features: Create mock implementations manually
354
- - Best for: Full control
355
-
356
- D) **No mocking**
357
-
358
- - Test against real APIs
359
- - Best for: Integration tests only
291
+ });
292
+ ````
360
293
 
361
- **Your answer:**
362
- ---
363
- ### Question 6.9: Test Organization
294
+ Naming pattern:
295
+ A) ⭐ "should [expected behavior] when [condition]"
296
+ B) "it [expected behavior]"
297
+ C) Free-form
364
298
 
365
- **How will you organize tests?**
299
+ ````
366
300
 
367
- A) **Collocated with source** (Recommended)
301
+ **6.6.1 Contract Testing** [If selected in 6.2]
368
302
 
369
303
  ```
370
- components/
371
- ├── Button/
372
- │ ├── Button.tsx
373
- │ ├── Button.test.tsx
374
- │ └── Button.stories.tsx
304
+ [Production-Ready/Enterprise only]
305
+
306
+ Contract testing tool:
307
+ A) ⭐ Pact - Consumer-driven contracts
308
+ B) Spring Cloud Contract - Provider contracts
309
+ C) Other: __
310
+
311
+ Contract strategy:
312
+ A) ⭐ Consumer-driven - Frontend/consumers define contracts
313
+ B) Provider-driven - Backend defines contracts
314
+ C) Both - Hybrid approach
315
+
316
+ Contract storage:
317
+ A) ⭐ Pact Broker - Centralized contract storage
318
+ B) Git repository - Version contracts in code
319
+ C) Other: __
320
+
321
+ Contract versioning:
322
+ - Strategy: __
323
+ - Breaking changes: __
375
324
  ```
376
325
 
377
- - Best for: Modularity, easy to find tests
378
-
379
- B) **Separate **tests** folder**
326
+ **6.6.2 Load/Performance Testing** [If selected in 6.2]
380
327
 
381
328
  ```
382
- components/
383
- ├── Button/
384
- │ ├── Button.tsx
385
- │ └── __tests__/
386
- │ └── Button.test.tsx
329
+ [Production-Ready/Enterprise only]
330
+
331
+ Load testing tool:
332
+ A) ⭐ Artillery - Node.js, YAML-based
333
+ B) K6 - Modern, JavaScript-based
334
+ C) JMeter - Java-based, GUI available
335
+ D) Locust - Python-based
336
+ E) Other: __
337
+
338
+ Test scenarios:
339
+ - Normal load: __ requests/second
340
+ - Peak load: __ requests/second
341
+ - Stress test: __ requests/second (beyond capacity)
342
+ - Duration: __ minutes
343
+
344
+ Performance thresholds:
345
+ - Response time p50: < __ ms
346
+ - Response time p95: < __ ms
347
+ - Response time p99: < __ ms
348
+ - Error rate: < __%
349
+ - Throughput: > __ requests/second
350
+
351
+ When to run:
352
+ A) ⭐ Before major releases
353
+ B) Weekly automated runs
354
+ C) On-demand only
387
355
  ```
388
356
 
389
- - Best for: Jest convention
390
-
391
- C) **Mirrored test folder**
357
+ **6.6.3 Chaos Engineering** [If selected in 6.2 - Enterprise only]
392
358
 
393
359
  ```
394
- src/
395
- ├── components/Button.tsx
396
- tests/
397
- ├── components/Button.test.tsx
360
+ [Enterprise only]
361
+
362
+ Chaos engineering tool:
363
+ A) ⭐ Chaos Monkey (Netflix)
364
+ B) Litmus (Kubernetes)
365
+ C) Gremlin - Managed chaos platform
366
+ D) Custom scripts
367
+ E) Other: __
368
+
369
+ Chaos experiments to run:
370
+ A) Network latency injection
371
+ B) Service failures
372
+ C) Database connection failures
373
+ D) CPU/memory exhaustion
374
+ E) Disk space issues
375
+ F) Network partition
376
+
377
+ → Your selection (e.g., A, B, C): __
378
+
379
+ Safety rules:
380
+ - Run only in: [Staging, Production with approval]
381
+ - Blast radius: __% of traffic/instances
382
+ - Auto-rollback: [Yes/No]
383
+ - Approval required: [Yes/No]
398
384
  ```
399
385
 
400
- - Best for: Separation of concerns
401
-
402
- **Your answer:**
403
-
404
- **E2E test location:**
405
-
406
- - `e2e/` folder at root
407
- - `tests/e2e/` folder
408
- - `__e2e__/` folders throughout
409
- ---
410
- ### Question 6.10: CI/CD Test Execution
411
-
412
- **How will tests run in CI?**
413
-
414
- A) ⭐ **All tests on every PR** (Recommended)
415
-
416
- - Unit + Integration + E2E
417
- - Best for: Most apps, catch regressions early
418
-
419
- B) **Unit/Integration on PR, E2E on merge to main**
420
-
421
- - Faster PR feedback, comprehensive on main
422
- - Best for: Slow E2E suites
423
-
424
- C) **Unit on PR, full suite nightly**
386
+ **6.7 CI/CD Testing** [All scopes - simplified for MVP]
425
387
 
426
- - Best for: Very large test suites
427
-
428
- D) **Manual test runs**
429
-
430
- - Not recommended
431
-
432
- **Your answer:**
433
-
434
- **Parallel test execution:**
435
- A) Yes - Run tests in parallel (faster)
436
- B) No - Sequential execution
437
-
438
- **Retry failed tests:**
439
- A) Yes - Retry flaky tests (specify retries: \_\_\_)
440
- B) No - Fail immediately
441
- ---
442
- ### Question 6.11: Visual Regression Testing
443
-
444
- **Will you do visual regression testing?**
388
+ ```
389
+ [If MVP scope:]
390
+ For MVP, we'll set up basic CI to run smoke tests.
445
391
 
446
- Visual regression = Screenshot comparison to detect unintended UI changes
392
+ When will smoke tests run?
393
+ A) ⭐ On pull request (GitHub Actions, GitLab CI) - Recommended
394
+ B) Before deploy only
447
395
 
448
- A) ⭐ **Yes, with Percy / Chromatic**
396
+ Selected: __
449
397
 
450
- - Features: Cloud-based, visual diffs, review UI
451
- - Best for: Design-critical apps, component libraries
398
+ Quality gate for MVP:
399
+ - All smoke tests must pass
400
+ - ⚠️ Coverage tracking (no minimum required)
452
401
 
453
- B) **Yes, with Playwright snapshots**
402
+ [If Production-Ready or Enterprise scope:]
454
403
 
455
- - Features: Local screenshot comparison
456
- - Best for: Self-hosted, free option
404
+ When will tests run?
457
405
 
458
- C) **No visual regression**
406
+ A) On every commit (pre-commit hook) - Catch issues early
407
+ B) 🔥 On pull request (GitHub Actions, GitLab CI) - Most popular, prevents broken merges
408
+ C) ⭐ Before deploy (staging pipeline) - Recommended safety check
409
+ D) Nightly (comprehensive test suite) - For slow/extensive tests
459
410
 
460
- - Best for: MVPs, non-visual apps
411
+ Selected: __
461
412
 
462
- **Your answer:**
413
+ Quality gates:
463
414
 
464
- **If yes, what to test:**
415
+ - All tests must pass
416
+ - ✅ Coverage must be >= __% (15-25% MVP, 60-80% Production, 80-95% Enterprise)
417
+ - ✅ No linting errors
418
+ - ⚡ Performance benchmarks met (optional, Enterprise recommended)
465
419
 
466
- - [ ] Critical user flows (checkout, signup)
467
- - [ ] All components (Storybook)
468
- - [ ] Responsive breakpoints
469
- - [ ] Dark/light themes
470
- ---
471
- ### Question 6.12: Accessibility Testing
420
+ Failing a quality gate:
421
+ A) Block merge/deploy - Force fix
422
+ B) ⚠️ Warning only - Allow with justification
472
423
 
473
- **How will you test accessibility?**
424
+ ```
474
425
 
475
- A) **jest-axe / vitest-axe**
426
+ ### Phase 6 Output
476
427
 
477
- ```typescript
478
- it('has no a11y violations', async () => {
479
- const { container } = render(<Button>Click me</Button>);
480
- const results = await axe(container);
481
- expect(results).toHaveNoViolations();
482
- });
483
428
  ```
429
+ 📋 PHASE 6 SUMMARY:
430
+
431
+ **If MVP scope (A):**
432
+ Testing Framework: [Jest/pytest/JUnit] (6.1)
433
+ Test Types: Smoke tests on critical paths [selected 3-5 critical flows] (6.2)
434
+ Test Approach: Integration/E2E tests covering happy path only (6.2)
435
+ Coverage Target: 15-25% (6.2)
436
+ CI/CD Testing: [on PR/before deploy] + quality gate: all tests must pass (6.7)
437
+ Status: Basic testing implemented for MVP
438
+
439
+ **If Production-Ready (B):**
440
+ Testing Framework: [Jest/pytest/JUnit + assertion library + mocking library] (6.1)
441
+ Test Types: [unit/integration/e2e - selected types] (6.2)
442
+ Test Distribution: [pyramid percentages: 70/20/10 or custom] (6.2)
443
+ Test Database: [in-memory/Docker/shared/mock + initial data strategy] (6.3)
444
+ Test Data Management: [factories/fixtures/faker approach + specific test data needs] (6.4)
445
+ Mocking Strategy: [what to mock (APIs/DB/files/time/email/payments) + approach] (6.5)
446
+ Test Organization: [co-located/separate folder + naming pattern] (6.6)
447
+ CI/CD Testing: [when tests run (commit/PR/deploy/nightly) + quality gates (pass/60-80% coverage/lint) + gate behavior (block/warn)] (6.7)
448
+ Status: Comprehensive testing strategy implemented
449
+
450
+ **If Enterprise (C):**
451
+ Testing Framework: [Jest/pytest/JUnit + assertion library + mocking library] (6.1)
452
+ Test Types: [unit/integration/e2e/contract/load/chaos - all types] (6.2)
453
+ Test Distribution: [pyramid percentages: 70/20/10 or custom] (6.2)
454
+ Test Database: [in-memory/Docker/shared/mock + initial data strategy] (6.3)
455
+ Test Data Management: [factories/fixtures/faker approach + specific test data needs] (6.4)
456
+ Mocking Strategy: [what to mock (APIs/DB/files/time/email/payments) + approach] (6.5)
457
+ Test Organization: [co-located/separate folder + naming pattern] (6.6)
458
+ Contract Testing: [tool (Pact/Spring Cloud Contract) + strategy + storage + versioning] (6.6.1)
459
+ Load Testing: [tool (Artillery/K6/JMeter) + scenarios + thresholds + schedule] (6.6.2)
460
+ Chaos Engineering: [tool (Chaos Monkey/Litmus/Gremlin) + experiments + safety rules] (6.6.3)
461
+ CI/CD Testing: [when tests run (commit/PR/deploy/nightly) + quality gates (pass/80-95% coverage/lint/performance) + gate behavior (block/warn)] (6.7)
462
+ Status: Exhaustive testing strategy with advanced scenarios
463
+
464
+ Is this correct? (Yes/No)
465
+ ```
466
+ ---
467
+ ### 📄 Generate Phase 6 Documents
484
468
 
485
- - Best for: Automated a11y checks in unit tests
469
+ **Before starting generation:**
486
470
 
487
- B) **@axe-core/playwright / @axe-core/cypress**
471
+ ```
472
+ 📖 Loading context from previous phases...
473
+ ✅ Re-reading docs/code-standards.md
474
+ ✅ Re-reading ai-instructions.md
475
+ ```
488
476
 
489
- - E2E accessibility testing
490
- - Best for: Full-page a11y scans
477
+ **Generate `docs/testing.md` automatically:**
491
478
 
492
- C) **Manual testing**
479
+ - Use template: `.ai-flow/templates/docs/testing.template.md`
480
+ - **If MVP scope:** Fill with basic testing strategy: framework selection, smoke tests on critical paths, coverage 15-25%, basic CI setup. Mark advanced sections as "Not implemented yet - expand when moving to Production-Ready"
481
+ - **If Production-Ready:** Fill with comprehensive testing strategy: framework, unit/integration/e2e tests, 60-80% coverage, test data management, mocking, full CI/CD
482
+ - **If Enterprise:** Fill with exhaustive testing strategy: all Production-Ready items + contract tests, load tests, security tests, 80-95% coverage, performance benchmarks
483
+ - Write to: `docs/testing.md`
493
484
 
494
- - Screen reader testing, keyboard navigation
495
- - Best for: Comprehensive a11y
485
+ ```
486
+ Generated: docs/testing.md
496
487
 
497
- D) **No automated a11y testing**
488
+ Document has been created with all Phase 6 information.
498
489
 
499
- - Best for: MVPs only (not recommended)
490
+ 📝 Would you like to make any corrections before continuing?
500
491
 
501
- E) **Combined (automated + manual)**
492
+ If yes: Edit the file and type "ready" when done. I'll re-read it.
493
+ → If no: Type "continue" to proceed to Phase 7.
494
+ ```
502
495
 
503
- - Best for: WCAG compliance
496
+ **If user edits file:**
497
+ Re-read file to refresh context before continuing.
498
+ ---
499
+ **Proceed to Phase 7 only after documents are validated.**
504
500
 
505
- **Your answer:**
506
- ---
507
- ## 📊 Phase 6 Summary
501
+ > ⚠️ **CRITICAL:** DO NOT generate README.md in this phase. README.md is ONLY generated in Phase 8 (step 8.5) after framework initialization.
502
+ ---
508
503
 
509
- ```
510
- ---
511
- 📋 PHASE 6 SUMMARY: TESTING STRATEGY
512
- ---
513
- Unit Testing: [Answer from 6.1]
514
- Component Testing: [Answer from 6.2]
515
- E2E Testing: [Answer from 6.3]
516
- Test Distribution: [Answer from 6.4]
517
- Coverage Targets: [Answer from 6.5]
518
- Snapshot Testing: [Answer from 6.6]
519
- Test Data: [Answer from 6.7]
520
- Mocking Strategy: [Answer from 6.8]
521
- Test Organization: [Answer from 6.9]
522
- CI/CD Execution: [Answer from 6.10]
523
- Visual Regression: [Answer from 6.11]
524
- A11y Testing: [Answer from 6.12]
525
-
526
- Is this correct? (Y/n)
527
- ```
528
- ---
529
- ## 📝 Document Generation
530
-
531
- Generate `docs/testing.md` with these placeholders:
532
-
533
- - `{{UNIT_TEST_FRAMEWORK}}` → Vitest / Jest / etc.
534
- - `{{COMPONENT_TEST_LIBRARY}}` → React Testing Library / Vue Test Utils / etc.
535
- - `{{E2E_FRAMEWORK}}` → Playwright / Cypress / etc.
536
- - `{{TEST_DISTRIBUTION}}` → Testing pyramid percentages
537
- - `{{COVERAGE_TARGETS}}` → Coverage thresholds
538
- - `{{SNAPSHOT_TESTING}}` → Yes/No and strategy
539
- - `{{TEST_DATA_STRATEGY}}` → Factory / Fixtures / Faker
540
- - `{{MOCKING_LIBRARY}}` → MSW / Vitest mocks / etc.
541
- - `{{TEST_ORGANIZATION}}` → Collocated / Separate / Mirrored
542
- - `{{CI_STRATEGY}}` → How tests run in CI
543
- - `{{VISUAL_REGRESSION_TOOL}}` → Percy / Playwright / None
544
- - `{{A11Y_TESTING}}` → jest-axe / Manual / Combined
545
-
546
- Update `ai-instructions.md`:
547
-
548
- ```markdown
549
- ## Testing
550
-
551
- - **Unit Tests:** {{UNIT_TEST_FRAMEWORK}}
552
- - **Component Tests:** {{COMPONENT_TEST_LIBRARY}}
553
- - **E2E Tests:** {{E2E_FRAMEWORK}}
554
- - **Coverage:** {{COVERAGE_TARGETS}}
555
-
556
- ### Rules
557
-
558
- - ✅ ALWAYS write tests for new features
559
- - ✅ ALWAYS test user behavior, not implementation details
560
- - ✅ ALWAYS use accessible queries (getByRole, getByLabelText)
561
- - ❌ NEVER test implementation details (state, props directly)
562
- - ❌ NEVER commit untested code
563
- - ✅ ALWAYS mock external APIs with {{MOCKING_LIBRARY}}
564
- {{#IF_SNAPSHOT_TESTING}}
565
- - ✅ ALWAYS review snapshot changes carefully
566
- {{/IF_SNAPSHOT_TESTING}}
567
- {{#IF_A11Y_TESTING}}
568
- - ✅ ALWAYS include axe accessibility checks in component tests
569
- {{/IF_A11Y_TESTING}}
570
- - ✅ ALWAYS maintain {{COVERAGE_TARGETS}}% code coverage
571
- ```
572
- ---
573
- ## 🚀 Next Steps
504
+ ## 📝 Generated Documents
574
505
 
575
- ```
576
- Phase 6 Complete!
506
+ After Phase 6, generate/update:
507
+ - `docs/testing.md` - Testing strategy and quality gates
577
508
 
578
- Documents Generated:
579
- - docs/testing.md
580
- - ai-instructions.md (updated)
509
+ ---
581
510
 
582
- Next: Phase 7 - Performance & Deployment
511
+ **Next Phase:** Phase 7 - Operations & Deployment (10-15 min)
583
512
 
584
- Read: .ai-flow/prompts/frontend/flow-build-phase-7-deployment.md
585
- ```
586
- ---
587
- **Last Updated:** 2025-01-XX
513
+ Read: `.ai-flow/prompts/backend/flow-build-phase-7.md`
588
514
 
589
- **Version:** 1.2.0
515
+ ---
590
516
 
517
+ **Last Updated:** 2025-12-20
518
+ **Version:** 2.1.8
591
519
 
520
+ ---
592
521
 
522
+ ## PHASE 7: Operations & Deployment (10-15 min)
593
523
 
524
+ ````