我想避免在Jasmine中的每个测试之前运行ajax调用。 相反,我想使用单个ajax调用的数据进行所有测试,有没有办法做到这一点?
目前我正在使用beforeEach,如下所示:
beforeEach(function(done) {
$.ajax({
url: '/vulnerability/data',
success: function (response) {
done();
},
dataType: 'html'
});
});
it("test 1", function() {
// ajax is called for the 1st time
// this won't run until the done callback is invoked from the beforeEach
});
it("test 2", function() {
// ajax is called for the 2nd time
// this won't run until the done callback is invoked from the beforeEach
});
it("test N", function() {
// ajax is called for the Nth time
// this won't run until the done callback is invoked from the beforeEach
});