I am updating my unit tests for Angular2 RC5. changelog notes the following violation:
addProviders [deprecated], use TestBed.configureTestingModule instead
But this seems to only accept an error when trying to include a service in a test. Where my unit test used the following:
beforeEach(() => addProviders([ MyService, MockBackend, ... ]));
Now it should configure the test module:
TestBed.configureTestingModule({ providers: [ StoryService, MockBackend, ... ] });
But this now causes an error
Service: MyService encountered FAILED notification exception
Error: Cannot configure the test module when the test module is already created. Make sure you do not use inject until TestBed.configureTestingModule .
I checked that inject not called before configureTestingModule . This does not affect other component / directive tests, they seem to pass fine. How can I resolve this error for unit testing a service using RC5? I understand that I may have to wait until the test documentation is updated for RC5, but any understanding of the possible solutions would be highly appreciated.
source share