`How to debug components in Enzyme?
R
R
Roman Yakimchuk2019-12-12 09:51:00
JavaScript
Roman Yakimchuk, 2019-12-12 09:51:00

How to debug components in Enzyme?

Friends,
How to debug a component in Enzyme?
```
test('Should create To-do item', () => {
let callback = jest.fn();
let instance = mountWithIntl();
let name = 'Name';
let content = 'Content';
instance .find('input[name="name"]').simulate('change', { target: { value: name } });
instance.find('input[name="content"]').simulate( 'change', { target: { value: content } });
instance.find('form').simulate('submit');
expect(callback).toHaveBeenCalled();
});
```
The test fails. In fact, the form works fine, i.e. obviously there is a bug somewhere or in the testing environment. It turns out that debugging is needed, but nothing is thrown. The test simply fails, and it’s completely impossible to understand at what point nothing happens (i.e. whether props were passed, whether a function was called inside the component) now is completely impossible.
How to output a log from a component when it is launched via Enzyme?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Yakimchuk, 2019-12-12
@yakimchuk-ry

While writing the question, I found the answer: https://stackoverflow.com/questions/54596066/how-t...
With --verbose false the log worked (strange, the verbose log was turned off, but it worked J)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question