2016-11-03 26 views
0

林有點新Zombie.js測試,而且很難尋找所以我會在這裏問...Zombie.js - 如果測試對象屬性發現

例子:(Globla變量)

hello = {"world" : "...."} 

所以我測試是這樣的:

describe('Check varibles', function() { 
    it('If ---> hello <--- exits', function(done) { 
     browser.assert.global('hello'); 
     done(); 
    }); 

    it('If ---> hello.world <--- exits', function(done) { 
     // ???? 
     done(); 
    }); 
}); 

我可以檢查hello是否退出。 但如何檢查如果hello.world`退出?

我試着用:

browser.assert.global('hello.world'); // AssertionError: undefined == true 

回答

0

哦,我得到了一個替代(使用assert直接)

第一:需要assert

const assert = require('assert'); 

所以做類似的事情:

it('If ---> hello.world <--- exits', function(done){ 
    assert.ok(browser.window.hello.world); 
    //assert.ok(!browser.window.hello.world); <-- or check if not exits 
    done(); 
});