Skip to content

Unit tests leave their temporary project directories behind in the system temp directory #529

Closed

Description

@Nitjsefnie

Describe the bug

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

  1. Count the leftovers: ls -d "${TMPDIR:-/tmp}"/ca-cli-* "${TMPDIR:-/tmp}"/ca-wk-* "${TMPDIR:-/tmp}"/brand-* 2>/dev/null | wc -l
  2. Run bun run test:unit in packages/ui
  3. 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.

@codeatlasdev/ui version

4.5.0 (main at 85086c5)

Svelte version

other

Framework

other

Minimal reproduction

No response

Before submitting

  • I searched existing issues and this hasn't been reported yet
  • I read the docs and confirmed this is unexpected behavior

Happy to send a PR for this.

Activity

  1. mvilacad commented on Oct 24, 2026

    @mvilacad
    Contributor

    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.

  2. added
    in progressSomeone is working on it (see the linked draft PR)
    on Oct 24, 2026
  3. self-assigned this
    on Oct 24, 2026
  4. mvilacad commented on Oct 24, 2026

    @mvilacad
    Contributor

    Working on this in #532 (draft). Branch fix/529-unit-tests-leave-their-temporary-project. Regression test first, then the fix.

  5. removed
    in progressSomeone is working on it (see the linked draft PR)
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions