lundi 6 juin 2016

History for Mocha tests for react components

I have started to write tests for my react components with Mocha. And when I started npm test I got an exception

Invariant Violation: Browser history needs a DOM

I was tried to connect history object to test file:

 import React, {Component} from 'react'
 import Modal from 'react-modal';
 import expect from 'expect'
 import TestUtils from 'react-addons-test-utils'
 import {AdminPage} from '../../app/DOM/pages/AdminPanel'
 const history = require('history');
 const historyObj = history.createMemoryHistory();
 historyObj.createLocation('/admin');

But I'v got this exception again. How I can solve this problem?

Aucun commentaire:

Enregistrer un commentaire