Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test suite failed to run Cannot find module or its corresponding type declarations

I get the following error every time I try to run test.


  ● Test suite failed to run

    src/repositories/list_contacts/ListContactRepository.test.ts:4:37 - error TS2307: Cannot find module './ListContactRepository' or its corresponding type declarations.

    4 import {ListContactRepository} from './ListContactRepository';
                                          ~~~~~~~~~~~~~~~~~~~~~~~~~

Earlier everything worked fine but this happened after I rename
src/repositories/quick_contacts/QuickListContactRepository.test.ts to

src/repositories/list_contacts/ListContactRepository.test.ts

And run git checkout -b list. After some changes I committed there and come back to previous branch by git checkout dev now I face this error whenever I try to run test.

This file src/repositories/list_contacts/ListContactRepository.test.ts doesn't even exist on my current branch. But jest keep complaining. Any suggestion to solve this will be appreciated.

like image 776
Nux Avatar asked Jan 01 '26 01:01

Nux


1 Answers

In my case I solved the problem by modifying the import path :

import { MyService } from "src/app/mymodule/services/myservice.service";

to

import { MyService } from "../../../mymodule/services/myservice.service";

like image 89
shenoy Avatar answered Jan 06 '26 11:01

shenoy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!