diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dcfcac157..f08ac9c36 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,7 +30,7 @@ jobs: npm ci npm run lint - unit-tests: + unit-and-integration-tests: runs-on: ubuntu-latest steps: - name: Checkout code @@ -39,29 +39,14 @@ jobs: uses: actions/setup-node@v4 with: node-version: ${{env.NODE_VERSION}} - - name: Install dependencies - working-directory: ./query-connector - run: npm install - - name: Run tests - working-directory: ./query-connector - run: npm run test:unit - - integration-tests: - runs-on: ubuntu-latest - steps: - name: Checkout code - uses: actions/checkout@v4 - - name: Set up Node.js - uses: actions/setup-node@v4 + uses: actions/checkout@v3 + - name: Setup reporting action and run tests + uses: ArtiomTr/jest-coverage-report-action@v2 with: - node-version: ${{env.NODE_VERSION}} - - name: Install dependencies - working-directory: ./query-connector - run: npm install - - - name: Run tests - working-directory: ./query-connector - run: npm run test:integration + test-script: npm run test:ci + working-directory: ./query-connector + skip-step: none end-to-end-tests: timeout-minutes: 15 diff --git a/query-connector/.gitignore b/query-connector/.gitignore index f0d2f23c8..1baad9077 100644 --- a/query-connector/.gitignore +++ b/query-connector/.gitignore @@ -6,3 +6,5 @@ certificates /playwright-report/ /blob-report/ /playwright/.cache/ +/coverage +report.json diff --git a/query-connector/integration.sh b/query-connector/integration.sh index 24f93a105..940d65460 100644 --- a/query-connector/integration.sh +++ b/query-connector/integration.sh @@ -1,14 +1,20 @@ #!/bin/bash set -e # Exit immediately if a command exits with a non-zero status - +docker compose down --volumes --remove-orphans docker compose -f docker-compose-integration.yaml up -d # wait for flyway to finish running before... docker compose -f docker-compose-integration.yaml logs -f flyway | grep -q "Successfully applied\|No migration necessary" +BASE_CMD="DATABASE_URL=postgresql://postgres:pw@localhost:5432/tefca_db TEST_TYPE=integration jest " # running our integration tests -DATABASE_URL=postgresql://postgres:pw@localhost:5432/tefca_db TEST_TYPE=integration jest --testPathPattern=tests/integration +if [ "$GENERATE_COVERAGE_REPORT" = "true" ]; then + JEST_CMD="$BASE_CMD --testPathIgnorePatterns='/e2e/' --ci --json --coverage --testLocationInResults --outputFile=report.json" +else + JEST_CMD="$BASE_CMD --testPathPattern=tests/integration" +fi +eval $JEST_CMD JEST_EXIT_CODE=$? # Teardown containers diff --git a/query-connector/package.json b/query-connector/package.json index 33c81ed53..558beea51 100644 --- a/query-connector/package.json +++ b/query-connector/package.json @@ -13,6 +13,7 @@ "start": "NODE_TLS_REJECT_UNAUTHORIZED=0 node .next/standalone/server.js", "lint": "next lint", "test": "npm run test:unit && npm run test:integration", + "test:ci": "GENERATE_COVERAGE_REPORT=true bash ./integration.sh", "test:unit": "jest --testPathIgnorePatterns='/e2e/' '/integration/'", "test:unit:watch": "jest --watch", "test:integration": "bash ./integration.sh",