Skip to content

Conversation

@sundaray
Copy link
Contributor

@sundaray sundaray commented Dec 26, 2025

Moved the patching and restoration of window.location from inside the individual tests to the beforeEach and afterEach hooks in the describe block.

Previously, if a test assertion failed before the inline restoration code ran, window.location would remain mocked, potentially polluting subsequent tests. With this change, afterEach guarantees restoration regardless of test outcome.

@sundaray sundaray requested a review from a team as a code owner December 26, 2025 19:29
@sundaray sundaray requested a review from ericroberts December 26, 2025 19:29
@sundaray sundaray changed the title fix(tests): move window.location mocking to beforeEach/afterEach fix(tests): move window.location patching and restoration to beforeEach/afterEach Dec 27, 2025
Move window.location mocking into a nested describe block containing
only the two tests that verify reload behavior. This ensures:
- Other tests run with real window.location
- Mock setup/teardown in beforeEach/afterEach guarantees cleanup
  even when assertions fail
@nicknisi nicknisi merged commit 3f50933 into workos:main Jan 6, 2026
5 checks passed
@nicknisi
Copy link
Member

nicknisi commented Jan 6, 2026

Thanks!

@nicknisi nicknisi mentioned this pull request Jan 7, 2026
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