You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/AGENTS.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -268,6 +268,30 @@ await env.mockIpcRenderer.invoke(IPC_CHANNELS.WORKSPACE_CREATE, projectPath, bra
268
268
- Verifying filesystem state (like checking if files exist) after IPC operations complete
269
269
- Loading existing data to avoid expensive API calls in test setup
270
270
271
+
### Testing without Mocks (preferred)
272
+
273
+
- Prefer exercising real behavior over substituting test doubles. Do not stub `child_process`, `fs`, or discovery logic.
274
+
- Use temporary directories and real processes in unit tests where feasible. Clean up with `fs.rmSync(temp, { recursive: true, force: true })` in `afterEach`.
275
+
- For extension system tests:
276
+
- Spawn the real global extension host via `ExtensionManager.initializeGlobal()`.
277
+
- Create real on-disk extensions in a temp `~/.cmux/ext` or project `.cmux/ext` folder.
278
+
- Register/unregister real workspaces and verify through actual tool execution.
279
+
- Integration tests must go through real IPC. Use the test harness's `mockIpcRenderer.invoke()` to traverse the production IPC path (this is a façade, not a Jest mock).
280
+
- Avoid spies and partial mocks. If a mock seems necessary, consider fixing the test harness or refactoring code to make the behavior testable without mocks.
281
+
- Acceptable exceptions: isolating nondeterminism (e.g., time) or external network calls. Prefer dependency injection with in-memory fakes over broad module mocks.
282
+
283
+
### Testing without Mocks (preferred)
284
+
285
+
- Prefer exercising real behavior over substituting test doubles. Do not stub `child_process`, `fs`, or discovery logic.
286
+
- Use temporary directories and real processes in unit tests where feasible. Clean up with `fs.rmSync(temp, { recursive: true, force: true })` in `afterEach`.
287
+
- For extension system tests:
288
+
- Spawn the real global extension host via `ExtensionManager.initializeGlobal()`.
289
+
- Create real on-disk extensions in a temp `~/.cmux/ext` or project `.cmux/ext` folder.
290
+
- Register/unregister real workspaces and verify through actual tool execution.
291
+
- Integration tests must go through real IPC. Use the test harness's `mockIpcRenderer.invoke()` to traverse the production IPC path (this is a façade, not a Jest mock).
292
+
- Avoid spies and partial mocks. If a mock seems necessary, consider fixing the test harness or refactoring code to make the behavior testable without mocks.
293
+
- Acceptable exceptions: isolating nondeterminism (e.g., time) or external network calls. Prefer dependency injection with in-memory fakes over broad module mocks.
294
+
271
295
If IPC is hard to test, fix the test infrastructure or IPC layer, don't work around it by bypassing IPC.
0 commit comments