Angularjs 如何使用Angular和Jasmine+编写行为/功能/终点测试$资源?
我想编写服务器端点的功能测试。我不是在做e2e测试。这更像是一种功能/行为测试Angularjs 如何使用Angular和Jasmine+编写行为/功能/终点测试$资源?,angularjs,unit-testing,jasmine,functional-testing,angular-mock,Angularjs,Unit Testing,Jasmine,Functional Testing,Angular Mock,我想编写服务器端点的功能测试。我不是在做e2e测试。这更像是一种功能/行为测试 beforeEach(inject(function ($injector) { f = $injector.get('WidgetFactory'); })); it('should have a factory and get all widgets',inject(function($timeout ){ expect(f).toBeDefined();
beforeEach(inject(function ($injector) {
f = $injector.get('WidgetFactory');
}));
it('should have a factory and get all widgets',inject(function($timeout ){
expect(f).toBeDefined();
expect(f).toBeTruthy();
var qArray = f.query();
$timeout.flush()
expect(qArray.length).toBe(3);
}));
但是,jasmine会产生以下错误:
unexpected request: GET http://some.made.up.service:8080/widget/
No more request expected
我不想用httpBackend.whenGET()
来模拟它,我想实际测试我的端点是否有不想要的行为(也就是指责后端团队)。模拟响应的单元测试是一个单独的规范文件
用茉莉花怎么做?我不想再添加量角器或摩卡。所以我猜您正在寻找api端点测试框架。飞盘()很适合这样。它基于nodejs和jasmine来测试端点