next-auth v5 with jest / testing library
Unanswered
Sloth bear posted this in #help-forum
Sloth bearOP
hi! has anyone successfully set up a project with next-auth v5 with tests using jest? i can't test any of my components because they need to be authenticated, and i couldn't find a way to mock the next-auth library 😦
the error:
the error:
Cannot find module 'next-auth' from '__tests__/Home.test.tsx'
1 | import '@testing-library/jest-dom';
> 2 | jest.mock('next-auth');2 Replies
Bighead carp
Hi does this help? https://github.com/nextauthjs/next-auth/discussions/4185
Sloth bearOP
hi!, unfortunately this didn't help :/
it still cannot find the module and throws an error here:
jest.mock("next-auth/react"
it still cannot find the module and throws an error here:
jest.mock("next-auth/react"