I have a component 'A' which includes other component 'B'. The component 'B' has withRouter in it. while writing test cases for component 'A' testing component 'B', the result is component not found.
import React from 'react';
import B from './someFile';
const A = () => {
return (
<B />
);
};
export default A;
import React from 'react';
import { withRouter } from 'react-router-dom';
const B = withRouter(({ history }) => {
#some code
});
export default B;
import React from 'react';
import { shallow } from 'enzyme';
import A from '../someFileA';
describe('A component', () => {
const component = shallow(<A />);
it('render A', () => {
shallow(<A />);
});
it('should verify B', () => {
expect(component.find('B')).toHaveLength(1);
});
});
error I am getting is :
expect(received).toHaveLength(expected)
Expected length: 1
Received length: 0
Aucun commentaire:
Enregistrer un commentaire