Skip to content

test(optimize): clean up pnpm v8 and v9 fixture artifacts after tests#1323

Merged
Simon (simonhj) merged 2 commits into
v1.xfrom
fix/pnpm-fixture-cleanup
May 21, 2026
Merged

test(optimize): clean up pnpm v8 and v9 fixture artifacts after tests#1323
Simon (simonhj) merged 2 commits into
v1.xfrom
fix/pnpm-fixture-cleanup

Conversation

@simonhj
Copy link
Copy Markdown

@simonhj Simon (simonhj) commented May 21, 2026

The pnpm v8/v9 optimize fixture tests run pnpm install inside the fixture directories during beforeEach to provision the specific pnpm binary version. The existing afterEach hooks only reset tracked files (git checkout HEAD -- .) but left untracked node_modules/ and .cache/ directories behind, polluting the working tree for both pnpm v8 and pnpm v9 fixtures.

This caused two problems for both fixtures:

  1. Running git add -A (or relying on pre-commit hooks that do) would accidentally stage thousands of untracked fixture artifacts.
  2. The pnpm9 fixture install was silently failing (swallowed by try/catch + stdio: 'ignore'), so pnpm9 tests fell back to the system pnpm rather than testing against pnpm v9.

Changes

  • Import trash and remove node_modules/ + .cache/ in both beforeEach (to clean up after prior aborted runs) and afterEach (to keep the fixture clean going forward) for both pnpm8 and pnpm9 fixtures.
  • Use Promise.all for parallel cleanup to avoid no-await-in-loop lint warnings.

Verification

  • All 4 pnpm-version tests continue to pass.
  • Fixture directories are now clean after each test run (only package.json and pnpm-lock.yaml remain).

Note

Low Risk
Low risk: test-only changes that add cleanup of node_modules/.cache in fixtures; main impact is slightly longer test setup and potential environment-specific filesystem deletion behavior.

Overview
Keeps the pnpm8/pnpm9 optimize fixture tests from leaving behind untracked install artifacts by deleting node_modules/ and .cache/ in both beforeEach (cleanup from prior runs) and afterEach (post-test cleanup).

The tests now use trash and run cleanup in parallel via Promise.all, while still resetting tracked files via git checkout.

Reviewed by Cursor Bugbot for commit 6f7d89d. Configure here.

@simonhj Simon (simonhj) changed the base branch from main to v1.x May 21, 2026 08:13
@simonhj Simon (simonhj) changed the title test(optimize): clean up pnpm fixture artifacts after tests test(optimize): clean up pnpm v8 and v9 fixture artifacts after tests May 21, 2026
@simonhj Simon (simonhj) marked this pull request as ready for review May 21, 2026 08:37
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue.

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 6f7d89d. Configure here.

Comment thread src/commands/optimize/cmd-optimize-pnpm-versions.test.mts Outdated
The pnpm v8/v9 optimize fixture tests run `pnpm install` inside the
fixture directories during beforeEach to provision the specific pnpm
binary version. The existing afterEach hooks only reset tracked files
(`git checkout HEAD -- .`) but left untracked `node_modules/` and
`.cache/` directories behind, polluting the working tree.

This caused two problems:
1. Running `git add -A` (or relying on pre-commit hooks that do)
   would accidentally stage thousands of untracked fixture artifacts.
2. The pnpm9 fixture install was silently failing (swallowed by
   `try/catch` + `stdio: 'ignore'`), so pnpm9 tests fell back to the
   system pnpm rather than testing against pnpm v9.

Fix:
- Import `trash` and remove `node_modules/` + `.cache/` in both
  beforeEach (to clean up after prior aborted runs) and afterEach
  (to keep the fixture clean going forward).
- Use `Promise.all` for parallel cleanup to avoid `no-await-in-loop`
  lint warnings.

All 4 pnpm-version tests continue to pass and fixtures are now clean
after each run.
@simonhj Simon (simonhj) force-pushed the fix/pnpm-fixture-cleanup branch from 6f7d89d to 82c5e43 Compare May 21, 2026 08:46
Copy link
Copy Markdown
Contributor

@mtorp Martin Torp (mtorp) left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch ✅

@simonhj Simon (simonhj) merged commit 2c214c5 into v1.x May 21, 2026
12 checks passed
@simonhj Simon (simonhj) deleted the fix/pnpm-fixture-cleanup branch May 21, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants