出于某种原因,我似乎无法让 vows.js 子主题在我的真实测试套件中工作,但它们在示例文件中工作正常......你能发现我的问题吗?
这有效:
vows.describe('An Education in Vows').addBatch({
'when I write an asynchronous topic': {
topic: function() {
var that = this;
setTimeout(function() {
that.callback(true);
}, 100);
},
'it passes': function (topic) {
assert.equal(topic, true);
},
'and it has an asynchronous sub-topic': {
topic: function() {
var that = this;
setTimeout(function() {
that.callback(true);
}, 100);
},
'it also passes': function (topic) {
assert.equal(topic, true);
}
}
}
}).run();
当我通过以下方式运行时:
node tests/learning-vows.js
我得到:
·
·
✓ OK » 2 honored (0.207s)
这不起作用:
我有一个文件 ./tests/smoke.js
vows.describe('Registration & Authentication').addBatch({
'when a user registers with a valid username and password': {
topic: function () {
client.register({
username: validusername,
password: validpassword
}, this.callback);
},
'we return status 200 OK': function (data, response) {
assert.equal(200, response.statusCode);
},
'simple sub-topic': {
topic: true,
'should work': function(topic) {
assert.equal(true, topic);
}
},
}
}).run()
当我通过以下方式执行此操作时:
node tests/smoke.js
我得到:
·
✗ Errored » 1 honored ∙ 1 errored
请注意,在第二个示例中,没有我得到的子主题:
·
✓ OK » 1 honored (0.100s)