'npm test fail after adding a new library module

I installed https://www.npmjs.com/package/ngx-export-as library and add its module to root component of one of the module in my app.

import { ExportAsModule } from 'ngx-export-as';

@NgModule({
  declarations: [
  AppComponent
],
imports: [
  BrowserModule,
  ExportAsModule
],
providers: [],
})

Then I used it in one of child component and also added library module in .spec.ts file of child component as follow:

import { ExportAsModule } from 'ngx-export-as';
beforeEach(async () => {
await TestBed.configureTestingModule({
  declarations: [SubjectsDetailsComponent],
  imports: [
    TranslateModule.forRoot(),
    StoreRootModuleIndex,
    ExportAsModule,
  
  ],
  schemas: [
    CUSTOM_ELEMENTS_SCHEMA,
    NO_ERRORS_SCHEMA,
  ],
}).compileComponents();

});

But when I run npm test It gives me an error in child component .spec.ts file that: Cannot find module 'ngx-export-as' from 'src/app/shell/subjects/components/subject-details/components/subject-details.component.spec.ts' on a line given below

import { ExportAsModule } from 'ngx-export-as';
     


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source