Replies: 1 comment 8 replies
-
We do this by mocking // ./__mocks__/next-firebase-auth/withAuthUser.js
// the mock just renders its child component
const withAuthUser = jest.fn(() => (wrappedComponent) => wrappedComponent)
export default withAuthUser // ./__mocks__/next-firebase-auth/useAuthUser.js
import getMockAuthUser from './my/test/utils'
const useAuthUser = jest.fn(() => getMockAuthUser())
export default useAuthUser Then, in tests, set the useAuthUser.mockReturnValue(someValue) If you wanted to, you could make your mocks more sophisticated so that the Alternatively, if you chose not to mock |
Beta Was this translation helpful? Give feedback.
-
This could be my sleep-deprived brain misfiring, but how would one set the auth state on a rendering test for a component?
The WithAuthUser HOC checks the return value of
useFirebaseUser
, and the tests for the package mock that function as well.However, because useFirebaseUser is not exported from the package, I can't seem to stub it properly in my app so my components wrapped in the HOC never render. Anyone got any ideas?
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions