Template testing
Helpers
waitForElement
Use this function in your test if you need to wait for a DOM element.
Your test needs to be asynchronous.
function waitForElement(selector, successCallback) {
var checkInterval = 50;
var timeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL;
var startTime = Date.now();
var intervalId = Meteor.setInterval(function () {
if (Date.now() > startTime + timeoutInterval) {
Meteor.clearInterval(intervalId);
// Jasmine will handle the test timeout error
} else if ($(selector).length > 0) {
Meteor.clearInterval(intervalId);
successCallback();
}
}, checkInterval);
}
Updated less than a minute ago