Open
Description
recently I've replaced mocha with jest and I love the snapshot testing feature. Unfortunately this does not work for components using the react-list. The tests are failing with an invariant violation:
Invariant Violation: getNodeFromInstance: Invalid argument.
at invariant (node_modules/fbjs/lib/invariant.js:44:15)
at Object.getNodeFromInstance (node_modules/react-dom/lib/ReactDOMComponentTree.js:162:77)
at findDOMNode (node_modules/react-dom/lib/findDOMNode.js:49:41)
at ReactList.getScrollParent (node_modules/react-list/react-list.js:191:18)
at ReactList.updateScrollParent (node_modules/react-list/react-list.js:325:34)
at ReactList.updateFrame (node_modules/react-list/react-list.js:310:14)
at ReactList.componentDidMount (node_modules/react-list/react-list.js:149:14)
at node_modules/react-test-renderer/lib/ReactCompositeComponent.js:265:25
at measureLifeCyclePerf (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:75:12)
at node_modules/react-test-renderer/lib/ReactCompositeComponent.js:264:11
Googling for this I found some react issues regarding react-test-renderer and react-dom imported by 3rd party libs. Now I am just mocking the react-list in the tests:
// __mocks__/react-list.js
import React from 'react';
const ref = () => {};
export default function ReactListMock ({
items,
itemsRenderer,
itemRenderer,
}) {
const itemElements = items.map ((item, index) => itemRenderer (index, index));
return itemsRenderer (itemElements, ref);
}
Does anyone have another solution?
Or even know whats going wrong in react internals?
Shall we add this to the FAQ section in the readme?
Metadata
Metadata
Assignees
Labels
No labels