Skip to content

Fix window.matchMedia mock cleanup in header tests#29

Merged
AccessiT3ch merged 2 commits intotest/phase1.5-test-coveragefrom
copilot/sub-pr-26
Feb 1, 2026
Merged

Fix window.matchMedia mock cleanup in header tests#29
AccessiT3ch merged 2 commits intotest/phase1.5-test-coveragefrom
copilot/sub-pr-26

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 1, 2026

The window.matchMedia mock was overwritten in beforeEach but not restored in afterEach, which can leak state to other tests.

Changes

  • Save original window.matchMedia before mocking (consistent with existing scrollIntoView pattern)
  • Restore in afterEach hook
describe("Header", () => {
  let originalMatchMedia;
  
  beforeEach(() => {
    originalMatchMedia = window.matchMedia;
    window.matchMedia = matchMediaMock;
  });
  
  afterEach(() => {
    window.matchMedia = originalMatchMedia;
  });
});

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…leaks

Co-authored-by: AccessiT3ch <95449364+AccessiT3ch@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on establishing test coverage baseline Fix window.matchMedia mock cleanup in header tests Feb 1, 2026
Copilot AI requested a review from AccessiT3ch February 1, 2026 20:26
@AccessiT3ch AccessiT3ch marked this pull request as ready for review February 1, 2026 20:31
@AccessiT3ch AccessiT3ch merged commit baaafab into test/phase1.5-test-coverage Feb 1, 2026
1 check passed
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