envalid
envalid copied to clipboard
cleanEnv error not logged properly with Jest in Github Actions
When I try to run tests with jest, I see the following error in my test suite. It works locally with the same env vars for some reason.
I don't have a way to see what the error is. Is there maybe a more basic logger that I can use out of the box in tests?
> jest --config src/test/unit/jest.config.ts --ci --forceExit
● process.exit called with "1"
6 | dotenv.config({ path: dotEnvPath });
7 |
> 8 | export const env = cleanEnv(process.env, {
| ^
9 | ENV_1: num(),
10 | ENV_2: bool({ default: false }),
11 | ENV_3: str(),
at defaultReporter (node_modules/envalid/src/reporter.ts:81:13)
at getSanitizedEnv (node_modules/envalid/src/core.ts:104:3)
at cleanEnv (node_modules/envalid/src/envalid.ts:18:34)
at Object.<anonymous> (src/utils/env.ts:8:[28](https://github.com/org/repo/actions/runs/14227168459/job/39869333489?pr=223#step:13:29))
I haven't seen this before. Which jest version are you using?
Also FWIW this call happens in defaultReporter. You can create and pass in a different reporter if you need different behavior that doesn't call process.exit(1) in your testing step