I am using Enzyme
to unit test my React components. I understand that in order to test the raw unconnected component I\'d have to just export it and test it (I\
If we have a router issue, we can consider to add the router lib into the test file, eg:
import React from 'react';
import { Provider } from 'react-redux';
import { BrowserRouter as Router } from 'react-router-dom';
import { mount } from 'enzyme';
import ReadDots from './ReadDots';
const storeFake = state => ({
default: () => {
},
subscribe: () => {
},
dispatch: () => {
},
getState: () => ({ ...state })
});
const store = storeFake({
dot: {
dots: [
{
id: '1',
dot: 'test data',
cost: '100',
tag: 'pocket money'
}
]
}
});
describe(' ', () => {
it('should render ReadDots component', () => {
const component = mount(
);
expect(component.length).toEqual(1);
});
});