问题
I am using createMockNode from react-test-renderer and have mocked out the style to prevent undefined errors.
let createNodeMock = (element) => {
if (element.type === 'input') {
return {
style: {"color":"red"},
};
}
return null;
}
This has prevented the "undefined" error on style, but now I get this error :
TypeError: Cannot read property '_ownerDocument' of undefined
at unstable_runWithPriority (A:\frontend\node_modules\scheduler\cjs\scheduler.development.js:643:12) TypeError: Cannot read property '_ownerDocument' of undefined
at exports.matchesDontThrow (A:\frontend\node_modules\jest-environment-jsdom\node_modules\jsdom\lib\jsdom\living\helpers\selectors.js:8:27)
at setPropertiesFromRule (A:\frontend\node_modules\jest-environment-jsdom\node_modules\jsdom\lib\jsdom\browser\Window.js:536:72)
at forEach.call.rule (A:\frontend\node_modules\jest-environment-jsdom\node_modules\jsdom\lib\jsdom\browser\Window.js:552:11)
(BTW, I am testing react-bootstrap-typeahead inside my component.)
Am I correctly creating the mock object for the input?
来源:https://stackoverflow.com/questions/58234007/cannot-read-property-ownerdocument-of-undefined-while-mocking-ref