Add a testing guide
See original GitHub issueSo, i have been trying to find examples of unit tests and the lack of information i find disturbing…
For example, a couple of versions ago, functions and objects like ready
and watch
would show up green in the code coverage, and idem for the command-line coverage… now i have updated some projects to make use of mocha and suddenly my coverage dropped significantly! And further more i cannot find how to properly test ready()
and watch
, even the official examples do not include unit tests! I have tried asking on gitter as well, but it seems unit-testing isn’t all that popular… But i really need it, since the company i work for considers Vue for a new big front-end, i need to show them that Vue is up to par with the other frameworks out there.
What i would really really need is a guide on how to properly test a single file component. For example, ready() is called by Vue itself, so should i mock this and spy on it to see if its called?! That seems like such a hassle and i would like to have the behavior that was before where it would just show up as covered… cause if there is a error in ready, stuff would already break, right?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:6 (4 by maintainers)
Top GitHub Comments
those slides are very valuable thank you, about that ready thing, have my component mounted on a dummy parent like so:
As per the docs… Now this is what my ready function looks like:
And this is the report output:
Now how do i make sure ready would pass? i have tried a bunch of things now and i am lost. Cause the funny thing is, this was green before i updated it, with all test passing…
Now, after the upgrade i have run my tests again, still they all pass, but my coverage went way down. Maybe some changes were implemented that made it more strict about what code it considered tested?
Also check out http://www.slideshare.net/coulix/vuejs-testing