1

currently I am running on Angular 9 ,while I am testing My Component using Jest, I am getting an error like "Can not find module 'ngx-store' from service.ts" and the code showing me which is wrong in service file (cartService).

import {SessionStorageService} from 'ngx-store-9'

there are some services injected into component's constructor . for that I am writing the code into test component.

beforeEach(()=>{imports:[WebStorageModule],providers:[{provide:cartService,useClass:mockcartService}] } What is wrong here.

skyboyer
  • 22,209
  • 7
  • 57
  • 64
PSINGH
  • 11
  • 1
  • Do you import the `WebStorageModule` in your `app.module` (or some other appropriate level). Did you install `ngx-store` correctly? – Gunnar B. Jul 31 '20 at 17:52
  • @Gunnar B ,yes I have imported WebStorageModule into main app.module . I got this error while running my test cases only and dependency I am using ngx-store-9 but the error it's saying ngx-store. – PSINGH Jul 31 '20 at 17:57
  • Is this the only import that throws an error (if you have more than that)? Maybe this can help https://stackoverflow.com/questions/50171412/jest-typescript-absolute-paths-baseurl-gives-error-cannot-find-module – Gunnar B. Jul 31 '20 at 18:01
  • only this import's error throwing for this test suite..rest of test suites are working fine..Can we mock SessionStorageService and WebStorageModule ? – PSINGH Jul 31 '20 at 18:51

0 Answers0