Javascript jasmine测试用例与角js

Javascript jasmine测试用例与角js,javascript,angularjs,jasmine,Javascript,Angularjs,Jasmine,我正在尝试测试rest服务,比如“/service/home/autolaunch?rnd=” 查询参数“rnd”值始终是唯一的,以消除internet explorer缓存问题。 在为上述后端服务编写jasmine测试用例时,我得到了错误“意外请求”,因为每次查询参数都不同。在编写jasmine测试时是否有跳过查询参数的方法 服务电话是这样的- http.get('/service/home/autolaunch', {params:{rnd:new Date().getTime()}}).t

我正在尝试测试rest服务,比如“/service/home/autolaunch?rnd=” 查询参数“rnd”值始终是唯一的,以消除internet explorer缓存问题。 在为上述后端服务编写jasmine测试用例时,我得到了错误“意外请求”,因为每次查询参数都不同。在编写jasmine测试时是否有跳过查询参数的方法

服务电话是这样的-

http.get('/service/home/autolaunch', {params:{rnd:new Date().getTime()}}).then(
          function(data){
          // TO do
});
Jasmine测试用例是-

httpBackend.when('GET','/service/home/autolaunch').respond(-- to do);
即使按照以下方式定义测试用例-

httpBackend.when('GET','/service/home/autolaunch?rnd=' + new Date().getTime()).respond(-- to do);
仍收到意外请求

调试完成后,您知道时间戳值不同。

您可以在
$httpBackend.expectGet()方法中使用正则表达式:

var regex = new RegExp('/service/home/autolaunch\\?rnd=.*');
httpBackend.expectGET(regex).respond(...);

谢谢你,丹尼斯。能够成功执行测试。@prad121很高兴我能提供帮助。如果这个答案有帮助,请“接受”。