I’m working on a project at the moment and I’ve been asked to introduce some testing. I have a few questions.
Is the state of Meteor testing at a point where investing hours learning about it will pay off yet?
How capable is it?
Should I be using velocity?
Which frameworks should I use?
What are the best resources for learning?
I’ll be using the responses of this post to decide whether or not I should attempt to introduce testing to my project or whether I should try to explain that testing in Meteor is "not quite ready yet but I hope I won’t have to do that.
I believe every piece of software should have testing, and if you have done testing in other web frameworks, you might find it to be very similar.
For myself, I use sanjo:jasmine with the velocity html reporter. You can use the jasmine introduction guide to get you started. Also, you can look at my github code to see how I used testing in meteor.
Learning jasmine isn’t too bad, and it applies to more frameworks than just meteor.
I’ve just starting testing a fairly complex Meteor package I’ve been writing and have found the process to be well worthwhile. Even though I only had a very limited set of tests written, they caught a bunch of errors that I wouldn’t otherwise have spotted during a recent refactor. I’m using sanjo:jasmine with the velocity html reporter.
I’ve also dabbled with xolvio:cucumber and, although I don’t have much of a clue about how to get the best out of it, I can see that it will be pretty awesome for BDD. This tutorial is fantastic. I’d really like to see a bunch of cucumber tests written for a simple app (like the leaderboard and/or todos app) – anyone know of something like this?
Based on my fairly limited experience:
I think Meteor testing is definitely at the stage where investing the hours of learning is worthwhile.
I’m quite impressed with the velocity project and how much easier it makes testing. I don’t have much past experience to compare it with, but I’ve found the testing capabilities of the packages mentioned above to cover everything I need.
I think velocity gives you a really good leg-up into testing. Personally, I need to see a few more examples of testing done well, but I think that’s just a case of me having to go looking around the Meteorverse a bit.
I’ve found sanjo:jasmine and xolvio:cucumber with the velocity html reporter to be pretty handy. For other frameworks, I know that @awatson1978 has done some serious work with starrynight for industrial strength testing, but I don’t know too much else about it.
The post I mentioned above got me up and running with xolvio:cucumber and I was lucky enough to have someone else bootstrap a test suite for my package using sanjo:jasmine. I find that looking at tests for code I’m familiar with to be the quickest way to learn patterns and syntax.
So is sanjo:jasmine current? I remember playing around with it many months ago but when I tried to install it today I can’t even get the package to install, even in a freshly created app. Just dies with an exception out of future.js. Maybe there’s some undoc prerequisite I’m missing?
[update] I solved the problem with adding the package by reinstalling meteor. Not sure why I didn’t think of it sooner. It had been at least a couple of days since the last reinstall but it wasn’t exhibiting the usual symptoms of needing a reinstall.
Anyway, now I’ve got velocity going with jasmine. Looks much more refined than the last time I tried it.