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
- Start one on https://neon.tech/ / aieven
- Start it locally using docker
docker run -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword -d postgresLet’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 studioWhat 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 psdocker kill container_id