DEV Community

Cover image for Integration Testing : Concept
Jayant
Jayant

Posted on

Integration Testing : Concept

Integration Testing

What

In Integration Testing we test how all the components work together, means unlike unit tests we don't have to mock out the services. We actually start all the services in the integration test and see how they work together.

Downside to this is that it is slower, as we have to start all the auxiliary services.

Here is a gist of what we have to do in the Integration Testing

Testing

How

To do the integration test we will use scripts and docker compose file.

  • docker-compose.yml file - It will start all the services
  • script file - It will run docker compose file, wait for our DB , migrate the DB , Do the Intial Seeding and run all the tests.

run-integration.sh

docker-compose up -d
echo '🟑 - Waiting for database to be ready...'
# The below command will wait for the DB after that all the command run.
./wait-for-it.sh "postgresql://postgres:mysecretpassword@localhost:5432/postgres" -- echo '🟒 - Database is ready!'
npx prisma migrate dev --name init
npm run test
docker-compose down

# To run this file simply do `run-integration.sh` + you need to install wait-for-it.sh from github.
# curl https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -o scripts/wait-for-it.sh
Enter fullscreen mode Exit fullscreen mode

For All the Steps Visit - 100xdevs Integration Testing

Thanks

Top comments (0)