karma + jasmine + angular + http GET's on every test

17 views
Skip to first unread message

0101...@gmail.com

unread,
Mar 9, 2016, 11:54:50 AM3/9/16
to karma-users

As part of the apps bootstrap, it runs through a series of HTTP GET's to load assets.

My unit tests will throw "unexpected GET request" if i don't account for the fetch. The issue is I have to include the GET on every test. And there are about a dozen of the below.

$httpBackend.when('GET', 'assets/iconsets/action-icons.svg').respond('ok');

My question is; is there a better, global way, to account for the GET's in one place and include that call in all of my tests?

Samuel Van Reeth

unread,
Mar 9, 2016, 6:39:28 PM3/9/16
to karma-users, 0101...@gmail.com
You can use a regular expression for the second argument of the 'when' method to match all your assets.
$httpBackend.when('GET', /assets/).respond('ok');


Op woensdag 9 maart 2016 17:54:50 UTC+1 schreef 0101...@gmail.com:
Reply all
Reply to author
Forward
0 new messages