Jest is a pretty common part of modern app stack. importing wretch middleware in the (non spec) code fails when running the suite:
Cannot find module 'wretch/middlewares' from...
in my case it fails on retry middleware specifically. similar problems have been reported in #144 and #150.
I spent quite some time finding a relatively clean solution and thought to share a simple one that has worked best for me so far:
- create a mock module in
<root>/__mocks/wretch/middlewares.ts
- ...with file content:
module.exports = {
retry: jest.fn(),
};
(or as needed).
ultimately this issue seems to be related to experimental nature of Jest ESM imports which I do not even have enabled. or perhaps there is something that wretch can do on the export side?
if nothing else I hope the above mocks fix might help someone else.
Jest is a pretty common part of modern app stack. importing wretch middleware in the (non spec) code fails when running the suite:
in my case it fails on
retrymiddleware specifically. similar problems have been reported in #144 and #150.I spent quite some time finding a relatively clean solution and thought to share a simple one that has worked best for me so far:
<root>/__mocks/wretch/middlewares.ts(or as needed).
ultimately this issue seems to be related to experimental nature of Jest ESM imports which I do not even have enabled. or perhaps there is something that wretch can do on the export side?
if nothing else I hope the above mocks fix might help someone else.