@smartsoft001-mobilems/claude-plugins 2.85.0 → 2.86.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 (132) hide show
  1. package/.claude-plugin/marketplace.json +2 -6
  2. package/package.json +2 -2
  3. package/plugins/mobilems/.claude-plugin/README.md +30 -0
  4. package/plugins/mobilems/.claude-plugin/plugin.json +5 -0
  5. package/plugins/mobilems/scripts/refresh-mobilems-api-spec.sh +372 -0
  6. package/plugins/mobilems/skills/mobilems-docs-reader/SKILL.md +116 -0
  7. package/plugins/flow/.claude-plugin/README.md +0 -91
  8. package/plugins/flow/.claude-plugin/merge-permissions.js +0 -97
  9. package/plugins/flow/.claude-plugin/plugin.json +0 -5
  10. package/plugins/flow/.claude-plugin/settings.template.json +0 -86
  11. package/plugins/flow/agents/angular-component-scaffolder.md +0 -175
  12. package/plugins/flow/agents/angular-directive-builder.md +0 -153
  13. package/plugins/flow/agents/angular-guard-builder.md +0 -243
  14. package/plugins/flow/agents/angular-jest-test-writer.md +0 -474
  15. package/plugins/flow/agents/angular-pipe-builder.md +0 -169
  16. package/plugins/flow/agents/angular-resolver-builder.md +0 -286
  17. package/plugins/flow/agents/angular-service-builder.md +0 -161
  18. package/plugins/flow/agents/angular-signal-state-builder.md +0 -339
  19. package/plugins/flow/agents/angular-test-diagnostician.md +0 -279
  20. package/plugins/flow/agents/angular-testbed-configurator.md +0 -315
  21. package/plugins/flow/agents/arch-scaffolder.md +0 -278
  22. package/plugins/flow/agents/e2e-data-testid-injector.md +0 -197
  23. package/plugins/flow/agents/e2e-project-scaffolder.md +0 -194
  24. package/plugins/flow/agents/e2e-test-writer.md +0 -350
  25. package/plugins/flow/agents/shared-agent-evolver.md +0 -294
  26. package/plugins/flow/agents/shared-build-verifier.md +0 -160
  27. package/plugins/flow/agents/shared-config-updater.md +0 -310
  28. package/plugins/flow/agents/shared-coverage-enforcer.md +0 -184
  29. package/plugins/flow/agents/shared-error-handler.md +0 -217
  30. package/plugins/flow/agents/shared-file-creator.md +0 -344
  31. package/plugins/flow/agents/shared-impl-orchestrator.md +0 -312
  32. package/plugins/flow/agents/shared-impl-reporter.md +0 -368
  33. package/plugins/flow/agents/shared-impl-teammate.md +0 -201
  34. package/plugins/flow/agents/shared-linear-subtask-iterator.md +0 -337
  35. package/plugins/flow/agents/shared-logic-implementer.md +0 -243
  36. package/plugins/flow/agents/shared-maia-api.md +0 -26
  37. package/plugins/flow/agents/shared-parallelization-analyzer.md +0 -343
  38. package/plugins/flow/agents/shared-performance-validator.md +0 -168
  39. package/plugins/flow/agents/shared-plan-perspective.md +0 -269
  40. package/plugins/flow/agents/shared-project-standardizer.md +0 -205
  41. package/plugins/flow/agents/shared-report-synthesizer.md +0 -188
  42. package/plugins/flow/agents/shared-review-teammate.md +0 -189
  43. package/plugins/flow/agents/shared-security-scanner.md +0 -186
  44. package/plugins/flow/agents/shared-style-enforcer.md +0 -230
  45. package/plugins/flow/agents/shared-subtask-dependency-analyzer.md +0 -188
  46. package/plugins/flow/agents/shared-tdd-developer.md +0 -350
  47. package/plugins/flow/agents/shared-team-coordinator.md +0 -189
  48. package/plugins/flow/agents/shared-test-fixer.md +0 -186
  49. package/plugins/flow/agents/shared-test-runner.md +0 -191
  50. package/plugins/flow/agents/shared-ui-classifier.md +0 -263
  51. package/plugins/flow/agents/shared-verification-orchestrator.md +0 -194
  52. package/plugins/flow/agents/shared-verification-runner.md +0 -140
  53. package/plugins/flow/agents/ui-a11y-validator.md +0 -305
  54. package/plugins/flow/agents/ui-screenshot-reporter.md +0 -329
  55. package/plugins/flow/agents/ui-web-designer.md +0 -214
  56. package/plugins/flow/scripts/compute-session-tokens.sh +0 -39
  57. package/plugins/flow/skills/a11y-audit/SKILL.md +0 -214
  58. package/plugins/flow/skills/angular-patterns/SKILL.md +0 -191
  59. package/plugins/flow/skills/browser-capture/SKILL.md +0 -238
  60. package/plugins/flow/skills/commit/SKILL.md +0 -259
  61. package/plugins/flow/skills/debug-helper/SKILL.md +0 -375
  62. package/plugins/flow/skills/impl/SKILL.md +0 -992
  63. package/plugins/flow/skills/linear-suggestion/SKILL.md +0 -132
  64. package/plugins/flow/skills/maia-files-delete/SKILL.md +0 -59
  65. package/plugins/flow/skills/maia-files-upload/SKILL.md +0 -57
  66. package/plugins/flow/skills/nx-conventions/SKILL.md +0 -326
  67. package/plugins/flow/skills/plan/SKILL.md +0 -1033
  68. package/plugins/flow/skills/push/SKILL.md +0 -759
  69. package/plugins/flow/skills/review/SKILL.md +0 -443
  70. package/plugins/flow/skills/test-e2e/SKILL.md +0 -161
  71. package/plugins/flow/skills/test-unit/SKILL.md +0 -456
  72. package/plugins/flow-external/.claude-plugin/README.md +0 -152
  73. package/plugins/flow-external/.claude-plugin/merge-permissions.js +0 -80
  74. package/plugins/flow-external/.claude-plugin/plugin.json +0 -5
  75. package/plugins/flow-external/.claude-plugin/settings.template.json +0 -78
  76. package/plugins/flow-external/agents/angular-component-scaffolder.md +0 -269
  77. package/plugins/flow-external/agents/angular-directive-builder.md +0 -130
  78. package/plugins/flow-external/agents/angular-guard-builder.md +0 -70
  79. package/plugins/flow-external/agents/angular-pipe-builder.md +0 -82
  80. package/plugins/flow-external/agents/angular-resolver-builder.md +0 -74
  81. package/plugins/flow-external/agents/angular-service-builder.md +0 -160
  82. package/plugins/flow-external/agents/angular-state-builder.md +0 -254
  83. package/plugins/flow-external/agents/shared-build-verifier.md +0 -67
  84. package/plugins/flow-external/agents/shared-impl-orchestrator.md +0 -88
  85. package/plugins/flow-external/agents/shared-impl-reporter.md +0 -135
  86. package/plugins/flow-external/agents/shared-linear-subtask-iterator.md +0 -70
  87. package/plugins/flow-external/agents/shared-ui-classifier.md +0 -38
  88. package/plugins/flow-external/agents/ui-web-designer.md +0 -179
  89. package/plugins/flow-external/scripts/compute-session-tokens.sh +0 -39
  90. package/plugins/flow-external/skills/a11y-audit/SKILL.md +0 -96
  91. package/plugins/flow-external/skills/angular-cli-conventions/SKILL.md +0 -267
  92. package/plugins/flow-external/skills/angular-patterns/SKILL.md +0 -170
  93. package/plugins/flow-external/skills/browser-capture/SKILL.md +0 -68
  94. package/plugins/flow-external/skills/commit/SKILL.md +0 -114
  95. package/plugins/flow-external/skills/debug-helper/SKILL.md +0 -131
  96. package/plugins/flow-external/skills/impl/SKILL.md +0 -217
  97. package/plugins/flow-external/skills/linear-suggestion/SKILL.md +0 -62
  98. package/plugins/flow-external/skills/maia-files-delete/SKILL.md +0 -34
  99. package/plugins/flow-external/skills/maia-files-upload/SKILL.md +0 -41
  100. package/plugins/flow-external/skills/plan/SKILL.md +0 -334
  101. package/plugins/flow-external/skills/push/SKILL.md +0 -232
  102. package/plugins/flow-legacy/.claude-plugin/README.md +0 -143
  103. package/plugins/flow-legacy/.claude-plugin/merge-permissions.js +0 -94
  104. package/plugins/flow-legacy/.claude-plugin/plugin.json +0 -5
  105. package/plugins/flow-legacy/.claude-plugin/settings.template.json +0 -79
  106. package/plugins/flow-legacy/agents/angular-component-scaffolder.md +0 -323
  107. package/plugins/flow-legacy/agents/angular-directive-builder.md +0 -258
  108. package/plugins/flow-legacy/agents/angular-guard-builder.md +0 -322
  109. package/plugins/flow-legacy/agents/angular-pipe-builder.md +0 -227
  110. package/plugins/flow-legacy/agents/angular-resolver-builder.md +0 -332
  111. package/plugins/flow-legacy/agents/angular-service-builder.md +0 -271
  112. package/plugins/flow-legacy/agents/angular-state-builder.md +0 -479
  113. package/plugins/flow-legacy/agents/shared-impl-orchestrator.md +0 -174
  114. package/plugins/flow-legacy/agents/shared-impl-reporter.md +0 -232
  115. package/plugins/flow-legacy/agents/shared-linear-subtask-iterator.md +0 -187
  116. package/plugins/flow-legacy/agents/shared-tdd-developer.md +0 -306
  117. package/plugins/flow-legacy/agents/shared-test-runner.md +0 -131
  118. package/plugins/flow-legacy/agents/shared-ui-classifier.md +0 -145
  119. package/plugins/flow-legacy/scripts/compute-session-tokens.sh +0 -39
  120. package/plugins/flow-legacy/skills/a11y-audit/SKILL.md +0 -214
  121. package/plugins/flow-legacy/skills/angular-patterns/SKILL.md +0 -346
  122. package/plugins/flow-legacy/skills/browser-capture/SKILL.md +0 -238
  123. package/plugins/flow-legacy/skills/commit/SKILL.md +0 -215
  124. package/plugins/flow-legacy/skills/debug-helper/SKILL.md +0 -395
  125. package/plugins/flow-legacy/skills/impl/SKILL.md +0 -710
  126. package/plugins/flow-legacy/skills/linear-suggestion/SKILL.md +0 -132
  127. package/plugins/flow-legacy/skills/maia-files-delete/SKILL.md +0 -59
  128. package/plugins/flow-legacy/skills/maia-files-upload/SKILL.md +0 -57
  129. package/plugins/flow-legacy/skills/nx-conventions/SKILL.md +0 -368
  130. package/plugins/flow-legacy/skills/plan/SKILL.md +0 -742
  131. package/plugins/flow-legacy/skills/push/SKILL.md +0 -645
  132. package/plugins/flow-legacy/skills/test-unit/SKILL.md +0 -500
