Getting ts-jest to work with testing files that use the .env mjs files
I'm trying to write a unit test to verify some code. This code uses the t3
env
variable which is setup in these .mjs
files. When I run jest it keeps failing to import from "./schema.mjs"
. Does anyone have an example repo which has test working fine in this scenario?6 Replies
+1 I'd like to know the answer to this too
i hit this as well
use vitest
jest has cursed cjs/esm stuff
always will most likely
+1, does anybody have any idea on how to fix this? 😢
This is disgusting but what I do is I just make a copy of the .mjs file with .ts instead - I copy the changes in both places and it works https://github.com/AnswerOverflow/AnswerOverflow/tree/main/packages/env
GitHub
AnswerOverflow/packages/env at main · AnswerOverflow/AnswerOverflow
Indexing Discord Help Channel Questions into Google - AnswerOverflow/AnswerOverflow
Then when whenever I’m working in doesn’t support .mjs I use the .ts import and vise versa - once I move to bun I think I’ll be able to stop doing that
cc @beto since I realize you’re the one who bumped this thread