How to wait for a Blaze template to be renderer before asserting on mocha-web-velocity?

193 Views Asked by At

I have some mocha-web-velocity tests that need the template to be rendered.

I can use setTimeout:

setTimeout(function() { chai.assert.equal($(".text-center").html(), "Something"); done() }, 1500)

This works but I would like not to depend on timeouts but to make the assertion on the rendered callback:

Template.deliver.rendered = function() { chai.assert.equal($(".text-center").html(), "Send a deliveqewrry"); done() }

This only works partially, as the error msg gets logged into the browser's console and the results UI shows an error, but the error diaplayed on the UI says that the timeout has reached (on the browser console I get the correct msg).

  1. Why is the behaviour different between this to approaches?
  2. Which is the best way to make my tests to wait for templates to be rendered?
0

There are 0 best solutions below