# This file is for running CI tests locally, mirroring .gitea/workflows/ci.yml services: # This is the test database, mirroring the 'services' block in the CI job. merchantsofhope-supplyanddemandportal-test-database: image: postgres:15-alpine hostname: test-database environment: POSTGRES_DB: merchantsofhope_test POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres ports: - "55432:5432" # Add a healthcheck to ensure the database is ready before tests run healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 10s timeout: 5s retries: 5 networks: merchantsofhope-supplyanddemandportal-network: aliases: - test-database backend-lint: build: context: ./backend dockerfile: Dockerfile target: dev entrypoint: ["npm", "run", "lint"] environment: NODE_ENV: test networks: - merchantsofhope-supplyanddemandportal-network # This service runs the backend test suite. backend-tester: build: context: ./backend dockerfile: Dockerfile target: dev command: > sh -c "npm run migrate && npm test -- --runInBand --coverage" environment: NODE_ENV: test DATABASE_URL: postgresql://postgres:postgres@merchantsofhope-supplyanddemandportal-test-database:5432/merchantsofhope_test JWT_SECRET: merchantsofhope_test_secret USE_DOCKER_TEST_DB: "false" SKIP_DB_WAIT: "true" RUN_MIGRATIONS: "false" POSTGRES_DB: merchantsofhope_test POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_HOST: merchantsofhope-supplyanddemandportal-test-database POSTGRES_PORT: "5432" DB_WAIT_TIMEOUT_MS: "180000" depends_on: merchantsofhope-supplyanddemandportal-test-database: condition: service_healthy networks: - merchantsofhope-supplyanddemandportal-network frontend-lint: build: context: ./frontend dockerfile: Dockerfile target: dev command: npm run lint environment: NODE_ENV: test networks: - merchantsofhope-supplyanddemandportal-network # This service runs the frontend test suite. frontend-tester: build: context: ./frontend dockerfile: Dockerfile target: dev command: npm test -- --watchAll=false --coverage environment: NODE_ENV: test networks: - merchantsofhope-supplyanddemandportal-network networks: merchantsofhope-supplyanddemandportal-network: driver: bridge