#ESM and writing test using Jest
6 messages · Page 1 of 1 (latest)
@chilly locust It helps if you describe the problem you're running into rather than asking "has anyone ever done it"
Yeah, sorry, that just drives me crazy... For now, I've managed to fix some errors, but the one I face now is that on my test file, I import a lib but Jest cannot find it. It return me this:
src/infrastructure/repository/code.spec.ts:4:22 - error TS2307: Cannot find module 'postgrejs' or its corresponding type declarations.
4 import { Pool } from 'postgrejs';
That's a type-script error saying it can't find types... but it looks like types are built-into that module, so either 1) the module isn't installed, or 2) there's something weird in whatever tsconfig you're using for jest.
@chilly locust Can I ask how you could manage to test TypeScript ESMs with Jest? as I understand you should change a lot for example hack the default resolver for Jest. Could I have your configration files for jest.config and tsconfig? 🙏
@jolly zinc It's probably better to open your own help channel with details of your problem rather than asking in related help channels