Skip to content

chore(test): move vitest cache to node_modules/.cache#616

Merged
John-David Dalton (jdalton) merged 1 commit intomainfrom
chore/vitest-cache-to-node-modules
Apr 24, 2026
Merged

chore(test): move vitest cache to node_modules/.cache#616
John-David Dalton (jdalton) merged 1 commit intomainfrom
chore/vitest-cache-to-node-modules

Conversation

@jdalton
Copy link
Copy Markdown
Contributor

Summary

  • Vitest's cacheDir moves from ./.cache/vitest to ./node_modules/.cache/vitest in both the main and isolated configs.
  • pnpm install already wipes node_modules/ (and its .cache/ subdir), so this buys us free cache invalidation on every install — no dedicated clean step needed.
  • Matches the pattern applied in ../socket-packageurl-js and ../meander.
  • Drops **/.cache from .gitignore since nothing writes to a top-level .cache/ anymore.

Adjacent fix: test/unit/utils.test.mts's resolveAbsPaths assertion matched on "socket-sdk-js/package.json", which breaks when the test runs from a git worktree whose directory name doesn't match the primary checkout. Switched to suffix matching (/package.json$, /src/index.ts$) which still verifies the path was resolved to absolute without baking in the repo's directory name. Caught while running the full suite from a socket-sdk-js-cache/ worktree.

Test plan

  • pnpm exec vitest --config .config/vitest.config.mts --run → 565/565 passing.
  • pnpm run build → clean.
  • Ran from a non-primary worktree path — the utils.test.mts fix confirmed.

`pnpm install` already clears `node_modules/` (and its `.cache/`
subdir) automatically, so pinning vitest's cacheDir there gives
us free cache invalidation on every install without needing a
dedicated clean step. Matches the pattern applied in
../socket-packageurl-js and ../meander.

Applied to both vitest configs (main + isolated).

Dropped `**/.cache` from .gitignore — nothing writes to a
top-level `.cache/` anymore; remaining cache consumers all land
under node_modules.

Also fixes test/unit/utils.test.mts's resolveAbsPaths assertion
to match on the path suffix (`/package.json`, `/src/index.ts`)
rather than the repo-dir name. Previous form ("socket-sdk-js/
package.json") broke when the test ran from a git worktree
whose working-tree path didn't match the primary checkout's dir
name. Suffix assertions are worktree-robust without losing the
"path-was-resolved-to-absolute" signal.
@jdalton John-David Dalton (jdalton) merged commit 9373853 into main Apr 24, 2026
11 checks passed
@jdalton John-David Dalton (jdalton) deleted the chore/vitest-cache-to-node-modules branch April 24, 2026 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants