'Jest/Enzyme create test script for component having export as withOktaAuth and withRouter
I am having a component exported as
export default withRouter(withOktaAuth(ComponentName));
In my .test.js file, I am creating mock as below -
jest.mock('@okta/okta-react', () => ({
useOktaAuth: jest.fn().mockReturnValue({
authState: {},
authService: {}
}),
withOktaAuth: jest.fn(x => x)
}));
But it is returning -
<ContextConsumer>
[function]
</ContextConsumer>
My jest function is as below -
describe('My Component', () => {
it('test component input form', () => {
const component = shallow(<MyComponent/>);
console.log('component',component.debug());
});
});
Can you please confirm how to fetch component mount() of an authenticated route?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
