DEV Community

Discussion on: Testing React Hook State Changes

Collapse
 
juuuuuuuuuuuuuu profile image
juuuuuuuuuuuuuu

Testing state change with hooks,
How to test init state ??

describe('init value, () => {
it('init value', () => {
expect(setState).toHaveBeenCalledWith(0);
});
});

This code doesn't pass.
please help me how to check init state!!

Collapse
 
theactualgivens profile image
Andrew Givens

My recommendation for testing the initial state would just be test that React.useState is called with your initial state value.