I am new to tests with React-Jest-Enzyme , but from all the information I have collected, it seems to me that most of the tests actually check if the React library is breaking, and not my actual business logic.
I will give some examples, and please correct me if I am wrong:
Checking Snapshots:
What is the deal with this strategy?
From what I see, its main purpose is to catch any unwanted changes in my code. he "builds" my component tree and just noticed that if a new line / characters are added, right?
therefore it was most often used for those cases when I accidentally pressed my keyboard? or did someone else accidentally mess up my code?
Enzymes Mounted / Small and Swine
Most of the examples I saw explaining how you use them are something like this:
const wrapper = mount(<MyComponeny />) expect(wrapper.find('button').simulate('click)).toHaveBeenCalledTime(1)
What value can I get from this? If I simulate a button click using simulate('click') enzymes, then I should expect this to trigger a click event.
what am i testing here? The functionality of enzymes?
also gives us the enzyme of the setState method. if wrapper.setState({value: 'some value')} Suppose, to change my state, why I see usage examples as follows:
wrapper.setState({value: 'new value')} expect(wrapper.state('value')).toBe('new value')
?
Why do I need to test the test environment / additional libraries?
it all seems a bit ambiguous