这是我在做什么
我的测试脚本
requirejs(['jquery', 'application'], function($, app){
describe('View Products List', function(){
// All test in this test suite fails
it('Products list should be present', function(done) {
$('.productlist').length.should.equal(1);
return done();
});
it('product list should be have a checkbox for product selection', function(done) {
$('.productlist td:first input[type=checkbox]').length.should.equal(1);
return done();
});
it('product name should be anchor which could be clickable', function(done) {
$('.productlist td:first a').length.should.equal(1);
return done();enter code here
});
it('Should show product details on click of product name', function(done) {
$('.productlist td:first a').click();
$('.editproduct').length.should.equal(1);
return done();
});
});
});
骨干视图
var Products = new Backbone.View.extend({
tagName : 'div'
template : productsTemplate
render: function() {
$(this.el).html(this.template());
}
initialize: function() {
// some code
}
});
描述
当我运行我的测试脚本并加载 url #products 时,产品视图将呈现到 html 正文。我希望测试用例检查视图生成的 DOM 元素。似乎测试首先运行,即在视图呈现 dom 元素之前,因此它失败了。我们如何确保在我的测试运行之前视图已经完全呈现?