Skip to content

Starting the DB

Course: Integration and End to End testing - chapter 4

Until now, we’ve used one of the following ways to start a DB

  1. Start one on https://neon.tech/ / aieven
  2. Start it locally using docker
docker run -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres

Let’s use the second one to start a database and then hit our backend

  • Make sure docker is running
  • Start a DB locally
docker run -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgres
  • Update .env
DATABASE_URL="postgresql://postgres:mysecretpassword@localhost:5432/postgres"
  • Migrate the DB
npx prisma migrate dev
  • Generate the client
npx prisma generate
  • Send a request from POSTMAN

  • Check the DB and ensure data is going in

npx prisma studio

What we did right now is a manual integration test

We now need to automate this thing and do the same programatically

Let’s take down the database for now -

docker ps
docker kill container_id