Below is a snippet of the code from my test:
import {
beforeEach, beforeEachProviders,
describe, xdescribe,
expect, it, xit,
async, inject
} from '@angular/core/testing';
import { UserService } from './user.service';
import { Http, ConnectionBackend, Response, Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { LocalStorage, SessionStorage, WEB_STORAGE_PROVIDERS } from 'h5webstorage';
beforeEachProviders(() => [
UserService, Http, Response, Observable, ConnectionBackend, LocalStorage, Headers, RequestOptions
]);
describe('Service: UserService', () => {
it('testtest', inject([UserService], (service) => {
expect('test').toEqual('test');
}));
});
Upon running this code, an error message appears:
Error: Cannot resolve all parameters for 'Response'(?). Make sure that all the parameters are decorated with Inject or have valid type annotations and that 'Response' is decorated with Injectable.
Could this be due to improper dependency injection in the test? What is the correct way to handle dependency injection in a Jasmine test?