-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[test] Jest snapshot testing "getNodeFromInstance: Invalid argument" #8739
Comments
@sakulstra Could you provide a reproduction project? I can't see why the snapshot testing wouldn't work. Could it be a jest issue? |
@oliviertassinari it probably is, yes. Upgrading react/react-dom and react-test-renderer to v16 solves the issue for me(sadly i can't just do this). I'll dig a bit deeper and setup a test repo tomorrow if i find some time. |
@sakulstra this is a shot in the dark based on the error message and the fact that you're using storyshots: you might need to provide the |
@pelotom sadly no, but I think I located the problem: facebook/react#7371 value: function componentDidMount() {
this.button = (0, _reactDom.findDOMNode)(this);
(0, _keyboardFocus.listenForFocusKeys)();
} isn't supported be react-test-renderer (awkward that it works with v16, can't find any docs stating a change here) The fix for me was to mock FindDOMNode like stated in one of the comments: jest.mock('react-dom', () => ({
findDOMNode: () => {}
})); Not sure if this is the best solution, but it should be sufficient till we switch over to v16. @oliviertassinari I think this issue can be closed, but does it make sense to include some info in the docs? I've seen there is a poll about dropping v15 support, so the docs would probably be obsolete soon. |
Isn't this issue linked to #7710? The behavior changed with https://github.com/callemall/material-ui/pull/8218/files. |
yep seems to be related :/ didn't find it in the issue list. |
@sakulstra Thanks a lot for the reproduction example! I confirm, it's broken with react@15 and it's working fine with react@16. We could have added some warnings internally, but given the issue is fixed upstream, I think that it's simpler to close the issue. People facing the issue can easily find the issue and the solution here. |
I currently use snapshot testing for a project, but it seems like as soon as i'm using a component which relies on material-ui/Button the tests fail with.
Expected Behavior
Snapshot testing is possible with all components.
Current Behavior
Snapshot testing isn't possible for some components.
Steps to Reproduce (for bugs)
Write a snapshot test for e.g.
import Hidden from 'material-ui/Hidden';
and one forimport Button from 'material-ui/Button';
(is there a pastebin which is capable of this?)Context
I tried using storyshots for snapshot testing of components using material-ui components.
The text was updated successfully, but these errors were encountered: