rbatsenko
rbatsenko
TTCTheo's Typesafe Cult
Created by rbatsenko on 4/12/2023 in #questions
Environment variables validation not working with Jest (env.mjs)
Hi, did anyone else have problems with env.mjs in tests (I use env.SOME_VAR in my components)? I get this error:
.../env.mjs:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import { z } from "zod";

SyntaxError: Cannot use import statement outside a module
.../env.mjs:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import { z } from "zod";

SyntaxError: Cannot use import statement outside a module
It's fixable by using babel.config.js, but I don't want to use babel (I have NX monorepo)... 🫣
4 replies