O'Reilly logo

Meteor: Full-Stack Web Application Development by Marcelo Reyna, Isaac Strack, Fabian Vogelsteller

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unit tests

Unit tests are much easier to build than behavior tests. These tests make sure that only a section of the web application is working correctly, such as Meteor.method or a template helper.

Unit tests make it quicker to find bugs in broken behavior tests. They should be used mostly in parts that you know can break easily, such as a publisher or a particular helper.

To run unit tests, we are going to use the sanjo:jasmine package:

meteor add sanjo:jasmine

Now create two directories: /jasmine/client/integration and /jasmine/server/integration. These are the special directories where jasmine runs tests. Let's build a quick test for the products publisher:

# /tests/jasmine/client/integration/publishers/products_pub_test.coffee do -> 'use strict' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required