Javascript AngularJS$http测试

Javascript AngularJS$http测试,javascript,angularjs,angularjs-http,Javascript,Angularjs,Angularjs Http,是否可以在不进行模拟的情况下使用$http?拨打电话的服务: // Make the request we are interested in testing ViewingRepositoryService.getThumbnail(obj, "urn:adsk.wipdata:versionedFile:BQLHHmlCRd-bqnr8rxF2xA?version=1", "medium") .then(function (data) { // On success (this is

是否可以在不进行模拟的情况下使用$http?拨打电话的服务:

// Make the request we are interested in testing
ViewingRepositoryService.getThumbnail(obj, "urn:adsk.wipdata:versionedFile:BQLHHmlCRd-bqnr8rxF2xA?version=1", "medium")
    .then(function (data) { // On success (this is what we are expecting)
        console.log('success');
        expect(data).to.deep.equal(mockData); //Validate the data is correct
        done();
    },
    function (err) {
        console.log('error');
        done();
    }
);

未显示“成功”或“错误”。

您可以查看此帖子:


您需要在测试文件中包含angular-mocks-with-real-backend.js,然后像往常一样使用$http。

只看到这一点,就什么也说不出来了。在这里发布您的详细代码。什么是ViewingRepositoryService?我觉得你的服务功能看起来很奇怪。我也不太喜欢服务,但这可能会有所帮助。你可以用Wireshark查看网络传输,你能解决你的问题吗?