I have a component that uses useContext
and then its output is dependent on the value in the context. A simple example:
import React, { useConte
Or if you're testing your component in isolation without mounting the parent components you can simply mocking useContext:
jest.mock('react', () => {
const ActualReact = require.requireActual('react')
return {
...ActualReact,
useContext: () => ({ }), // what you want to return when useContext get fired goes here
}
})
You can still use a dynamic useContext
value with a global jest.fn