[Unit Test] Error finding provider


#1

Hi guys,

I’m trying to test my code but test shows me this error:

Error: No provider for W!
at injectionError (http://localhost:9876/base/src/test.ts?eee5aa08746e51a55d604253d78d8a13a11752ba:1537:86)
at noProviderError (http://localhost:9876/base/src/test.ts?eee5aa08746e51a55d604253d78d8a13a11752ba:1575:12)
at ReflectiveInjector_.Array.concat.ReflectiveInjector_.throwOrNull (http://localhost:9876/base/src/test.ts?eee5aa08746e51a55d604253d78d8a13a11752ba:3076:19)
at ReflectiveInjector
.Array.concat.ReflectiveInjector_.getByKeyDefault (http://localhost:9876/base/src/test.ts?eee5aa08746e51a55d604253d78d8a13a11752ba:3115:25)
at ReflectiveInjector
.Array.concat.ReflectiveInjector_.getByKey (http://localhost:9876/base/src/test.ts?eee5aa08746e51a55d604253d78d8a13a11752ba:3047:25)
at ReflectiveInjector
.Array.concat.ReflectiveInjector_.get (http://localhost:9876/base/src/test.ts?eee5aa08746e51a55d604253d78d8a13a11752ba:2916:21)
at DynamicTestModuleInjector.get (ng:///DynamicTestModule/module.ngfactory.js:156:131)
at DynamicTestModuleInjector.getInternal (ng:///DynamicTestModule/module.ngfactory.js:234:61)
at DynamicTestModuleInjector.Array.concat.NgModuleInjector.get (http://localhost:9876/base/src/test.ts?eee5aa08746e51a55d604253d78d8a13a11752ba:3862:44)
at resolveDep (http://localhost:9876/base/src/test.ts?eee5aa08746e51a55d604253d78d8a13a11752ba:11257:45)

Seems like I’m lacking some dependency but I can’t figure out which one. BTW why is the code not being mapped?

This is my test bed:


	beforeEach (done => {
		TestBed.configureTestingModule({
			declarations: [ AuthenticationComponent ],
			imports: [ IonicModule, FormsModule ],
			providers: [
				App, DomController, AlertController,
				AuthenticationService,
				{provide: GestureController, useClass: GestureControllerStub},
				{provide: Platform, useClass: PlatformStub},
				{provide: Config, useClass: ConfigStub}
			]
		}).compileComponents().then (done).catch (done.fail);
	});

Perhaps you are wondering why am I not using async, and the answer is: It doesn’t work for me, don’t really know why but using it triggers jasmine.DEFAULT_TIMEOUT_INTERVAL which is manually set to 60000.

Hope you guys can help me, I don’t like to ask too much but find out the answers by my self. This way of doing things is making me to lost too much time.