I have the following in a jasmine test for angular...
beforeEach(module('app'));
beforeEach(module('app.services'));
beforeEach(module(function ($provide, Config) {
reservationCallerJquery = {
reserveBooking: function (reservationRequestDto, reserveBookingSuccess) {
doJqueryPost(reservationRequestDto.item,
"I need a value from my config class",
reserveBookingSuccess);
}
$provide.value("ReservationCaller", reservationCallerJquery);
}));
But I get the error:
Error: [$injector:modulerr] Failed to instantiate module function ($provide,Config) due to: Error: [$injector:unpr] Unknown provider: Config
So how do I set that string of my stub to something from config? (The Config lives in the 'app.services')...I think I need to get it from there but how?
You'r missing inject, you can inject service, constant, controller etc.. in one of two ways :
In the inject callback you can retrieve $injector and then get what you want.
or
Get the service directly, you can add _ServiceName_ that will be resolve as ServiceName but allow you to use the ServiceName var in your test :
My typical test setup is :