After creating component using IONIC 4 getting following issue -
Failed: Invalid provider for the NgModule ‘DynamicTestModule’ - only instances of Provider and Type are allowed, got: [?[object Object]?, …]
import { async, ComponentFixture, TestBed } from ‘@angular/core/testing’;
import { IonicModule, NavController, Events } from ‘@ionic/angular’;
import { ProductListPage } from ‘./product-list.page’;
import { StorageMock, NavControllerMock } from ‘ionic-mocks’;
import { ProjectsService } from ‘…/provider/projects.service’;
import { ChangeDetectorRef, CUSTOM_ELEMENTS_SCHEMA,NO_ERRORS_SCHEMA } from ‘@angular/core’;
import { CustomFunctionService } from ‘…/provider/custom-function.service’;
import { SharedService } from ‘…/provider/shared.service’;
describe(‘ProductListPage’, () => {
let component: ProductListPage;
let fixture: ComponentFixture;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ProductListPage ],
imports: [IonicModule.forRoot()],
providers: [
{ provider: ProjectsService, useValue: ProjectsService },
{ provider: CustomFunctionService, useValue: CustomFunctionService },
{ provider: SharedService, useValue: SharedService },
ChangeDetectorRef,
CustomFunctionService,
SharedService,
Events,
{ provider: NavController, useValue: NavControllerMock },
],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
}).compileComponents();
fixture = TestBed.createComponent(ProductListPage);
component = fixture.componentInstance;
fixture.detectChanges();
}));
it(‘should create’, () => {
expect(component).toBeTruthy();
});
});