DEV Community

Discussion on: VueJS Testing: What Not How

Collapse
anthonygore profile image
Anthony Gore

Hi Ricardo. Thanks for posting this, testing is one of the trickiest areas of Vue.

That said, I don't really see the point in testing this way. Most of the tests here are either testing Vue core functionality, which already has tests, or are duplicating other error mechanisms. For example, if you mess up your props or text interpolations, you'll get a compilation error that tells you the same info as what these tests do.

I do believe in unit tests, I just think they're only valueable when they're more abstract i.e. testing the inputs and outputs of the component, not implementation details.

For this component, I think one snapshot test is all that's needed!

Collapse
rdelga80 profile image
Ricardo Delgado Author

Hi Anthony, fan of your work and I appreciate the feedback.

Yes, I absolutely agree, and I really hope the intention of the post isn't lost in the details of the examples I used.

I'm more trying to convey the concept of what it looks like to have tests drive what you code rather then going back and writing tests after writing code.

I hope the examples didn't distract from the concept, even though I think testing a props validator is useful.

But I'll go back and choose some better examples if you think the point gets that lost.