【问题标题】:Zombie.js - Test if object property foundZombie.js - 测试是否找到对象属性
【发布时间】:2017-03-16 20:35:08
【问题描述】:

我对 Zombie.js 测试有点陌生,而且很难搜索,所以我会在这里问...

示例: (全局变量)

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 

【问题讨论】:

    标签: javascript node.js testing zombie.js


    【解决方案1】:

    哦,我有一个替代方案(直接使用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();
    });
    

    【讨论】:

      猜你喜欢
      • 2015-09-20
      • 2023-03-27
      • 1970-01-01
      • 2014-12-24
      • 2015-10-10
      • 1970-01-01
      • 2016-11-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多