Here I attached my spec files.
actionService.spec.ts
import { TestBed } from '@angular/core/testing';
import { NgxSmartModalService } from 'ngx-smart-modal';
import { ActionService } from './action.service';
describe('ActionService', () => {
    let service: ActionService;
    beforeEach(() => {    
    TestBed.configureTestingModule({
        providers: [NgxSmartModalService]
    });
    service = TestBed.inject(ActionService);
    });
    it('should be created', () => {
    expect(service).toBeTruthy();
    });
});
MultiNumberComponent.spec.ts
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ActionService } from '../services/action/action.service';
import { MultiNumberComponent } from './multi-number.component';
import { MatDialogModule } from '@angular/material/dialog';
import { HttpTestingController, HttpClientTestingModule } from '@angular/common/http/testing';
import { HttpClient } from 'selenium-webdriver/http';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { CircleProgressComponent } from './../circle-progress/circle-progress.component';
import { PieChartComponent } from './../pie-chart/pie-chart.component';
    
describe('MultiNumberComponent', () => {
    let component: MultiNumberComponent;
    let fixture: ComponentFixture<MultiNumberComponent>;
    beforeEach(async(() => {
    TestBed.configureTestingModule({
        imports: [MatDialogModule, HttpClientTestingModule],
        declarations: [ MultiNumberComponent, PieChartComponent, CircleProgressComponent],
        providers: [ ActionService ],
        schemas: [NO_ERRORS_SCHEMA]
    }).compileComponents().then( result => {
    fixture = TestBed.createComponent(MultiNumberComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
    })
    }));
    
    it('should create', () => {
    expect(component).toBeTruthy();
    });
    
});
When I do the "npm run test" I'm getting the following error.
1 SPEC, 1 FAILURE, RANDOMIZED WITH SEED 66295SPEC LIST | FAILURES MULTINUMBERCOMPONENT > SHOULD CREATE FAILED: UNCAUGHT (IN PROMISE): NULLINJECTORERROR: R3INJECTORERROR(DYNAMICTESTMODULE)[ACTIONSERVICE -> NGXSMARTMODALSERVICE -> NGXSMARTMODALSERVICE]: NULLINJECTORERROR: NO PROVIDER FOR NGXSMARTMODALSERVICE!
can anyone help to fix this error?
Try adding NgxSmartModalModule in the imports of your spec file like:
imports: [MatDialogModule, HttpClientTestingModule, NgxSmartModalModule]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With