'"Cannot use import statement outside a module" in global setup with mixture of JS & TS files
I'm converting a test suite for a Node.js backend from Mocha to Jest. The codebase is a mostly converted set of TS files, with some few yet notable exceptions. Our bootstrapping code, as the global setup file, imports (via require) some JS files, which in turn require some TS files that then import other things.
I've got the jest.config.ts set to use ts-jest, and it works fine elsewhere, but does the nature of tunneling from a TS entry-point, into JS files, then back into TS files that need/want to use import, make for an edge case beyond what Jest and ts-jest together can handle? I'm making sure I'm using ts-jest as the preset here, and I've added and removed transform to make sure ts-jest gets run against both TS and JS files, but still no luck.
I'd try to give you the actual code sample, but it's so convoluted and riddled with needs-to-be-concealed proprietary stuff that it's easier to develop a reductive example. (I'm doing this now, in the event that there is a bug with Jest itself or ts-jest — in that scenario, I can just drop the repo on GH and put it in an issue on the repo for the offending project.)
Any ideas?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
