refactor: Transition to Vitest for testing framework and remove obsolete files #8
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Unit Tests | |
| on: | |
| push: | |
| branches: [ main, develop ] | |
| pull_request: | |
| workflow_dispatch: | |
| env: | |
| NODE_VERSION: '18' | |
| PNPM_VERSION: '8' | |
| jobs: | |
| unit-tests: | |
| name: Client Unit Tests | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js and pnpm | |
| uses: ./.github/actions/setup-node-pnpm | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| pnpm-version: ${{ env.PNPM_VERSION }} | |
| - name: Run unit tests with coverage | |
| run: | | |
| cd client | |
| echo "🧪 Running client unit tests..." | |
| pnpm run test:coverage --reporter=verbose | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v4 | |
| if: always() | |
| with: | |
| directory: ./client/coverage | |
| flags: unit-tests | |
| name: client-unit-tests | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: false # Don't fail CI if Codecov upload fails | |
| - name: Coverage Summary | |
| if: always() | |
| run: | | |
| cd client | |
| if [ -f coverage/coverage-summary.json ]; then | |
| echo "" | |
| echo "📊 COVERAGE SUMMARY" | |
| echo "===================" | |
| # Extract coverage percentages from JSON | |
| if command -v jq &> /dev/null; then | |
| LINES=$(jq -r '.total.lines.pct' coverage/coverage-summary.json) | |
| FUNCTIONS=$(jq -r '.total.functions.pct' coverage/coverage-summary.json) | |
| BRANCHES=$(jq -r '.total.branches.pct' coverage/coverage-summary.json) | |
| STATEMENTS=$(jq -r '.total.statements.pct' coverage/coverage-summary.json) | |
| echo "📈 Lines: $LINES%" | |
| echo "🔧 Functions: $FUNCTIONS%" | |
| echo "🌿 Branches: $BRANCHES%" | |
| echo "📝 Statements: $STATEMENTS%" | |
| echo "" | |
| # Check minimum coverage thresholds | |
| if (( $(echo "$LINES >= 50" | bc -l) )); then | |
| echo "✅ Line coverage meets minimum threshold (50%)" | |
| else | |
| echo "⚠️ Line coverage below minimum threshold (50%)" | |
| fi | |
| else | |
| echo "📋 Coverage files generated in ./coverage/" | |
| fi | |
| else | |
| echo "⚠️ No coverage summary found" | |
| fi | |
| - name: Upload coverage artifacts | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: coverage-reports | |
| path: | | |
| client/coverage/ | |
| !client/coverage/tmp/ | |
| retention-days: 7 | |
| - name: Test Summary | |
| if: always() | |
| run: | | |
| echo "" | |
| echo "🧪 UNIT TESTS COMPLETED" | |
| echo "======================" | |
| if [ "${{ job.status }}" = "success" ]; then | |
| echo "✅ All unit tests passed!" | |
| echo "📊 Coverage reports uploaded" | |
| echo "🎉 Client unit tests are healthy" | |
| else | |
| echo "❌ Some unit tests failed" | |
| echo "💡 Check test output above for details" | |
| echo "📊 Coverage reports still uploaded for analysis" | |
| fi |