C
C
colorkid2019-09-14 21:28:47
JavaScript
colorkid, 2019-09-14 21:28:47

Can't see React component under test, how to fix?

Hello. I am writing tests for a React app.
There is a class component export class MyComponent extends React.Component
which has a clearState method which clears the state of the component.
in all tutorials they write something like
const MyComponent = shallow();
MyComponent.clearState()
and then see if the state has changed. BUT I have MyComponent in the console empty object {}
Why is MyComponent empty after shallow()?
Tried doing const MyComponent = shallow().instance();
but when calling the MyComponent.clearState() method, the state does not change in any way...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question