I found this article how to create an artificial server delay when using $httpBackend for mocking data.
Is there any way at all to have this on a per-mock basis? Perhaps something like:
$httpBackend
.whenGET(/\/my\/endpoint$/)
.respond(data, 2000);
OR
$httpBackend
.whenGET(/\/my\/endpoint$/)
.withDelay(2000)
.respond(data);
You can use angular-mocke2e-maydelay
if you use
bowerin index.html
Add this to your app
In the tests the unmocked
$httpBackendcan be used as below to delay the response.This feature request is already posted in the angularjs repo