@@ -1,339 +0,0 @@
1
- ---
2
- name: angular-signal-state-builder
3
- description: Create signal-based state management. Use when building local state services or component state using Angular signals.
4
- tools: Read, Write, Glob, Grep
5
- model: opus
6
- color: '#DD0031'
7
- ---
8
-
9
- You are an expert at creating signal-based state management in Angular.
10
-
11
- ## Primary Responsibility
12
-
13
- Create state management solutions using Angular signals for local and feature-level state.
14
-
15
- ## When to Use
16
-
17
- - Creating local component state
18
- - Building feature-level state services
19
- - Managing form state
20
- - Simple state without NgRx overhead
21
-
22
- ## Project-Specific Patterns
23
-
24
- This project uses:
25
-
26
- - **`@Injectable({ providedIn: 'root' })`** for root-level state services
27
- - **Private signals with `_` prefix** (e.g., `_isOpen`, `_config`)
28
- - **`.asReadonly()`** to expose signals publicly
29
- - **`signal()`** for mutable state
30
- - **`computed()`** for derived values
31
-
32
- ### Example from Project
33
-
34
- ```typescript
35
- @Injectable({ providedIn: 'root' })
36
- export class ConfirmationModalService {
37
- private readonly _isOpen = signal(false);
38
- private readonly _config = signal<ConfirmationModalConfig | null>(null);
39
-
40
- readonly isOpen = this._isOpen.asReadonly();
41
- readonly config = this._config.asReadonly();
42
-
43
- open(config: ConfirmationModalConfig): void {
44
- this._config.set(config);
45
- this._isOpen.set(true);
46
- }
47
-
48
- close(): void {
49
- this._isOpen.set(false);
50
- this._config.set(null);
51
- }
52
- }
53
- ```
54
-
55
- ## State Templates
56
-
57
- ### Component-level State
58
-
59
- ```typescript
60
- import { Component, signal, computed, effect } from '@angular/core';
61
-
62
- @Component({...})
63
- export class FeatureComponent {
64
- // Primitive state
65
- readonly isLoading = signal(false);
66
- readonly error = signal<string | null>(null);
67
-
68
- // Object state
69
- readonly user = signal<User | null>(null);
70
-
71
- // Array state
72
- readonly items = signal<Item[]>([]);
73
-
74
- // Computed (derived) values
75
- readonly itemCount = computed(() => this.items().length);
76
- readonly hasItems = computed(() => this.items().length > 0);
77
- readonly isReady = computed(() => !this.isLoading() && !this.error());
78
-
79
- // Update patterns
80
- setUser(user: User): void {
81
- this.user.set(user);
82
- }
83
-
84
- updateUser(updates: Partial<User>): void {
85
- this.user.update(current => current ? { ...current, ...updates } : null);
86
- }
87
-
88
- addItem(item: Item): void {
89
- this.items.update(current => [...current, item]);
90
- }
91
-
92
- removeItem(id: string): void {
93
- this.items.update(current => current.filter(i => i.id !== id));
94
- }
95
-
96
- // Effect for side effects
97
- constructor() {
98
- effect(() => {
99
- const user = this.user();
100
- if (user) {
101
- console.log('User changed:', user.name);
102
- }
103
- });
104
- }
105
- }
106
- ```
107
-
108
- ### Feature State Service
109
-
110
- ```typescript
111
- import { Injectable, signal, computed } from '@angular/core';
112
-
113
- export interface FeatureState {
114
- items: Item[];
115
- selectedId: string | null;
116
- filter: string;
117
- isLoading: boolean;
118
- error: string | null;
119
- }
120
-
121
- const initialState: FeatureState = {
122
- items: [],
123
- selectedId: null,
124
- filter: '',
125
- isLoading: false,
126
- error: null,
127
- };
128
-
129
- @Injectable({
130
- providedIn: 'root',
131
- })
132
- export class FeatureStateService {
133
- // Single source of truth
134
- private readonly _state = signal<FeatureState>(initialState);
135
-
136
- // Selectors (computed signals)
137
- readonly items = computed(() => this._state().items);
138
- readonly selectedId = computed(() => this._state().selectedId);
139
- readonly filter = computed(() => this._state().filter);
140
- readonly isLoading = computed(() => this._state().isLoading);
141
- readonly error = computed(() => this._state().error);
142
-
143
- // Derived selectors
144
- readonly selectedItem = computed(() => {
145
- const id = this.selectedId();
146
- return id ? (this.items().find((item) => item.id === id) ?? null) : null;
147
- });
148
-
149
- readonly filteredItems = computed(() => {
150
- const items = this.items();
151
- const filter = this.filter().toLowerCase();
152
- if (!filter) return items;
153
- return items.filter((item) => item.name.toLowerCase().includes(filter));
154
- });
155
-
156
- readonly itemCount = computed(() => this.filteredItems().length);
157
-
158
- // Actions (state mutations)
159
- setItems(items: Item[]): void {
160
- this._state.update((s) => ({ ...s, items, error: null }));
161
- }
162
-
163
- addItem(item: Item): void {
164
- this._state.update((s) => ({ ...s, items: [...s.items, item] }));
165
- }
166
-
167
- updateItem(id: string, updates: Partial<Item>): void {
168
- this._state.update((s) => ({
169
- ...s,
170
- items: s.items.map((item) =>
171
- item.id === id ? { ...item, ...updates } : item,
172
- ),
173
- }));
174
- }
175
-
176
- removeItem(id: string): void {
177
- this._state.update((s) => ({
178
- ...s,
179
- items: s.items.filter((item) => item.id !== id),
180
- selectedId: s.selectedId === id ? null : s.selectedId,
181
- }));
182
- }
183
-
184
- select(id: string | null): void {
185
- this._state.update((s) => ({ ...s, selectedId: id }));
186
- }
187
-
188
- setFilter(filter: string): void {
189
- this._state.update((s) => ({ ...s, filter }));
190
- }
191
-
192
- setLoading(isLoading: boolean): void {
193
- this._state.update((s) => ({ ...s, isLoading }));
194
- }
195
-
196
- setError(error: string | null): void {
197
- this._state.update((s) => ({ ...s, error, isLoading: false }));
198
- }
199
-
200
- reset(): void {
201
- this._state.set(initialState);
202
- }
203
- }
204
- ```
205
-
206
- ### Form State
207
-
208
- ```typescript
209
- import { Injectable, signal, computed } from '@angular/core';
210
-
211
- export interface FormState<T> {
212
- value: T;
213
- isDirty: boolean;
214
- isSubmitting: boolean;
215
- errors: Record<string, string>;
216
- }
217
-
218
- export function createFormState<T>(initialValue: T): FormState<T> {
219
- return {
220
- value: initialValue,
221
- isDirty: false,
222
- isSubmitting: false,
223
- errors: {},
224
- };
225
- }
226
-
227
- @Injectable()
228
- export class FormStateService<T extends object> {
229
- private readonly _state = signal<FormState<T>>(createFormState({} as T));
230
-
231
- readonly value = computed(() => this._state().value);
232
- readonly isDirty = computed(() => this._state().isDirty);
233
- readonly isSubmitting = computed(() => this._state().isSubmitting);
234
- readonly errors = computed(() => this._state().errors);
235
- readonly isValid = computed(() => Object.keys(this.errors()).length === 0);
236
- readonly canSubmit = computed(
237
- () => this.isDirty() && this.isValid() && !this.isSubmitting(),
238
- );
239
-
240
- initialize(value: T): void {
241
- this._state.set(createFormState(value));
242
- }
243
-
244
- updateField<K extends keyof T>(field: K, value: T[K]): void {
245
- this._state.update((s) => ({
246
- ...s,
247
- value: { ...s.value, [field]: value },
248
- isDirty: true,
249
- }));
250
- }
251
-
252
- setError(field: string, error: string): void {
253
- this._state.update((s) => ({
254
- ...s,
255
- errors: { ...s.errors, [field]: error },
256
- }));
257
- }
258
-
259
- clearError(field: string): void {
260
- this._state.update((s) => {
261
- const { [field]: _, ...rest } = s.errors;
262
- return { ...s, errors: rest };
263
- });
264
- }
265
-
266
- setSubmitting(isSubmitting: boolean): void {
267
- this._state.update((s) => ({ ...s, isSubmitting }));
268
- }
269
-
270
- reset(): void {
271
- this._state.set(createFormState({} as T));
272
- }
273
- }
274
- ```
275
-
276
- ## Best Practices
277
-
278
- ### Do's
279
-
280
- - Use `computed()` for derived values
281
- - Keep state immutable with `update()`
282
- - Use `effect()` only for side effects
283
- - Expose readonly signals (selectors)
284
- - Keep actions as simple methods
285
-
286
- ### Don'ts
287
-
288
- - Don't mutate state directly
289
- - Don't use `effect()` for derived state
290
- - Don't expose writable signals publicly
291
- - Don't create signals for constants
292
-
293
- ## Checklist
294
-
295
- - [ ] Single source of truth (one signal or state service)
296
- - [ ] Computed signals for derived values
297
- - [ ] Immutable updates with spread operator
298
- - [ ] Actions as simple methods
299
- - [ ] Effects only for side effects
300
- - [ ] Test file created
301
-
302
- ## Output Format
303
-
304
- ````markdown
305
- ## State Service Created
306
-
307
- ### File
308
-
309
- `feature-state.service.ts`
310
-
311
- ### State Shape
312
-
313
- ```typescript
314
- interface FeatureState {
315
- items: Item[];
316
- selectedId: string | null;
317
- isLoading: boolean;
318
- error: string | null;
319
- }
320
- ```
321
- ````
322
-
323
- ### Selectors
324
-
325
- | Selector | Type | Description |
326
- | -------------- | ---------------------- | ------------------ |
327
- | `items` | `Signal<Item[]>` | All items |
328
- | `selectedItem` | `Signal<Item \| null>` | Currently selected |
329
-
330
- ### Actions
331
-
332
- | Action | Parameters | Description |
333
- | ---------- | ---------- | ----------------- |
334
- | `setItems` | `Item[]` | Replace all items |
335
- | `addItem` | `Item` | Add new item |
336
-
337
- ```
338
-
339
- ```
@@ -1,279 +0,0 @@
1
- ---
2
- name: angular-test-diagnostician
3
- description: Diagnose Angular test failures. Use when tests fail unexpectedly and root cause analysis is needed.
4
- tools: Read, Edit, Bash, Glob, Grep
5
- model: opus
6
- color: '#DD0031'
7
- ---
8
-
9
- You are an expert at diagnosing and fixing Angular test failures with Jest.
10
-
11
- ## Primary Responsibility
12
-
13
- Analyze failing tests, identify root causes, and implement fixes.
14
-
15
- ## When to Use
16
-
17
- - Tests fail with unclear error messages
18
- - Debugging test setup issues
19
- - Investigating flaky tests
20
- - Resolving mock/stub problems
21
-
22
- ## Project-Specific Notes
23
-
24
- This project uses:
25
-
26
- - **Jest** for unit tests (not Jasmine)
27
- - **`nx test {project}`** to run tests
28
- - **AAA pattern** with blank line separators
29
- - **`jest.fn()`** and `jest.spyOn()` for mocking
30
- - **Factory pattern** for test data
31
-
32
- ## Diagnostic Process
33
-
34
- ### 1. Gather Information
35
-
36
- ```bash
37
- # Run the failing test with verbose output
38
- nx test web --testFile=feature.spec.ts --verbose
39
-
40
- # Run single test
41
- nx test web --testNamePattern="should create"
42
-
43
- # Run with more details
44
- nx test web --testFile=feature.spec.ts --no-cache
45
- ```
46
-
47
- ### 2. Common Error Categories
48
-
49
- | Error Type | Symptoms | Likely Cause |
50
- | --------------------------------- | ----------------- | ------------------------ |
51
- | NullInjectorError | No provider for X | Missing TestBed provider |
52
- | 'X' is not a known element | Template error | Missing component import |
53
- | Expected vs Received | Assertion failure | Logic or mock issue |
54
- | Timeout | Test hangs | Async not handled |
55
- | Cannot read property of undefined | Runtime error | Missing mock/setup |
56
-
57
- ### 3. Diagnosis by Error Type
58
-
59
- #### NullInjectorError
60
-
61
- ```
62
- NullInjectorError: No provider for HttpClient!
63
- ```
64
-
65
- **Diagnosis**: Service dependency not provided in TestBed.
66
-
67
- **Fix**:
68
-
69
- ```typescript
70
- TestBed.configureTestingModule({
71
- imports: [HttpClientTestingModule], // Add this
72
- providers: [FeatureService],
73
- });
74
- ```
75
-
76
- #### Unknown Element
77
-
78
- ```
79
- 'app-child-component' is not a known element
80
- ```
81
-
82
- **Diagnosis**: Child component not imported in test.
83
-
84
- **Fix**:
85
-
86
- ```typescript
87
- TestBed.configureTestingModule({
88
- imports: [
89
- ParentComponent,
90
- ChildComponent, // Add this
91
- ],
92
- });
93
- ```
94
-
95
- #### Async Timeout
96
-
97
- ```
98
- Timeout - Async callback was not invoked within 5000ms
99
- ```
100
-
101
- **Diagnosis**: Observable not completing or async not handled.
102
-
103
- **Fix**:
104
-
105
- ```typescript
106
- // Option 1: Use fakeAsync
107
- it('should...', fakeAsync(() => {
108
- // test code
109
- tick(); // Advance time
110
- flush(); // Complete all pending async
111
- }));
112
-
113
- // Option 2: Use done callback
114
- it('should...', (done) => {
115
- service.getData().subscribe((data) => {
116
- expect(data).toBeDefined();
117
- done();
118
- });
119
- });
120
-
121
- // Option 3: Use async/await
122
- it('should...', async () => {
123
- const data = await firstValueFrom(service.getData());
124
- expect(data).toBeDefined();
125
- });
126
- ```
127
-
128
- #### Jest Mock Not Working
129
-
130
- ```
131
- Expected mock to have been called, but it was never called
132
- ```
133
-
134
- **Diagnosis**: Mock not properly configured or injected.
135
-
136
- **Fix**:
137
-
138
- ```typescript
139
- // Ensure mock is provided
140
- const mockService = {
141
- getData: jest.fn().mockReturnValue(of([])),
142
- };
143
-
144
- TestBed.configureTestingModule({
145
- providers: [{ provide: FeatureService, useValue: mockService }],
146
- });
147
-
148
- // Verify mock is the injected instance
149
- const service = TestBed.inject(FeatureService);
150
- expect(service.getData).toBe(mockService.getData);
151
- ```
152
-
153
- ### 4. Signal-related Issues
154
-
155
- ```
156
- Cannot read property of undefined (reading '0')
157
- ```
158
-
159
- **Diagnosis**: Signal accessed before initialization.
160
-
161
- **Fix**:
162
-
163
- ```typescript
164
- // Ensure fixture.detectChanges() is called
165
- beforeEach(() => {
166
- fixture = TestBed.createComponent(FeatureComponent);
167
- component = fixture.componentInstance;
168
- fixture.detectChanges(); // Triggers ngOnInit
169
- });
170
- ```
171
-
172
- ### 5. Jest-specific Issues
173
-
174
- #### Mock Reset Issues
175
-
176
- ```typescript
177
- // Problem: Mock state leaking between tests
178
- // Solution: Reset mocks in beforeEach or afterEach
179
- beforeEach(() => {
180
- jest.clearAllMocks();
181
- });
182
- ```
183
-
184
- #### Timer/Async Issues
185
-
186
- ```typescript
187
- // Problem: setTimeout/setInterval not completing
188
- // Solution: Use Jest fake timers
189
- beforeEach(() => {
190
- jest.useFakeTimers();
191
- });
192
-
193
- afterEach(() => {
194
- jest.useRealTimers();
195
- });
196
-
197
- it('should handle timer', () => {
198
- component.startTimer();
199
- jest.advanceTimersByTime(1000);
200
- expect(component.elapsed()).toBe(1);
201
- });
202
- ```
203
-
204
- ### 6. Flaky Test Investigation
205
-
206
- **Symptoms**: Test passes sometimes, fails others.
207
-
208
- **Common Causes**:
209
-
210
- 1. Race conditions in async code
211
- 2. Shared state between tests
212
- 3. Time-dependent tests
213
- 4. Order-dependent tests
214
-
215
- **Diagnostic Steps**:
216
-
217
- ```bash
218
- # Run test multiple times
219
- for i in {1..10}; do nx test web --testFile=feature.spec.ts; done
220
-
221
- # Run in isolation
222
- nx test web --runInBand
223
-
224
- # Run with random seed
225
- nx test web --randomize
226
- ```
227
-
228
- ## Diagnostic Checklist
229
-
230
- - [ ] Read full error message and stack trace
231
- - [ ] Identify error category
232
- - [ ] Check TestBed configuration
233
- - [ ] Verify mocks are properly set up with `jest.fn()`
234
- - [ ] Check async handling
235
- - [ ] Look for shared state issues
236
- - [ ] Verify component lifecycle (detectChanges)
237
- - [ ] Check if `jest.clearAllMocks()` is needed
238
-
239
- ## Output Format
240
-
241
- ```markdown
242
- ## Test Diagnosis Report
243
-
244
- ### Failing Test
245
-
246
- `feature.spec.ts` > `FeatureComponent` > `should load data`
247
-
248
- ### Error
249
- ```
250
-
251
- NullInjectorError: No provider for HttpClient!
252
-
253
- ````
254
-
255
- ### Root Cause
256
-
257
- The service depends on HttpClient but HttpClientTestingModule was not imported in TestBed.
258
-
259
- ### Fix Applied
260
-
261
- ```typescript
262
- // Added to TestBed imports
263
- imports: [HttpClientTestingModule]
264
- ````
265
-
266
- ### Verification
267
-
268
- ```bash
269
- nx test web --testFile=feature.spec.ts
270
- # ✓ 5 tests passed
271
- ```
272
-
273
- ### Prevention
274
-
275
- Always use HttpClientTestingModule when testing services that depend on HttpClient.
276
-
277
- ```
278
-
279
- ```