Understanding Browser Redirection in zombieJS

105 views
Skip to first unread message

Olajide Aderibigbe

unread,
Nov 12, 2015, 3:58:35 AM11/12/15
to zombie.js
Hi all, I'm new to testing with zombieJS and I'm having a block and I don't seem to understand it. 

I have a link (anchor tag), that on click redirects to another url say `http://www.example.com` from the testing page say `localhost:3000/global.html`
I have written a test to check if the href has a value which actually passes.

describe('On link click with redirect link', function() {
    it('confirm that it has href value', function(done) {
      var link = browser.link('#link2');
      assert.equal(link.href, 'http://www.example.com/');
      done();
    });
     it('do not follow that redirection', function(done){
       var link = browser.query('#link');
       browser.click(link, function(evt){
        //Do something and not follow the redirection
       //more like evt.preventDefault();
         done();
       })
     });
     it('redirects page to href value', function(done){
       var link = browser.query('#link');
       browser.click(link, function(){
           assert(browser.redirected);
           assert.equal(browser.location, 'http://www.example.com/')
           done();
       })
     });
});

the remaining two tests fail because I couldn't detect or stop the browser from loading the page if it detects redirection.
Please can anyone advice on what I need to do?.
Also is there an underlying principle or what is generally the concept around testing browser redirection.
PS: I have also tried using browser.wait, but the test is still failing.

Thanks!


Reply all
Reply to author
Forward
0 new messages