Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPIKE - code coverage #349

Merged
merged 20 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 7 additions & 22 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
npm ci
npm run lint

unit-tests:
unit-and-integration-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions query-connector/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ certificates
/playwright-report/
/blob-report/
/playwright/.cache/
/coverage
report.json
18 changes: 0 additions & 18 deletions query-connector/integration.sh

This file was deleted.

3 changes: 2 additions & 1 deletion query-connector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
"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": " bash ./unit_and_integration_tests.sh",
"test:unit": "jest --testPathIgnorePatterns='/e2e/' '/integration/'",
"test:unit:watch": "jest --watch",
"test:integration": "bash ./integration.sh",
"test:integration": "JUST_INTEGRATION=true bash ./unit_and_integration_tests.sh",
"test:playwright": "docker compose -f ./docker-compose-e2e.yaml build --no-cache && docker compose -f ./docker-compose-e2e.yaml up -d && npx playwright test --reporter=list",
"test:playwright:local": "dotenv -e ./.env -- npx playwright test --ui",
"cypress:open": "cypress open",
Expand Down
25 changes: 25 additions & 0 deletions query-connector/unit_and_integration_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/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
if [ "$JUST_INTEGRATION" = "true" ]; then
JEST_CMD="$BASE_CMD --testPathPattern=tests/integration"
else
# assuming that the only reason we'd want to run both the unit and integration tests is in the CI context where we need to gather coverage report info
JEST_CMD="$BASE_CMD --testPathIgnorePatterns='/e2e/' --ci --json --coverage --testLocationInResults --outputFile=report.json"
fi
eval $JEST_CMD
JEST_EXIT_CODE=$?
fzhao99 marked this conversation as resolved.
Show resolved Hide resolved

# Teardown containers
docker compose -f docker-compose-integration.yaml down

# Exit with the Jest exit code
exit $JEST_EXIT_CODE
Loading