trinity-method-sdk 2.0.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 (191) hide show
  1. package/CHANGELOG.md +116 -0
  2. package/LICENSE +21 -0
  3. package/README.md +555 -0
  4. package/dist/cli/commands/deploy/agents.d.ts +14 -0
  5. package/dist/cli/commands/deploy/agents.js +59 -0
  6. package/dist/cli/commands/deploy/ci-cd.d.ts +13 -0
  7. package/dist/cli/commands/deploy/ci-cd.js +50 -0
  8. package/dist/cli/commands/deploy/claude-setup.d.ts +17 -0
  9. package/dist/cli/commands/deploy/claude-setup.js +91 -0
  10. package/dist/cli/commands/deploy/configuration.d.ts +13 -0
  11. package/dist/cli/commands/deploy/configuration.js +215 -0
  12. package/dist/cli/commands/deploy/directories.d.ts +12 -0
  13. package/dist/cli/commands/deploy/directories.js +38 -0
  14. package/dist/cli/commands/deploy/gitignore.d.ts +12 -0
  15. package/dist/cli/commands/deploy/gitignore.js +53 -0
  16. package/dist/cli/commands/deploy/index.d.ts +38 -0
  17. package/dist/cli/commands/deploy/index.js +156 -0
  18. package/dist/cli/commands/deploy/knowledge-base.d.ts +16 -0
  19. package/dist/cli/commands/deploy/knowledge-base.js +75 -0
  20. package/dist/cli/commands/deploy/linting.d.ts +18 -0
  21. package/dist/cli/commands/deploy/linting.js +51 -0
  22. package/dist/cli/commands/deploy/metrics.d.ts +13 -0
  23. package/dist/cli/commands/deploy/metrics.js +34 -0
  24. package/dist/cli/commands/deploy/pre-flight.d.ts +13 -0
  25. package/dist/cli/commands/deploy/pre-flight.js +29 -0
  26. package/dist/cli/commands/deploy/root-files.d.ts +16 -0
  27. package/dist/cli/commands/deploy/root-files.js +178 -0
  28. package/dist/cli/commands/deploy/sdk-install.d.ts +12 -0
  29. package/dist/cli/commands/deploy/sdk-install.js +57 -0
  30. package/dist/cli/commands/deploy/summary.d.ts +14 -0
  31. package/dist/cli/commands/deploy/summary.js +130 -0
  32. package/dist/cli/commands/deploy/templates.d.ts +14 -0
  33. package/dist/cli/commands/deploy/templates.js +84 -0
  34. package/dist/cli/commands/deploy/types.d.ts +39 -0
  35. package/dist/cli/commands/deploy/types.js +5 -0
  36. package/dist/cli/commands/update/agents.d.ts +14 -0
  37. package/dist/cli/commands/update/agents.js +31 -0
  38. package/dist/cli/commands/update/backup.d.ts +31 -0
  39. package/dist/cli/commands/update/backup.js +97 -0
  40. package/dist/cli/commands/update/commands.d.ts +14 -0
  41. package/dist/cli/commands/update/commands.js +75 -0
  42. package/dist/cli/commands/update/index.d.ts +15 -0
  43. package/dist/cli/commands/update/index.js +118 -0
  44. package/dist/cli/commands/update/knowledge-base.d.ts +14 -0
  45. package/dist/cli/commands/update/knowledge-base.js +38 -0
  46. package/dist/cli/commands/update/pre-flight.d.ts +13 -0
  47. package/dist/cli/commands/update/pre-flight.js +37 -0
  48. package/dist/cli/commands/update/summary.d.ts +20 -0
  49. package/dist/cli/commands/update/summary.js +47 -0
  50. package/dist/cli/commands/update/templates.d.ts +14 -0
  51. package/dist/cli/commands/update/templates.js +25 -0
  52. package/dist/cli/commands/update/types.d.ts +13 -0
  53. package/dist/cli/commands/update/types.js +7 -0
  54. package/dist/cli/commands/update/utils.d.ts +11 -0
  55. package/dist/cli/commands/update/utils.js +19 -0
  56. package/dist/cli/commands/update/verification.d.ts +20 -0
  57. package/dist/cli/commands/update/verification.js +54 -0
  58. package/dist/cli/commands/update/version.d.ts +18 -0
  59. package/dist/cli/commands/update/version.js +36 -0
  60. package/dist/cli/commands/update.d.ts +7 -0
  61. package/dist/cli/commands/update.js +7 -0
  62. package/dist/cli/index.d.ts +3 -0
  63. package/dist/cli/index.js +36 -0
  64. package/dist/cli/types.d.ts +77 -0
  65. package/dist/cli/types.js +5 -0
  66. package/dist/cli/utils/deploy-ci.d.ts +22 -0
  67. package/dist/cli/utils/deploy-ci.js +138 -0
  68. package/dist/cli/utils/deploy-linting.d.ts +3 -0
  69. package/dist/cli/utils/deploy-linting.js +136 -0
  70. package/dist/cli/utils/detect-stack.d.ts +3 -0
  71. package/dist/cli/utils/detect-stack.js +270 -0
  72. package/dist/cli/utils/error-classes.d.ts +63 -0
  73. package/dist/cli/utils/error-classes.js +84 -0
  74. package/dist/cli/utils/error-handler.d.ts +59 -0
  75. package/dist/cli/utils/error-handler.js +127 -0
  76. package/dist/cli/utils/errors.d.ts +52 -0
  77. package/dist/cli/utils/errors.js +102 -0
  78. package/dist/cli/utils/get-sdk-path.d.ts +18 -0
  79. package/dist/cli/utils/get-sdk-path.js +31 -0
  80. package/dist/cli/utils/inject-dependencies.d.ts +2 -0
  81. package/dist/cli/utils/inject-dependencies.js +55 -0
  82. package/dist/cli/utils/linting-tools.d.ts +8 -0
  83. package/dist/cli/utils/linting-tools.js +206 -0
  84. package/dist/cli/utils/metrics/code-quality.d.ts +32 -0
  85. package/dist/cli/utils/metrics/code-quality.js +122 -0
  86. package/dist/cli/utils/metrics/dependency-parser.d.ts +21 -0
  87. package/dist/cli/utils/metrics/dependency-parser.js +153 -0
  88. package/dist/cli/utils/metrics/file-complexity.d.ts +26 -0
  89. package/dist/cli/utils/metrics/file-complexity.js +77 -0
  90. package/dist/cli/utils/metrics/framework-detector.d.ts +17 -0
  91. package/dist/cli/utils/metrics/framework-detector.js +120 -0
  92. package/dist/cli/utils/metrics/git-metrics.d.ts +30 -0
  93. package/dist/cli/utils/metrics/git-metrics.js +83 -0
  94. package/dist/cli/utils/metrics/index.d.ts +28 -0
  95. package/dist/cli/utils/metrics/index.js +100 -0
  96. package/dist/cli/utils/template-processor.d.ts +10 -0
  97. package/dist/cli/utils/template-processor.js +188 -0
  98. package/dist/cli/utils/validate-path.d.ts +80 -0
  99. package/dist/cli/utils/validate-path.js +180 -0
  100. package/dist/index.d.ts +6 -0
  101. package/dist/index.js +8 -0
  102. package/dist/templates/agents/aj-team/apo-documentation-specialist.md.template +572 -0
  103. package/dist/templates/agents/aj-team/bas-quality-gate.md.template +906 -0
  104. package/dist/templates/agents/aj-team/bon-dependency-manager.md.template +636 -0
  105. package/dist/templates/agents/aj-team/cap-configuration-specialist.md.template +670 -0
  106. package/dist/templates/agents/aj-team/dra-code-reviewer.md.template +768 -0
  107. package/dist/templates/agents/aj-team/kil-task-executor.md.template +764 -0
  108. package/dist/templates/agents/aj-team/uro-refactoring-specialist.md.template +759 -0
  109. package/dist/templates/agents/audit/juno-auditor.md.template +447 -0
  110. package/dist/templates/agents/deployment/ein-cicd.md.template +694 -0
  111. package/dist/templates/agents/deployment/ino-context.md.template +733 -0
  112. package/dist/templates/agents/deployment/tan-structure.md.template +661 -0
  113. package/dist/templates/agents/deployment/zen-knowledge.md.template +451 -0
  114. package/dist/templates/agents/leadership/aj-cc.md.template +462 -0
  115. package/dist/templates/agents/leadership/aj-maestro.md.template +943 -0
  116. package/dist/templates/agents/leadership/aly-cto.md.template +407 -0
  117. package/dist/templates/agents/planning/eus-decomposer.md.template +496 -0
  118. package/dist/templates/agents/planning/mon-requirements.md.template +323 -0
  119. package/dist/templates/agents/planning/ror-design.md.template +465 -0
  120. package/dist/templates/agents/planning/tra-planner.md.template +432 -0
  121. package/dist/templates/ci/cd.yml.template +175 -0
  122. package/dist/templates/ci/ci.yml.template +196 -0
  123. package/dist/templates/ci/generic-ci.yml +115 -0
  124. package/dist/templates/ci/github-actions.yml +86 -0
  125. package/dist/templates/ci/gitlab-ci.yml +103 -0
  126. package/dist/templates/claude/EMPLOYEE-DIRECTORY.md.template +545 -0
  127. package/dist/templates/documentation/ROOT-README.md.template +307 -0
  128. package/dist/templates/documentation/SUBDIRECTORY-README.md.template +261 -0
  129. package/dist/templates/investigations/bug.md.template +484 -0
  130. package/dist/templates/investigations/feature.md.template +564 -0
  131. package/dist/templates/investigations/performance.md.template +625 -0
  132. package/dist/templates/investigations/security.md.template +714 -0
  133. package/dist/templates/investigations/technical.md.template +433 -0
  134. package/dist/templates/knowledge-base/AI-DEVELOPMENT-GUIDE.md.template +957 -0
  135. package/dist/templates/knowledge-base/ARCHITECTURE.md.template +452 -0
  136. package/dist/templates/knowledge-base/CODING-PRINCIPLES.md.template +750 -0
  137. package/dist/templates/knowledge-base/DOCUMENTATION-CRITERIA.md.template +1118 -0
  138. package/dist/templates/knowledge-base/ISSUES.md.template +539 -0
  139. package/dist/templates/knowledge-base/TESTING-PRINCIPLES.md.template +894 -0
  140. package/dist/templates/knowledge-base/Technical-Debt.md.template +640 -0
  141. package/dist/templates/knowledge-base/To-do.md.template +407 -0
  142. package/dist/templates/knowledge-base/Trinity.md.template +464 -0
  143. package/dist/templates/linting/flutter/.pre-commit-config.yaml.template +27 -0
  144. package/dist/templates/linting/flutter/analysis_options.yaml.template +26 -0
  145. package/dist/templates/linting/nodejs/.eslintrc-commonjs.json.template +19 -0
  146. package/dist/templates/linting/nodejs/.eslintrc-esm.json.template +19 -0
  147. package/dist/templates/linting/nodejs/.eslintrc-typescript.json.template +22 -0
  148. package/dist/templates/linting/nodejs/.pre-commit-config.yaml.template +51 -0
  149. package/dist/templates/linting/nodejs/.prettierrc.json.template +10 -0
  150. package/dist/templates/linting/python/.flake8.template +16 -0
  151. package/dist/templates/linting/python/.pre-commit-config.yaml.template +30 -0
  152. package/dist/templates/linting/python/pyproject.toml.template +38 -0
  153. package/dist/templates/linting/rust/.pre-commit-config.yaml.template +28 -0
  154. package/dist/templates/linting/rust/clippy.toml.template +14 -0
  155. package/dist/templates/linting/rust/rustfmt.toml.template +12 -0
  156. package/dist/templates/root/CLAUDE.md.template +65 -0
  157. package/dist/templates/root/TRINITY.md.template +52 -0
  158. package/dist/templates/shared/claude-commands/trinity-agents.md.template +168 -0
  159. package/dist/templates/shared/claude-commands/trinity-audit.md.template +646 -0
  160. package/dist/templates/shared/claude-commands/trinity-changelog.md.template +624 -0
  161. package/dist/templates/shared/claude-commands/trinity-continue.md.template +549 -0
  162. package/dist/templates/shared/claude-commands/trinity-create-investigation.md.template +232 -0
  163. package/dist/templates/shared/claude-commands/trinity-decompose.md.template +181 -0
  164. package/dist/templates/shared/claude-commands/trinity-design.md.template +347 -0
  165. package/dist/templates/shared/claude-commands/trinity-docs.md.template +2093 -0
  166. package/dist/templates/shared/claude-commands/trinity-end.md.template +397 -0
  167. package/dist/templates/shared/claude-commands/trinity-init.md.template +606 -0
  168. package/dist/templates/shared/claude-commands/trinity-investigate-templates.md.template +725 -0
  169. package/dist/templates/shared/claude-commands/trinity-orchestrate.md.template +1061 -0
  170. package/dist/templates/shared/claude-commands/trinity-plan-investigation.md.template +135 -0
  171. package/dist/templates/shared/claude-commands/trinity-plan.md.template +201 -0
  172. package/dist/templates/shared/claude-commands/trinity-readme.md.template +1971 -0
  173. package/dist/templates/shared/claude-commands/trinity-requirements.md.template +148 -0
  174. package/dist/templates/shared/claude-commands/trinity-start.md.template +268 -0
  175. package/dist/templates/shared/claude-commands/trinity-verify.md.template +453 -0
  176. package/dist/templates/shared/claude-commands/trinity-workorder.md.template +249 -0
  177. package/dist/templates/source/base-CLAUDE.md.template +310 -0
  178. package/dist/templates/source/flutter-CLAUDE.md.template +593 -0
  179. package/dist/templates/source/nodejs-CLAUDE.md.template +531 -0
  180. package/dist/templates/source/python-CLAUDE.md.template +510 -0
  181. package/dist/templates/source/react-CLAUDE.md.template +513 -0
  182. package/dist/templates/source/rust-CLAUDE.md.template +653 -0
  183. package/dist/templates/source/tests-CLAUDE.md.template +432 -0
  184. package/dist/templates/trinity/CLAUDE.md.template +372 -0
  185. package/dist/templates/work-orders/ANALYSIS-TEMPLATE.md.template +276 -0
  186. package/dist/templates/work-orders/AUDIT-TEMPLATE.md.template +262 -0
  187. package/dist/templates/work-orders/IMPLEMENTATION-TEMPLATE.md.template +260 -0
  188. package/dist/templates/work-orders/INVESTIGATION-TEMPLATE.md.template +206 -0
  189. package/dist/templates/work-orders/PATTERN-TEMPLATE.md.template +320 -0
  190. package/dist/templates/work-orders/VERIFICATION-TEMPLATE.md.template +273 -0
  191. package/package.json +94 -0
