https://www.youtube.com/watch?v=OIpfWTThrK8
It is good but could use some clarification and revision 5 years later...
Reasons to test:
- Confidence/Removal of Fear to Change Code
- The product that rhymes with "Packer" is a good example of this. Devs are afraid to touch the code and when we do, more regressions have arisen.
- Code Quality
- Good testing -> higher code quality
- SRP
- Modular
- Forces you to think about what my component really is doing?
- Good testing -> higher code quality
- Tests are good documentation
it('hides the logOut button if the user is not logged in', () => {
expect(wrapper.findByInnerText('Log Out')).to.exist()
wrapper.setProps({loggedIn: false}))
expect(wrapper.findByInnerText('Log Out')).not.to.exist()
})
I disagree on #1... it is not testing the framework (vue)!
Input: myProp Output: DOM
We are not testing vue! Perhaps a non contrived example would be better:
it('displays the full name', () => {
expect(wrapper.text()).toInclude(testProps.fullName)
})
I agree on #2, prop validation is vue framework and we shouldn't test that.