Warm tip: This article is reproduced from stackoverflow.com, please click
express-graphql mocha node.js prisma prisma-graphql

How to set up a different database for testing in prisma?

发布于 2020-05-08 11:00:41

I want to use a different database for testing my app instead of local database.

this is my env file

# Environment
NODE_ENV=development

# Backend
API_PORT=4000
APP_SECRET=omg
DASHBOARD_URL=http://localhost:1234

# Prisma
PRISMA_ENDPOINT=http://localhost:4466
PRISMA_SECRET=omg
PRISMA_MANAGEMENT_API_SECRET=omg

what I have tried is changing the Prisma endpoint into http://localhost:4466/default/test

but, then how to dynamically change the endpoint? so that when I need to run the app it will point to that http://localhost:4466/default/default and when I need to run test suits it will point to that http://localhost:4466/default/test endpoint.

Questioner
Ashik
Viewed
14
Ashik 2020-02-25 21:42

you can testing against a test stage.

all you need is two different env file. one is for the development environment and one is for testing environment.

  • on .env.dev: http://localhost:4466/default/default
  • on .env.test: http://localhost:4466/default/test

after that, you can run docker separately for development and test environment.