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: .github/instructions/testing-workflow.instructions.md
+54-1Lines changed: 54 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -537,7 +537,59 @@ envConfig.inspect
537
537
- ❌ Tests that don't clean up mocks properly
538
538
- ❌ Overly complex test setup that's hard to understand
539
539
540
-
## 🧠 Agent Learning Patterns
540
+
## � Common Pitfalls & Fast Diagnosis
541
+
542
+
These recurring issues have caused wasted cycles. Follow the quick diagnosis flow to avoid them:
543
+
544
+
### 1. 0 Tests Detected When Filtering (e.g. with --grep or targeted run)
545
+
546
+
Likely Causes (in order):
547
+
548
+
- The TypeScript test file has not been compiled to `out/test/...` yet.
549
+
- The file was moved outside the compiler `rootDir` (tsconfig sets `rootDir: src`), so `tsc` will not emit it into `out/`.
550
+
- The grep / test name filter does not match the suite or test names.
551
+
552
+
Diagnosis Checklist:
553
+
554
+
1. Confirm compile step ran: if not in watch mode, run the compile test script (see below) **before** executing tests.
555
+
2. Check for the emitted JS: derive the expected path (replace `src/` with `out/` and ensure the directory pattern matches `out/test/**/*.unit.test.js`). If the JS file is missing, it's a compilation / placement issue.
556
+
3. Open the compiled JS and verify the `suite("<Your Suite Name>")` string literally appears; if missing, the source file wasn’t included or was misnamed.
557
+
4. Re-run the test using the programmatic test tool (preferred) referencing the file path instead of a grep first; if that succeeds, refine your grep pattern.
558
+
559
+
Remediation:
560
+
561
+
- Ensure unit test files live under `src/test/...` (since `rootDir` is `src`) so they are emitted under `out/test/...` and picked up by Mocha’s spec glob.
562
+
- Run `watch-tests` once (preferred) or a one-off `compile-tests` before first execution.
563
+
- Avoid relocating tests to a top-level `test/` folder unless tsconfig and spec globs are updated accordingly.
564
+
565
+
### 2. Using Terminal First Instead of Test Tool
566
+
567
+
Always default to the test execution tool (runTests) for:
568
+
569
+
- Precise targeting (single file / specific tests via testNames)
570
+
- Richer integration & structured output
571
+
572
+
Use terminal (`npm run unittest`) only as a fallback.
573
+
574
+
### 3. Infinite Watch Confusion
575
+
576
+
If you started `npm run watch-tests`, do **not** also run `compile-tests` repeatedly—watch already handles incremental builds. Just re-run the test tool after edits.
577
+
578
+
### Quick Flowchart
579
+
580
+
0 tests? → Was TS compiled? (Check for `out/test/...js`) → If no: compile. → If yes: Is file under `src/test`? → If no: relocate. → If yes: Does suite name match grep / filter? → Adjust filter → Use runTests with direct file path.
If that returns 0, re-check compilation path mapping.
591
+
592
+
## Agent Learning Patterns
541
593
542
594
### Key Implementation Insights
543
595
@@ -550,3 +602,4 @@ envConfig.inspect
550
602
- When fixing mock environment creation, use `null` to truly omit properties rather than `undefined` (1)
551
603
- Always recompile TypeScript after making import/export changes before running tests, as stubs won't work if they're applied to old compiled JavaScript that doesn't have the updated imports (2)
552
604
- Create proxy abstraction functions for Node.js APIs like `cp.spawn` to enable clean testing - use function overloads to preserve Node.js's intelligent typing while making the functions mockable (1)
605
+
- When a targeted test run yields 0 tests, first verify the compiled JS exists under `out/test` (rootDir is `src`); absence almost always means the test file sits outside `src` or compilation hasn't run yet (1)
0 commit comments