-
Notifications
You must be signed in to change notification settings - Fork 64
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
String for mocks looks weird #12
Comments
Hi, thanks for raising the bug, I will have a look! |
@eskimoblood Can you give me more details about your test? How exactly are you mocking the component? |
In one of my project, I'm using jest.mock('../Field', () => {
return function Field(props) {
return props.children;
};
}); and it works fine with But I'm interested in your issue, can you provide more details? |
I'm using the approach from thus gist |
But let me try your approach, maybe this fix the problem. |
Cool, thanks for the link, I'm looking at it! |
Ok so I've just tried that (basically just copying from your link): function mockComponent(componentName) {
return props => {
return (
<mocked originalComponent={componentName} {...props}>{props.children}</mocked>
);
};
}
jest.mock('./fixtures/mocked-component', () => { return mockComponent('Icon'); });
import MockedComponent from './fixtures/mocked-component';
it('converts a mocked component', () => {
const shallowed = shallow(
<MockedComponent className="class"><strong>Hello!</strong></MockedComponent>
);
expect(shallowToJson(shallowed)).toMatchSnapshot();
}); and the snapshot output is: exports[`test converts a mocked component 1`] = `
<mocked
className="class"
originalComponent="Icon">
<strong>
Hello!
</strong>
</mocked>
`; which seems ok 🤔 |
I too had transpiled code in my snapshot even with react-test-renderer jestjs/jest#1756 though it is closed, @cpojer acknowledge it was reported by others too. |
I just move to
as suggested in the comments of the gist and it works. So just close the issue. Thanks for your help. |
Ok thanks for the insight @bsr203, that's strange 🤔 @eskimoblood I'm glad it works with you 😊 I'm still curious of what was causing that. |
I use Jest to mock out some child components, with the
react-test-renderer
I gotusing
enzyme
andshallowToJson
I got:Do you think its possible to recognise mocks and render they just like the
react-test-renderer
.The text was updated successfully, but these errors were encountered: