Skip to content

Commit 1a1b1c5

Browse files
committed
updates
1 parent 64fa669 commit 1a1b1c5

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

.github/instructions/testing-workflow.instructions.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,59 @@ envConfig.inspect
537537
- ❌ Tests that don't clean up mocks properly
538538
- ❌ Overly complex test setup that's hard to understand
539539

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.
581+
582+
### Example Programmatic Run
583+
584+
```
585+
await runTests({
586+
files: ['/absolute/path/to/src/test/features/execution/execUtils.unit.test.ts']
587+
});
588+
```
589+
590+
If that returns 0, re-check compilation path mapping.
591+
592+
## Agent Learning Patterns
541593

542594
### Key Implementation Insights
543595

@@ -550,3 +602,4 @@ envConfig.inspect
550602
- When fixing mock environment creation, use `null` to truly omit properties rather than `undefined` (1)
551603
- 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)
552604
- 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)

src/test/features/execution/execUtils.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as assert from 'assert';
2-
import { quoteStringIfNecessary, quoteArgs } from '../../../features/execution/execUtils';
2+
import { quoteArgs, quoteStringIfNecessary } from '../../../features/execution/execUtils';
33

44
suite('Execution Utils Tests', () => {
55
suite('quoteStringIfNecessary', () => {

0 commit comments

Comments
 (0)