Hi! I'm trying to setup Jest tests but I have a pr...
# orm-help
e
Hi! I'm trying to setup Jest tests but I have a problem with connection to DB. I get an error:
Copy code
error: Environment variable not found: DATABASE_URL.
despite the fact I have it in my
prisma-test-environment.js
(like in the examples directory). Can somebody help me with that?
1
r
Hey @Eden Lane 👋 Does the variables name exactly match the one you have specified in your
schema.prisma
?
e
yes, they are equal
r
Could you run
prisma generate
and try again? If even that doesn’t work, then I would need to check the code so that I can help you out.
e
I'm not sure it will work because I have a different DB for my tests
one thing that I know - it works for my
db push
command
r
I’m not sure it will work because I have a different DB for my tests
That’s fine as long as it’s Postgres.
one thing that I know - it works for my 
db push
 command
So it works from the CLI but not from the test file?
e
yeah, test file doesn't see the variable
I had to put the variable in
setupJest.ts
file. It works this way, but it's not ideal of course..
r
Let me check by trying it in the example.
e
Sure. Thanks for helping me
r
Although you could try this setup that I have already in place for Postgres which works fine and let me know if this works 🙂
e
it seems like
Copy code
this.global.process.env.DATABASE_URL =
did the trick!
💯 1
thank you a lot!
🙌 1