From f8abc521f3bd2e5aeaf11ae3ed3a6e1214646060 Mon Sep 17 00:00:00 2001 From: ethernet Date: Wed, 15 Jul 2026 12:14:07 -0400 Subject: [PATCH] docs: add JS test placement rule to AGENTS.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a "Tests for JavaScript / npm / package.json invariants belong in the JS suite" subsection under Testing, documenting that the CI classifier routes package.json / lockfile / .ts/.tsx changes to the frontend lane — so Python tests asserting about those files won't run on a JS-only PR. Includes a table mapping artifact types to the correct vitest workspace and run commands. --- AGENTS.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 78a150ab0c35..bb2a78f2114a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1278,6 +1278,7 @@ def profile_env(tmp_path, monkeypatch): ## Testing +### Python **ALWAYS use `scripts/run_tests.sh`** — do not call `pytest` directly. The script enforces hermetic environment parity with CI (unset credential vars, TZ=UTC, LANG=C.UTF-8, `-n auto` xdist workers, in-tree subprocess-isolation plugin). Direct `pytest` @@ -1291,12 +1292,12 @@ scripts/run_tests.sh tests/agent/test_foo.py::test_x # one test scripts/run_tests.sh -v --tb=long # pass-through pytest flags ``` -### Subprocess-per-test-file isolation +#### Subprocess-per-test-file isolation Every test file runs in a freshly-spawned Python subprocess via `run_tests_parallel.py`. This means module-level dicts/sets and ContextVars from one test file cannot leak into the next. -### Why the wrapper +#### Why the wrapper | | Without wrapper | With wrapper | | ------------------- | ------------------------------------------- | ----------------------------------------- | @@ -1305,6 +1306,17 @@ ContextVars from one test file cannot leak into the next. | Timezone | Local TZ (PDT etc.) | UTC | | Locale | Whatever is set | C.UTF-8 | +### Where to place what tests + +The CI change classifier (`scripts/ci/classify_changes.py`) runs specific jobs based on what files changed. A Python test that asserts +about the contents of `package.json`, `package-lock.json`, `.ts`/`.tsx` +source, or any other JS-side artifact will not run on a PR that only touches +those files. This means a regression can go green on a PR and red on `main` (where the +classifier fails open and runs everything). + +Any test that reads or asserts about `package.json`, +`package-lock.json`, `tsconfig.json`, `.ts`/`.tsx`/`.js`/`.mjs`/`.cjs` +source files configuration belongs in the JS (vitest) test suite, not in `tests/*.py`. ### Don't write change-detector tests