#Multiple .env files solution with Prisma

5 messages · Page 1 of 1 (latest)

dusty olive
#

Currently i am having one project which i have to test and it is using prisma orm, and i have to automate e2e test where it will load env file based on NODE_ENV
So how can i achieve this?

I have check all possibilities and could not find any solution.
Thanks

tawny crag
#
"test:e2e": "pnpm run test:setup && dotenv -e .env.test -- jest --config ./test/jest-e2e.json && pnpm run test:cleanup",

that's the way I do it, I use dotenv to load .env.test which has a DATABASE_URL that points to a different port than the one of .env.local I use in dev

test:setup runs a postgres database with docker compose

#
"test:setup": "docker compose up test-database --wait && dotenv -e .env.test -- prisma migrate deploy && prisma generate",
#

there's test:setup for info

#

runs fine in a pre-commit hook, and in my CI