【发布时间】:2013-05-19 04:29:19
【问题描述】:
我正在尝试在 express 应用上使用zombie.js(带有 mocha),以确保某些元素不会显示在页面上。这是我尝试这样做的方法:
var app = require('../app).app, // this is express but you don't care
chai = require('chai'),
should = chai.should(),
Browser = require('zombie'),
browser = new Browser();
describe("page", function() {
it('should not have a the whatever element', function(done) {
browser.visit('http://localhost:3000', function() {
browser.query('#whatever').should.not.exist;
done();
});
});
});
现在当我运行这个测试时,它总是失败:
-
如果#whatever 存在,我得到这个:
expected <div class="whatever">whatever</div> to not exist -
如果 #whatever 不存在,我希望测试通过,但我也会收到错误消息
TypeError: Cannot read property 'should' of null
也许这是一个愚蠢的测试,但有没有办法进行这样的测试以使其通过?我哪里做错了?
谢谢。
【问题讨论】:
标签: node.js express mocha.js zombie.js chai