Answer the question
In order to leave comments, you need to log in
How to test render props, jest+enzyme?
Good afternoon! Please tell me how to test the render block if it comes with props?
The code
...
<div>
{drop && deleteBlock('Name')} // этот пропс выводит блок, который я хочу протестировать, что он вывелся
</div>
...
it('should trigger archivedIcon prop when item is drop', () => {
const props= {
...defaultProps,
drop: true,
deleteBlock: jest.fn(),
};
const enzymeWrapper = shallow(<DeleteItem{...props} />);
expect(props.deleteBlock).toHaveBeenCalledTimes(1);
expect(props.deleteBlock).toHaveBeenCalledWith('Name');
expect(enzymeWrapper.find('[data-test="drop"]')).toHaveLength(1); // вот здесь проблема
});
Expected value to have length:
1
Received:
{"length": 0, Symbol(enzyme.__root__): {"length": 1,
....
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question