Zombie.js - 测试是否找到了对象属性

时间:2016-11-03 09:54:07

标签: javascript node.js testing 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 

1 个答案:

答案 0 :(得分: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();
});