Ive just upgraded Angular2 from RC3 to RC4 ...
import {
expect, it, iit, xit,
describe, ddescribe, xdescribe,
beforeEach, beforeEachProviders, withProv
You will need to import addProviders from @angular/core/testing.
Instead of:
beforeEachProviders(() => [
{provide: Router, useClass: MockRouter}
]);
You'll want to do this:
beforeEach(() => {
addProviders([
{provide: Router, useClass: MockRouter}
])
});
Source: RC4 Changelog
After reviewing a few other documents, it appears you want:
beforeEach(() => TestBed.configureTestingModule({
providers: [
{ provide: Service, useClass: MockService }
]})
);
Source: https://angular.io/guide/dependency-injection
Here's a complete example, for a Window reference service:
import { TestBed, inject } from '@angular/core/testing';
import { WindowRef } from './window-ref';
describe('WindowRef', () => {
let subject: WindowRef;
beforeEach(() => {
TestBed.configureTestingModule({
providers: [
WindowRef
]});
});
beforeEach(inject([WindowRef], (windowRef: WindowRef) => {
subject = windowRef;
}));
it('should provide a way to access the native window object', () => {
expect(subject.nativeWindow).toBe(window);
});
});