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
{{ message }}
Repository navigation
Unit tests leave their temporary project directories behind in the system temp directory #529
Several unit tests create a temporary project directory with mkdtempSync(join(tmpdir(), ...)) and never remove it, so every unit-test run leaves directories behind in the system temp directory:
packages/ui/tests/cli.test.ts:17: the project() helper, prefix ca-cli-, one directory per call
packages/ui/tests/workarounds.test.ts:8: the project() helper, prefix ca-wk-, one directory per call
packages/ui/tests/brand.test.ts:66, :98 and :213 (prefix brand-) and :202 (prefix brand-proj-)
None of the three files removes these directories afterwards: there is no rmSync and no afterEach/afterAll teardown. On one machine that ran the suite repeatedly, 158 of these directories had accumulated. Noticed while working on #412.
Steps to reproduce
Count the leftovers: ls -d "${TMPDIR:-/tmp}"/ca-cli-* "${TMPDIR:-/tmp}"/ca-wk-* "${TMPDIR:-/tmp}"/brand-* 2>/dev/null | wc -l
Run bun run test:unit in packages/ui
Count again: the number has grown, and it grows again on every run
Expected behavior
Each test removes the temporary directories it created when it finishes, whether it passes or fails, so a test run leaves the temp directory as it found it.
Actual behavior
Directories prefixed ca-cli-, ca-wk-, brand- and brand-proj- stay in the temp directory after the run and pile up across runs.
Measured on this machine: 51,488 leftover ca-/brand- dirs in $TMPDIR; the leak spans 11 test files (brand, cli, compare, doctor, migrate-cli, migrate-react, migrate-typescript, migrations, tokens-import, ui-guard, workarounds), more than the 3 listed. Fix: one shared helper that removes every dir at teardown, plus a guard against raw mkdtempSync in unit tests.
Activity
mvilacad commentedon Oct 24, 2026
Measured on this machine: 51,488 leftover ca-/brand- dirs in $TMPDIR; the leak spans 11 test files (brand, cli, compare, doctor, migrate-cli, migrate-react, migrate-typescript, migrations, tokens-import, ui-guard, workarounds), more than the 3 listed. Fix: one shared helper that removes every dir at teardown, plus a guard against raw mkdtempSync in unit tests.
mvilacad commentedon Oct 24, 2026
Working on this in #532 (draft). Branch
fix/529-unit-tests-leave-their-temporary-project. Regression test first, then the fix.fix: test: unit tests remove the temp project directories they create (…
fix: unit tests leave their temporary project directories behind in t…