We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I went through this already existing issue: #372
But my mock for the useAuth function is simply not working. Can someone help please ?
useAuth
I added the below code segment to my test file:
const auth = require('react-oidc-context'); jest.mock('react-oidc-context', () => { const orig = jest.requireActual('react-oidc-context'); return { __esModule: true, default: jest.fn(), useAuth: jest.fn(), ...orig, }; }); auth.useAuth.mockResolvedValue('test'); render(<App />, { wrapper: ({ children }) => ( <AuthProvider authority='authority' client_id='client' redirect_uri='redirect' > {children} </AuthProvider> ), }); waitFor(() => { expect( screen.getByText('Tournaments managed by Lotus Chess Academy') ).toBeInTheDocument(); }); });
I'm getting the error TypeError: auth.useAuth.mockResolvedValue is not a function. I have a nextjs project with typescript enabled.
TypeError: auth.useAuth.mockResolvedValue is not a function
The text was updated successfully, but these errors were encountered:
With auth.useAuth.mockResolvedValue('test'); you mock useAuth like it would be a string ("test"), but it is a function...
auth.useAuth.mockResolvedValue('test');
Sorry, something went wrong.
@pamapa Actually I tried this first but it didnt work:
jest.mock('react-oidc-context', () => { const orig = jest.requireActual('react-oidc-context'); return { __esModule: true, default: jest.fn(), useAuth: jest.fn, ...orig, }; });
I might have pasted my last snippet out of a lot of failed attempts...
No branches or pull requests
I went through this already existing issue:
#372
But my mock for the
useAuth
function is simply not working. Can someone help please ?I added the below code segment to my test file:
I'm getting the error
TypeError: auth.useAuth.mockResolvedValue is not a function
.I have a nextjs project with typescript enabled.
The text was updated successfully, but these errors were encountered: