-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
NextJS 14 with Sentry 8.48.0: [RouterEvents not found] #14928
-
Hello,
We just upgraded our sentry version to the latest release as of today.
And started seeing this issue in Jest tests.
TypeError: Cannot read properties of undefined (reading 'events')
at Object.<anonymous> (node_modules/@sentry/nextjs/src/client/routing/pagesRouterRoutingInstrumentation.ts:19:50)
at Object.<anonymous> (node_modules/@sentry/nextjs/build/cjs/client/routing/nextRoutingInstrumentation.js:5:43)
at Object.<anonymous> (node_modules/@sentry/nextjs/build/cjs/client/browserTracingIntegration.js:4:36)
at Object.<anonymous> (node_modules/@sentry/nextjs/build/cjs/client/index.js:12:35)
at Object.<anonymous> (node_modules/@sentry/nextjs/build/cjs/index.client.js:3:15)
at Object.<anonymous> (src/context/CurrentUserStateProvider.tsx:[25](https://github.com/semper-aviation/goodwin_web/actions/runs/12655302982/job/35265273114#step:5:26):17)
at Object.<anonymous> (src/components/layout/appShell/Navbar.tsx:18:35)
at Object.<anonymous> (src/components/layout/appShell/Navbar.test.tsx:11:56)
Since we dont have next/router usage anymore move to app dir with nextjs, what can we do to fix these errors.
I was not able to find any documentation on mocking this or get rid of this ?
Beta Was this translation helpful? Give feedback.
All reactions
No I am not.
Only thing after migrating to NextJS14 was this.
jest.mock('next/navigation', () => ({
usePathname: jest.fn(),
}))
;(usePathname as jest.Mock).mockImplementation(() => '/')
However for my test to pass I had to add this to work now...
jest.mock('@sentry/nextjs', () => ({
browserTracingIntegration: jest.fn().mockReturnValue({}),
}))
Replies: 1 comment 1 reply
-
Hi, are you mocking the Next.js router in any way?
Beta Was this translation helpful? Give feedback.
All reactions
-
No I am not.
Only thing after migrating to NextJS14 was this.
jest.mock('next/navigation', () => ({
usePathname: jest.fn(),
}))
;(usePathname as jest.Mock).mockImplementation(() => '/')
However for my test to pass I had to add this to work now...
jest.mock('@sentry/nextjs', () => ({
browserTracingIntegration: jest.fn().mockReturnValue({}),
}))
Beta Was this translation helpful? Give feedback.