-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Support react shallow render. #18
Comments
This should be as easy as importing ReactTestComponent from pretty-format plugins here and pass it to pretty-format config (also adjusting the |
That's not actually solving the issue. I'll give a more complete example to illustrate my use-case: describe('snapshot-diff tests', () => {
const Bar = () => <span>inside Bar</span>;
const Foo = ({ text = 'none' }) => <div><Bar /><span>{text}</span></div>;
it('diffs react components', () => {
const shallowNode = component => shallow(component).getNode();
const base = <Foo />;
const withText = <Foo text="something" />;
expect(shallowNode(base)).toMatchDiffSnapshot(shallowNode(withText), {
aAnnotation: 'base',
bAnnotation: 'with text',
});
});
}); Running this yield the following snapshot: Snapshot Diff:
- <div><Bar /><span>none</span></div>
+ <div><Bar /><span>something</span></div>
<div>
<span>
inside Bar
</span>
<span>
- none
+ something
</span>
</div>
`; What I would like to get is: Snapshot Diff:
- base
+ with text
<div>
<Bar />
<span>
- none
+ something
</span>
</div>
`; That could be done by giving the user the choice of rendering for React Components, instead of using
|
Faced the same issue. Are the any updates or workarounds here? |
Provides new addSerializers function to add additional serializer objects to be used before diffing. Fixes jest-community#18 Fixes jest-community#30
Provides new addSerializers function to add additional serializer objects to be used before diffing. React component serializer implementation using `react-test-renderer` has been extracted out. Fixes jest-community#18 Fixes jest-community#30
Provides new setSerializers function to set the serializer objects to be used before diffing. React component serializer implementation using `react-test-renderer` has been extracted out. Fixes jest-community#18 Fixes jest-community#30 Fixes jest-community#31
Provides new setSerializers function to set the serializer objects to be used before diffing. React component serializer implementation using `react-test-renderer` has been extracted out. Fixes jest-community#18 Fixes jest-community#30 Fixes jest-community#31
Provides new setSerializers function to set the serializer objects to be used before diffing. React component serializer implementation using `react-test-renderer` has been extracted out. Fixes jest-community#18 Fixes jest-community#30 Fixes jest-community#31
I usually write the snapshot tests using enzyme shallow render:
I would like to keep this approach when having diffs. However, I get fully rendered components when I do:
That's because
.getNode
also returns a React Component so the diff will choose the react diff pathI'm not sure what would be the solution for this. I've modified the code to ignore the Component check statement and it works fine with diffStrings.
The text was updated successfully, but these errors were encountered: