I am trying to test the React component that uses the browserHistory of a reactive router. To provide access to browserHistory, I use the createMemoryHistory module (reactive router) as follows:
let createMemoryHistory = require('react-router/lib/createMemoryHistory');
In the test env, I use the JSDOM library.
global.document = jsdom(''); global.window = document.defaultView;
Then I try to assign the created DOM history object:
let history = createMemoryHistory(); global.history = history;
When rendering a component in a test environment, I get the following error:
Invariant violation: browser history requires DOM
Any idea how to overcome it?
magos source share