test: npm test writes job fixtures into the developer's real ~/.codex plugin state
Summary
npm test writes job and stop-review fixtures into the developer's real plugin data under ~/.codex/plugins/data/. The unit tests resolve state paths from the default CODEX_HOME, and several files create jobs there. These include tracked-jobs.test.mjs, job-control.test.mjs, render.test.mjs and state.test.mjs. Some of these fixtures are left in running or cancelling state and are never cleaned up.
For someone who contributes to the plugin and also uses it, those leftovers end up in the same store the installed plugin reads. In my case, every local run since July left fixtures behind:
test-status-session-a/b.json,test-status-all-a/b.jsonandtracked-race-job.json(statuscancelling)j1.logstop-review-history.jsonlwith alternating block/allow entrieseperm-live-process.json(statusrunning, pid 1)
That came to 77 workspace directories in total. The eperm-live-process.json fixture landed in the state directory of a real checkout, next to that checkout's real review jobs.
Data written to the legacy plugins/data/cc namespace from a source checkout is merged into the installed plugin's cc-<marketplace> namespace the next time the plugin runs (migrateLegacyPluginDataRoots). So running the tests from a clone still reaches the installed plugin's state.
Environment
- cc@sendbird 1.5.0, current
mainat 19e565151f35b328a5b9433df351bd8f3818fdc7 - Node.js 24, macOS
Reproduction
Run the unit tests with a throwaway home so nothing real is touched:
FAKE_HOME="$(mktemp -d "${TMPDIR:-/tmp}/fake-home-XXXXXX")"
HOME="$FAKE_HOME" npm test >/dev/null 2>&1
find "$FAKE_HOME/.codex/plugins/data" -type f | sed "s|$FAKE_HOME|~|" | sort | head
The listing shows the fixtures under ~/.codex/plugins/data/cc/state/<hash>/…. Without the HOME override, they land in the real ~/.codex.
Expected
The unit test run points CODEX_HOME at a temporary directory, so it never reads or writes the developer's real Codex home. node --test passes --import to each test file's process, so a single setup module added to the test scripts covers every file. The integration and e2e suites already set their own CODEX_HOME.
I have a small fix and can open a PR.