From e8b6b684a4ecf79dfb353bc0d6be216b2fd28d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C5=82awomir=20Jedlikowski?= Date: Mon, 5 Feb 2024 13:55:06 +0100 Subject: [PATCH] chore: running integration tests on a separate database --- .env.test | 11 +++++++++++ docker-compose.yml | 19 +++++++++++++++++++ package.json | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 .env.test diff --git a/.env.test b/.env.test new file mode 100644 index 0000000..e298c34 --- /dev/null +++ b/.env.test @@ -0,0 +1,11 @@ +REDIS_URL=redis://redis:6379/1 +RDS_HOSTNAME=postgres_test +RDS_PORT=5432 +RDS_DB_NAME=app +RDS_USERNAME=postgres +RDS_PASSWORD=password +APP_NAME=express-boilerplate +AUTH_API_KEY=b6cfcd8f-db8e-2cb5-cb34-e1a8900067fd +STAGE=development +BITBUCKET_COMMIT=commit_sha +API_URL=http://localhost:1337 diff --git a/docker-compose.yml b/docker-compose.yml index 69e9eea..8cab255 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,6 +37,16 @@ services: networks: - app + js_test: + image: app:local + env_file: + - .env.test + depends_on: + - postgres_test + - redis + networks: + - app + boilerplate_api: <<: *common working_dir: /app/build @@ -62,6 +72,15 @@ services: networks: - app + postgres_test: + image: postgres:14-alpine + environment: + POSTGRES_PASSWORD: password + POSTGRES_USERNAME: postgres + POSTGRES_DB: app + networks: + - app + redis: container_name: redis image: 'redis' diff --git a/package.json b/package.json index ff91d75..d280cde 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "integration-tests": "cd build && node ../node_modules/.bin/mocha \"src/tests/**/*.spec.js\" --file=\"src/tests/bootstrap.js\" --exit", "services-units": "cd build && node ../node_modules/.bin/mocha \"src/{,!(tests)/**}/*.spec.js\"", "services-units-coverage": "nyc npm run services-units", - "integration": "docker-compose run --rm js npm run integration-tests", + "integration": "docker-compose run --rm js_test npm run integration-tests", "units": "docker-compose run --rm js npm run services-units-coverage", "shell": "docker-compose run --rm js sh", "generate-migration": "docker-compose run --rm js ./node_modules/.bin/typeorm migration:generate ./src/migrations/migration -d ./build/src/config/db",