I'm testing Hero component using jest & enzyme. I thought to my mind that I can do the same thing in the two ways.
For example, I want to get a component's state.
test('Test description', () => {
const element = shallow(
<Hero />
);
// 1
expect(element.state()).toBeTruthy();
// 2
expect(element.instance().state).toBeTruthy();
});
I have two variants to write this code: using .instance().state or .state(). Probably there are recommendations how to write code like that?
Aucun commentaire:
Enregistrer un commentaire