Testing with TestBed: No Provider for StatusBar Error

I read an article about testing Ionic2 projects with TestBed, and I have problems when I try to repeat the example from the article in my environment. When I try to start the tests in Step 3 , I have a "No provider for StatusBar" error.

This may be a stupid question, but can anyone guess why this is happening?

The StatusBar is included (imported) in my app.component.ts file .

import { StatusBar } from '@ionic-native/status-bar';
+6
source share
2 answers

TestBed @NgModule . , , , , .

, , ( , , NgModule), .

TestBed.configureTestingModule({
  ......,
  providers: [
    StatusBar
  ]
})

 TestBed.configureTestingModule({
   imports: [
      ModuleContainingStatusBar
   ]     
})

(, , , StatusBar )

+8

providers @NgModule

+1

Source: https://habr.com/ru/post/1015986/


All Articles