@@ -0,0 +1,432 @@
1
+ # CLAUDE.md - Testing Standards
2
+ ## {{PROJECT_NAME}} - Test Suite
3
+
4
+ **Testing Framework:** {{TEST_FRAMEWORK}}
5
+ **Test Directory:** tests/
6
+ **Coverage Target:** 80%+
7
+
8
+ ---
9
+
10
+ ## Test Organization
11
+
12
+ ### Directory Structure
13
+ ```
14
+ tests/
15
+ ├── unit/ # Unit tests (isolated function/class tests)
16
+ ├── integration/ # Integration tests (multiple components)
17
+ ├── e2e/ # End-to-end tests (full workflow tests)
18
+ ├── helpers/ # Test helpers and utilities
19
+ └── __mocks__/ # Mock implementations
20
+ ```
21
+
22
+ ### Naming Conventions
23
+ - **Test files**: `*.test.ts` or `*.spec.ts`
24
+ - **Test suites**: `describe('ComponentName', () => {...})`
25
+ - **Test cases**: `it('should behave in specific way', () => {...})`
26
+ - **Setup/Teardown**: `beforeEach`, `afterEach`, `beforeAll`, `afterAll`
27
+
28
+ ---
29
+
30
+ ## Test Writing Standards
31
+
32
+ ### Test Structure (AAA Pattern)
33
+ ```typescript
34
+ describe('Feature Name', () => {
35
+ it('should do something specific', () => {
36
+ // Arrange - Set up test data and conditions
37
+ const input = 'test input';
38
+ const expected = 'expected output';
39
+
40
+ // Act - Execute the function/method being tested
41
+ const result = functionUnderTest(input);
42
+
43
+ // Assert - Verify the result matches expectations
44
+ expect(result).toBe(expected);
45
+ });
46
+ });
47
+ ```
48
+
49
+ ### Test Isolation
50
+ - **Each test must be independent** - No shared state between tests
51
+ - **Use beforeEach/afterEach** - Clean up after each test
52
+ - **Mock external dependencies** - Database, APIs, file system, etc.
53
+ - **Avoid test order dependency** - Tests should pass in any order
54
+
55
+ ### Test Coverage Requirements
56
+ ```typescript
57
+ // All exported functions must have tests
58
+ export function criticalFunction() {
59
+ // Must have: happy path + edge cases + error cases
60
+ }
61
+
62
+ // All classes must have tests
63
+ export class ImportantClass {
64
+ // Must test: constructor + all public methods + error states
65
+ }
66
+
67
+ // Integration tests must cover:
68
+ // - Happy path workflows
69
+ // - Error handling paths
70
+ // - Edge cases and boundary conditions
71
+ ```
72
+
73
+ ---
74
+
75
+ ## Test Categories
76
+
77
+ ### Unit Tests (`tests/unit/`)
78
+ **Purpose:** Test individual functions/methods in isolation
79
+
80
+ ```typescript
81
+ import { describe, it, expect } from '@jest/globals';
82
+ import { parseInput } from '../../src/utils/parser.js';
83
+
84
+ describe('parseInput', () => {
85
+ it('should parse valid input correctly', () => {
86
+ const result = parseInput('valid-input');
87
+ expect(result).toEqual({ valid: true, data: 'valid-input' });
88
+ });
89
+
90
+ it('should handle invalid input', () => {
91
+ expect(() => parseInput(null)).toThrow('Input cannot be null');
92
+ });
93
+
94
+ it('should handle edge cases', () => {
95
+ expect(parseInput('')).toEqual({ valid: false, data: '' });
96
+ });
97
+ });
98
+ ```
99
+
100
+ ### Integration Tests (`tests/integration/`)
101
+ **Purpose:** Test multiple components working together
102
+
103
+ ```typescript
104
+ import { describe, it, expect, beforeEach, afterEach } from '@jest/globals';
105
+ import { createTempDir, cleanupTempDir } from '../helpers/test-helpers.js';
106
+
107
+ describe('Feature Integration', () => {
108
+ let testDir: string;
109
+
110
+ beforeEach(async () => {
111
+ testDir = await createTempDir();
112
+ });
113
+
114
+ afterEach(async () => {
115
+ await cleanupTempDir(testDir);
116
+ });
117
+
118
+ it('should complete full workflow', async () => {
119
+ // Test multiple components working together
120
+ const result = await completeWorkflow(testDir);
121
+ expect(result.success).toBe(true);
122
+ });
123
+ });
124
+ ```
125
+
126
+ ### End-to-End Tests (`tests/e2e/`)
127
+ **Purpose:** Test complete user workflows from start to finish
128
+
129
+ ```typescript
130
+ describe('User Workflow - E2E', () => {
131
+ it('should complete typical user journey', async () => {
132
+ // Simulate real user interaction
133
+ // Test entire system working together
134
+ // Verify final outcome
135
+ });
136
+ });
137
+ ```
138
+
139
+ ---
140
+
141
+ ## Mocking Standards
142
+
143
+ ### Mock External Dependencies
144
+ ```typescript
145
+ // __mocks__/external-library.ts
146
+ export const mockedFunction = jest.fn(() => 'mocked value');
147
+
148
+ // In test file
149
+ import { mockedFunction } from 'external-library';
150
+
151
+ describe('Component using external library', () => {
152
+ it('should use mocked dependency', () => {
153
+ const result = componentUnderTest();
154
+ expect(mockedFunction).toHaveBeenCalled();
155
+ });
156
+ });
157
+ ```
158
+
159
+ ### Mock File System Operations
160
+ ```typescript
161
+ import fs from 'fs-extra';
162
+ jest.mock('fs-extra');
163
+
164
+ describe('File operations', () => {
165
+ it('should handle file writes', async () => {
166
+ await writeFile('test.txt', 'content');
167
+ expect(fs.writeFile).toHaveBeenCalledWith('test.txt', 'content');
168
+ });
169
+ });
170
+ ```
171
+
172
+ ---
173
+
174
+ ## Test Helpers (`tests/helpers/`)
175
+
176
+ ### Common Test Utilities
177
+ ```typescript
178
+ // tests/helpers/test-helpers.ts
179
+
180
+ /**
181
+ * Create temporary directory for testing
182
+ */
183
+ export async function createTempDir(): Promise<string> {
184
+ const tempDir = path.join(os.tmpdir(), `test-${Date.now()}`);
185
+ await fs.ensureDir(tempDir);
186
+ return tempDir;
187
+ }
188
+
189
+ /**
190
+ * Cleanup temporary directory after testing
191
+ */
192
+ export async function cleanupTempDir(dir: string): Promise<void> {
193
+ await fs.remove(dir);
194
+ }
195
+
196
+ /**
197
+ * Create mock data for testing
198
+ */
199
+ export function createMockData(overrides = {}) {
200
+ return {
201
+ id: 'test-id',
202
+ name: 'Test Name',
203
+ ...overrides
204
+ };
205
+ }
206
+ ```
207
+
208
+ ---
209
+
210
+ ## Async Testing
211
+
212
+ ### Async/Await Pattern
213
+ ```typescript
214
+ describe('Async operations', () => {
215
+ it('should handle async functions', async () => {
216
+ const result = await asyncFunction();
217
+ expect(result).toBeDefined();
218
+ });
219
+
220
+ it('should handle async errors', async () => {
221
+ await expect(failingAsyncFunction()).rejects.toThrow('Expected error');
222
+ });
223
+ });
224
+ ```
225
+
226
+ ### Timeout Configuration
227
+ ```typescript
228
+ describe('Long running tests', () => {
229
+ it('should complete within timeout', async () => {
230
+ // Extend timeout for this test
231
+ const result = await longRunningOperation();
232
+ expect(result).toBeDefined();
233
+ }, 10000); // 10 second timeout
234
+ });
235
+ ```
236
+
237
+ ---
238
+
239
+ ## Error Testing
240
+
241
+ ### Expected Errors
242
+ ```typescript
243
+ describe('Error handling', () => {
244
+ it('should throw for invalid input', () => {
245
+ expect(() => functionThatThrows('invalid')).toThrow('Invalid input');
246
+ });
247
+
248
+ it('should handle async errors', async () => {
249
+ await expect(asyncFunctionThatThrows()).rejects.toThrow('Async error');
250
+ });
251
+ });
252
+ ```
253
+
254
+ ### Error Message Validation
255
+ ```typescript
256
+ it('should throw with specific message', () => {
257
+ expect(() => functionUnderTest()).toThrow(/specific pattern in message/);
258
+ });
259
+ ```
260
+
261
+ ---
262
+
263
+ ## Coverage Requirements
264
+
265
+ ### Minimum Coverage Thresholds
266
+ - **Statements:** 80%
267
+ - **Branches:** 75%
268
+ - **Functions:** 80%
269
+ - **Lines:** 80%
270
+
271
+ ### Critical Code Paths
272
+ - **100% coverage required for:**
273
+ - Authentication/Authorization
274
+ - Security-related code
275
+ - Payment processing
276
+ - Data validation
277
+ - Error handling
278
+
279
+ ### Coverage Exclusions
280
+ ```typescript
281
+ /* istanbul ignore next */
282
+ function debugOnlyFunction() {
283
+ // Development/debugging only - excluded from coverage
284
+ }
285
+ ```
286
+
287
+ ---
288
+
289
+ ## Test Data Management
290
+
291
+ ### Test Fixtures
292
+ ```typescript
293
+ // tests/fixtures/sample-data.ts
294
+ export const validUserData = {
295
+ id: '123',
296
+ email: 'test@example.com',
297
+ name: 'Test User'
298
+ };
299
+
300
+ export const invalidUserData = {
301
+ id: null,
302
+ email: 'invalid-email',
303
+ name: ''
304
+ };
305
+ ```
306
+
307
+ ### Factory Functions
308
+ ```typescript
309
+ // tests/helpers/factories.ts
310
+ export function createUser(overrides = {}) {
311
+ return {
312
+ id: generateId(),
313
+ email: 'test@example.com',
314
+ createdAt: new Date(),
315
+ ...overrides
316
+ };
317
+ }
318
+ ```
319
+
320
+ ---
321
+
322
+ ## Performance Testing
323
+
324
+ ### Performance Benchmarks
325
+ ```typescript
326
+ describe('Performance tests', () => {
327
+ it('should complete operation within time limit', async () => {
328
+ const startTime = Date.now();
329
+
330
+ await performanceIntensiveOperation();
331
+
332
+ const duration = Date.now() - startTime;
333
+ expect(duration).toBeLessThan(1000); // Must complete within 1 second
334
+ });
335
+ });
336
+ ```
337
+
338
+ ---
339
+
340
+ ## Continuous Integration
341
+
342
+ ### CI Test Requirements
343
+ - **All tests must pass** before merging
344
+ - **Coverage must meet thresholds** (80%+)
345
+ - **No test skipping** with `.skip` or `x` prefix in CI
346
+ - **Test performance** - Flag tests taking >5 seconds
347
+
348
+ ### Local Testing Commands
349
+ ```bash
350
+ # Run all tests
351
+ npm test
352
+
353
+ # Run specific test file
354
+ npm test -- path/to/test.test.ts
355
+
356
+ # Run tests in watch mode
357
+ npm run test:watch
358
+
359
+ # Generate coverage report
360
+ npm run test:coverage
361
+
362
+ # Run tests by category
363
+ npm run test:unit
364
+ npm run test:integration
365
+ npm run test:e2e
366
+ ```
367
+
368
+ ---
369
+
370
+ ## Test Debugging
371
+
372
+ ### Debug Output
373
+ ```typescript
374
+ describe('Debugging tests', () => {
375
+ it('should help debug failures', () => {
376
+ const input = complexInput();
377
+ console.log('Input:', JSON.stringify(input, null, 2));
378
+
379
+ const result = functionUnderTest(input);
380
+ console.log('Result:', JSON.stringify(result, null, 2));
381
+
382
+ expect(result).toMatchSnapshot();
383
+ });
384
+ });
385
+ ```
386
+
387
+ ### Focused Testing
388
+ ```typescript
389
+ // Run only this test during debugging
390
+ it.only('should debug this specific case', () => {
391
+ // Your test code
392
+ });
393
+
394
+ // Skip this test temporarily
395
+ it.skip('should fix this later', () => {
396
+ // Broken test
397
+ });
398
+ ```
399
+
400
+ ---
401
+
402
+ ## Best Practices
403
+
404
+ ### DO ✅
405
+ - Write tests **before or alongside** implementation (TDD)
406
+ - Test **behavior**, not implementation details
407
+ - Use **descriptive test names** explaining what's being tested
408
+ - Keep tests **simple and focused** (one assertion per test when possible)
409
+ - Mock **external dependencies** (APIs, databases, file system)
410
+ - Clean up **after each test** (temp files, database records, etc.)
411
+ - Run tests **frequently** during development
412
+
413
+ ### DON'T ❌
414
+ - Don't **skip tests** without good reason and a TODO comment
415
+ - Don't test **implementation details** (internal variables, private methods)
416
+ - Don't create **test dependencies** (Test A must run before Test B)
417
+ - Don't **hard-code dates/times** (use relative times or freeze time)
418
+ - Don't **commit commented-out tests** (fix or remove them)
419
+ - Don't **ignore failing tests** (fix them or document the issue)
420
+ - Don't **test external libraries** (assume they work, test your usage)
421
+
422
+ ---
423
+
424
+ ## Related Files
425
+ - **Test Configuration**: `jest.config.js`, `tsconfig.test.json`
426
+ - **Test Helpers**: `tests/helpers/test-helpers.ts`
427
+ - **Mocks**: `tests/__mocks__/`
428
+ - **Coverage Reports**: `coverage/`
429
+
430
+ ---
431
+
432
+ *This CLAUDE.md file provides testing standards for {{PROJECT_NAME}}. All tests must follow these conventions to ensure consistency and maintainability.*