-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
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
Unable to write unit test for the component code is unreachable. #9
Comments
In my test file: jest.mock('react-http-request', () => ({
})); Code:
Coverage file: A HELP IS REALLY APPRECIATED.. |
i might be using wrong way to mock please correct if you believe so. |
Hi @reeteshsingh93, import React from 'react';
import Request from 'react-http-request';
import renderer from 'react-test-renderer';
jest.mock('react-http-request', () => ({
__esModule: true,
default: jest.fn(({ children }) => children({
error: null,
result: null,
loading: true
}))
}));
it('should render a loader', () => {
const tree = renderer
.create(
<Request
url='https://api.github.com/users/mbasso'
method='get'
accept='application/json'
verbose={true}
>
{
({error, result, loading}) => {
if (loading) {
return <div>loading...</div>;
} else {
return <div>{ JSON.stringify(result) }</div>;
}
}
}
</Request>
)
.toJSON();
expect(tree).toMatchSnapshot();
}); |
No description provided.
The text was updated successfully, but these errors were encountered: