Skip to content

Commit 3ff9910

Browse files
frano-mclaude
andcommitted
test: clear all mocks in beforeEach so hook tests are reorder-safe (#955)
Addresses copilot review feedback on PR #959: Router.push and other module-level jest.fn() mocks weren't being cleared between tests, which made assertions order-dependent. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fc089d8 commit 3ff9910

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

tests/useNextAuthService.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const MOCK_LOGIN = service.login as jest.MockedFunction<typeof service.login>;
3131

3232
describe("useNextAuthService", () => {
3333
beforeEach(() => {
34+
jest.clearAllMocks();
3435
mockRouterQuery = {};
3536
MOCK_LOGIN.mockReset();
3637
MOCK_USE_ROUTE_HISTORY.mockReset();

tests/useSessionActive.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const MOCK_USE_ROUTE_HISTORY = useRouteHistory as jest.MockedFunction<
6161

6262
describe("useSessionActive", () => {
6363
beforeEach(() => {
64+
jest.clearAllMocks();
6465
mockRouterQuery = {};
6566
MOCK_USE_ROUTE_HISTORY.mockReset();
6667
MOCK_USE_ROUTE_HISTORY.mockReturnValue({

0 commit comments

Comments
 (0)