{"_id":"55bf6a0303d092210084c146","category":{"_id":"55c345418713ec1900d1732d","project":"55a92d71cf45e1390093f321","version":"55a92d71cf45e1390093f324","__v":2,"pages":["55c345838713ec1900d17330","55c34683b6e05719008a046e"],"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-08-06T11:30:09.092Z","from_sync":false,"order":2,"slug":"jasmine-advanced","title":"Jasmine Advanced"},"version":{"_id":"55a92d71cf45e1390093f324","__v":12,"project":"55a92d71cf45e1390093f321","createdAt":"2015-07-17T16:29:37.746Z","releaseDate":"2015-07-17T16:29:37.746Z","categories":["55a92d72cf45e1390093f325","55b9aea1baf4cd2300bc56e7","55bf16593179dd1900a19521","55bf16b93179dd1900a19525","55bf16c53bbd4b17002c2369","55bf234703d092210084c07b","55bf2859ad601c2b00762c4c","55bf3217ad601c2b00762c69","55bf321b03d092210084c09d","55bf5ef78b83a5370044504e","55c345418713ec1900d1732d","55c3473057f7f32d0016ec0a"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"user":"55a4738a68c7e20d0036d4de","project":"55a92d71cf45e1390093f321","parentDoc":null,"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-08-03T13:17:55.082Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":4,"body":"## Helpers\n\n### waitForElement\n\nUse this function in your test if you need to wait for a DOM element.\nYour test needs to be [asynchronous](http://jasmine.github.io/2.1/introduction.html#section-Asynchronous_Support).\n\n```javascript\nfunction waitForElement(selector, successCallback) {\n  var checkInterval = 50;\n  var timeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL;\n  var startTime = Date.now();\n  var intervalId = Meteor.setInterval(function () {\n    if (Date.now() > startTime + timeoutInterval) {\n      Meteor.clearInterval(intervalId);\n      // Jasmine will handle the test timeout error\n    } else if ($(selector).length > 0) {\n      Meteor.clearInterval(intervalId);\n      successCallback();\n    }\n  }, checkInterval);\n}\n```","excerpt":"","slug":"jasmine-template-testing","type":"basic","title":"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](http://jasmine.github.io/2.1/introduction.html#section-Asynchronous_Support). ```javascript 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); } ```