Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Meteor Design Patterns

You're reading from   Meteor Design Patterns Accelerate your code writing skills with over twenty programming patterns that will make your code easier to maintain and scale

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher Packt
ISBN-13 9781783987627
Length 184 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Marcelo Reyna Marcelo Reyna
Author Profile Icon Marcelo Reyna
Marcelo Reyna
Arrow right icon
View More author details
Toc

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'

  describe "Products publisher", ->
    it "should return product data", ->
      # SETUP
      subscription = Meteor.subscribe("products")

      if subscription.ready()
        # EXECUTE...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image