Jest Test always get error: Unable to load the module "ts-patch/compiler"

I am following the official doc of Jest testing

but after run npm run test
always get error:

 FAIL  src/rpc-add-item.test.ts
  ● Test suite failed to run

    Unable to load the module "ts-patch/compiler". Using "ts-jest" requires this package to be installed. To fix it:
        ↳ install "ts-patch/compiler": `npm i -D ts-patch/compiler` (or `yarn add --dev ts-patch/compiler`)

I try to install npm i -D ts-patch/compiler but it is not exist. After do some research fo ts-patch, seem like this ts-patch/compiler is the live compiler of ts-patch.

Meanwhile, cannot find any example with jest test in github, could anyone help?

Btw, i am using the ts-patch 2.1.0 as the 3.x need TS > 5.

@ftkg i see this thread which you help to resolve, could you help to have a look? ERROR node-builder RUN npx tsc on attemt to setup Jest - #8 by georgeneversleep

any help? @novabyte

That is likely the cause you are facing errors, can you update to TS 5 and the latest ts-patch?

we tried, but it got lots of compile error even for the demo script. I think all the demo code i found is use the TS < 5.

Finally, make it work.

@mengxin if you can, please provide the steps you had to take as it can be helpful for the community :slight_smile:.

seems like it relates to the jest config and typescript version.
i move the jest config from the package to an independent config file

I create a ts template repo

hope it can help anyone who wants to use it. the official server template repo the ts part seem like not work.

1 Like