【发布时间】:2014-04-29 16:43:03
【问题描述】:
我正在尝试编写一个集成测试,它调用我的真实服务(返回 JSON)并确保 JSON 的格式正常。
我收到一个错误
Error: Unable to load http://localhost:7200/users/signoff status: 0
ErrorCtor@http://localhost:9000/resources/www/tests/lib/dojo/errors/create.js:29
onError@http://localhost:9000/resources/www/tests/lib/dojo/request/xhr.js:133
我有一个服务,它具有与服务器交互的实际功能,它从每个功能返回承诺。我的测试是这样的。
define([
'intern!bdd',
'intern/chai!expect',
'app/services/myService'
], function (bdd, expect, MyService) {
with (bdd) {
describe('Service Tests', function () {
var service;
before(function () {
service = MyService.getInstance();
});
it('should sign user off', function(){
var dfd = this.async(2000);
service.signUserOff().then(dfd.callback(function (data) {
expect(data).to.exist;
expect(data.status).to.exist;
}), dfd.reject.bind(dfd));
});
});
}
});
service.signOff() 调用真正的服务,然后返回一个承诺。我已经用 Firefox 和 PhantomJS 都试过了,但我一直收到这个错误。奇怪的是,如果在浏览器中手动加载,错误中的 URL 可以正常工作。
我想知道这是否与 Intern 无法加载 request/xhr.js 并因此引发此错误有关?
【问题讨论】:
标签: asynchronous dojo functional-testing intern