Ive just upgraded Angular2 from RC3 to RC4 ...
import {
expect, it, iit, xit,
describe, ddescribe, xdescribe,
beforeEach, beforeEachProviders, withProviders,
async, inject
} from '@angular/core/testing';
In my unit test I have the following code ...
beforeEachProviders(() => [
{provide: Router, useClass: MockRouter}
]);
This works fine but since moving to RC4 I have a deprecation warning on beforeEachProviders
.
Anyone know what the new way of doing things is? Or should I import beforeEachProviders
from somewhere else instead of '@angular/core/testing'?
After reviewing a few other documents, it appears you want:
Source: https://angular.io/guide/dependency-injection
You will need to import addProviders from @angular/core/testing.
Instead of:
You'll want to do this:
Source: RC4 Changelog
Here's a complete example, for a Window reference service: