Skip to content

test: isolate test files and restore test-scoped spies - #3499

Merged
setchy merged 1 commit into
mainfrom
test/isolation-and-mock-hygiene
Oct 25, 2026
Merged

setchy merged 1 commit into
mainfrom
test/isolation-and-mock-hygiene

Conversation

@setchy

@setchy setchy commented Oct 25, 2026

Copy link
Copy Markdown
Member

Summary

  • Enable per-file isolation so module state cannot leak between test files.
  • Add a shared setup that restores spies created inside a test, while leaving intentional module-scope spies in place for the whole file.
  • Give the notifications util mock a deterministic empty default instead of returning undefined after mockReset().
  • Remove stale mockGitifyNotification.unread resets; the fixture is no longer mutated by the suite.

Why

isolate: false combined with clearMocks (which only clears calls) made test order matter. A global restoreMocks is not safe here because many suites intentionally share spies across tests, so the setup restores only spies created during a test.

Verification

  • pnpm test: 200 files, 1,968 tests passed
  • pnpm exec vp check --no-fmt: 464 files passed

Enable per-file isolation so module state cannot leak between test files. Add a setup that restores spies created inside a test while leaving intentional module-scope spies in place, give the notifications mock a deterministic empty default, and drop stale shared-fixture resets.
@setchy
setchy requested a review from afonsojramos as a code owner October 25, 2026 13:24
@github-actions github-actions Bot added the test Enhancements to test coverage or quality label Oct 25, 2026
@sonarqubecloud

Copy link
Copy Markdown

@setchy
setchy merged commit 5a14eca into main Oct 25, 2026
19 checks passed
@setchy
setchy deleted the test/isolation-and-mock-hygiene branch October 25, 2026 13:30
@github-actions github-actions Bot added this to the Release 7.11.0 milestone Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Enhancements to test coverage or quality

Development

Successfully merging this pull request may close these issues.

1 participant