Search code examples
meteorintegration-testingfunctional-testingmeteor-blazetinytest

How do I write tests for Meteor which involves templating?


I recently created a Meteor package and want to write some tests. What my test package basically do is that users can insert into the template {{> abc}} and they'll get an HTML element printed on the page.

With TinyTest, all you can do is test the package's API using something like test.equal(actual, expected, message, not). However, I need it to test whether the element was successfully printed on the page. Furthermore, I will pass the template some parameters and test them too.

It seems like I'd have to create a dummy app, run bash to initiate the app, and test whether the elements can be found on page. So should I only use TinyTest to test the API, and write my own tests (somehow!) for templating? If not, how should I go about it?

I read something about Blaze.toHTML, but I cannot find anything in the documentation on it? Nor it's source page.


Solution

  • I think TinyTest is great for starting with Unit testing, but what you need sounds more like an Integration test.

    I would recommend you look into the following links for more info on testing with Meteor, especially with Velocity - Meteor's official testing framework:

    You can create a demo application, and run integration tests using Mocha or Jasmine.