zombie.js visit() calling back too early (using browserify)
Im using zombie to test a backbone app, when I use zombie.visit, zombie calls the vows callback before all scripts on the page are loaded, so my backbone app isn't loaded. However if I wait for the 'done' event, i.e. browser.on 'done', @callback
then my backbone app gets loaded before the call开发者_运维技巧back is called.
Anyway to get the visit function to only callback once the 'done' event is received?
PS Im using browserify to load quite a large script including backbone/underscore/jquery and other jquery plugins
I ran in to the same thing but, oddly, I used some of your other suggestions to use 'on done' to figure out a way to wait until the document was completely loaded (including any dynamically injected from JS stuffs!).
it('should have the correct title', function() {
browser.on('done', function(doc) {
console.log("DONE finally finito..");
//console.log(browser.html());
expect(doc.document.title).toMatch('.*Login');
expect(doc.document.title).not.toEqual('XXXXX');
asyncSpecDone();
});
browser.visit(LOGIN, function(err, doc) {
});
asyncSpecWait();
});
where LOGIN is a URL to my login page. the browser.html() printed out the full page and I saw the dynamically inserted elements as expected. FWIW, my application is using node .ejs files that express.js is compiling on the fly; but this will likely apply to any dynamically injected page that you want to test with zombie.
To my mind this looks like an anti-pattern and I would love if the author either corrects me or posts an alternative. However, this is a workaround.
精彩评论