ワンクリックで
fxa-test-independence
// Validates that Jest tests in a given file pass both as a full suite and individually in isolation, catching hidden order dependencies and shared mutable state.
// Validates that Jest tests in a given file pass both as a full suite and individually in isolation, catching hidden order dependencies and shared mutable state.
Lists open FXA PRs matching a search term with a rich status table — file/line counts, draft state, review activity, and approval status. Defaults to all open PRs needing review.
Approves the on-hold "Approve Functional Tests (PR)" CircleCI job for the current PR branch, kicking off the gated Playwright functional tests. Requires CIRCLECI_TOKEN in the environment.
Reviews changed React/TSX code for component design, hooks misuse, performance, accessibility, and state management issues. Reports findings with severity and concrete fix recommendations. Operates on files changed vs main.
Fast single-pass FXA-specific commit review covering security, conventions, logic/bugs, tests, and migrations. No subagents — runs directly in the main context.
Thorough FXA-specific commit review using parallel specialist agents. Covers security, TypeScript, logic/bugs, test quality, and architecture. Agents explore call sites, git history, and monorepo conventions.
Drafts Jest tests for changed code. Defaults to staged/unstaged changes or the most recent commit. Output is a starting point for review, not final.
| name | fxa-test-independence |
| description | Validates that Jest tests in a given file pass both as a full suite and individually in isolation, catching hidden order dependencies and shared mutable state. |
| allowed-tools | Bash, Read, Grep |
| argument-hint | <test-file-path> |
| user-invocable | true |
| context | fork |
Validate that tests pass both when run together and when run individually. A test that passes in the full suite but fails in isolation has a hidden dependency on execution order or shared state — that is a bug in the test, not the code.
If $ARGUMENTS is provided, use it as the test file path.
Otherwise, check for recently changed test files:
git diff HEAD --name-only | grep -E '\.(spec|test)\.(ts|tsx)$'
git diff --cached --name-only | grep -E '\.(spec|test)\.(ts|tsx)$'
If multiple files are found, ask the engineer which to validate. If no file is found, ask for one explicitly.
Read the target file and extract every it(...) / test(...) name. Build the full list before running anything.
Show the engineer the list of tests to be validated and the commands that will be run. Do not proceed without confirmation.
File: packages/fxa-auth-server/lib/account.spec.ts
Tests found: 12
Will run:
1. Full suite (all 12 tests together)
2. Each test individually (12 isolated runs)
Total runs: 13
Derive the package root from the test file path (e.g. packages/fxa-auth-server/lib/foo.spec.ts → packages/fxa-auth-server). Always cd into the package before invoking Jest so the local jest.config.* is picked up. Do NOT use nx test-unit — it runs the entire package suite regardless of the file argument.
Show the exact command, then run it:
cd <package-root> && npx jest <relative-path-to-spec> --no-coverage
Example: for packages/fxa-auth-server/lib/metricsCache.spec.ts:
cd packages/fxa-auth-server && npx jest lib/metricsCache.spec.ts --no-coverage
Record: pass/fail and any output for failing tests.
For each test name extracted in Step 2, run it individually from the same package root:
cd <package-root> && npx jest <relative-path-to-spec> --testNamePattern="<exact test name>" --no-coverage
Record the result for each.
Output a results table:
| # | Test name | Full suite | Isolated | Status |
|---|---|---|---|---|
| 1 | returns account when found | ✅ | ✅ | OK |
| 2 | throws NotFound when missing | ✅ | ❌ | ORDER DEPENDENCY |
Status codes:
OK — passes in both contextsORDER DEPENDENCY — passes in suite, fails in isolation; likely depends on state set by a prior testBROKEN — fails in both; implementation or mock issueFALSE POSITIVE — passes in isolation, fails in suite; likely pollutes shared state for other testsFor any non-OK result, include the failure output and a diagnosis:
Likely causes by status:
ORDER DEPENDENCY: missing beforeEach reset, shared module-level variable mutated by a prior test, or singleton not re-initialised between testsFALSE POSITIVE: test mutates a shared mock or global without cleaning up in afterEachBROKEN: wrong mock return value, missing await, or the implementation under test has changedSuggest a concrete fix for each failure. Do not fix automatically — present the diagnosis and let the engineer decide.