CI Integration
Aver tests run in any CI system that supports Node.js. This guide covers GitHub Actions with JUnit reporting and Playwright browser testing.
Basic Setup
Section titled “Basic Setup”Aver tests are Vitest tests, so standard Vitest CI configuration works:
name: CIon: [push, pull_request]
jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: 22 cache: npm - run: npm ci - run: npx aver runaver run wraps vitest run and adds adapter/domain filtering via --adapter and --domain flags. For Vitest-specific options like --reporter or --outputFile, use npx vitest run directly.
JUnit Reporting
Section titled “JUnit Reporting”Use Vitest’s built-in JUnit reporter for CI-friendly test output:
- run: npx vitest run --reporter=junit --reporter=default --outputFile.junit=test-results.xmlThe --reporter=default keeps console output alongside the XML report.
Playwright in CI
Section titled “Playwright in CI”If your adapters use @averspec/protocol-playwright, install browsers:
- run: npx playwright install --with-deps chromiumCache browsers for faster runs:
- name: Get Playwright version id: pw-version run: echo "version=$(npx playwright --version)" >> $GITHUB_OUTPUT
- name: Cache Playwright browsers uses: actions/cache@v4 with: path: ~/.cache/ms-playwright key: playwright-${{ runner.os }}-${{ steps.pw-version.outputs.version }} restore-keys: playwright-${{ runner.os }}-
- name: Install Playwright run: npx playwright install --with-deps chromiumGitHub Actions Annotations
Section titled “GitHub Actions Annotations”Add the github-actions reporter for inline failure annotations on PRs:
- run: > npx vitest run --reporter=junit --reporter=github-actions --reporter=default --outputFile.junit=test-results.xmlBuild Before Testing
Section titled “Build Before Testing”If your adapters import from built packages (common in monorepos), build first:
- name: Build run: pnpm --filter @averspec/core run build
- name: Test run: npx aver runRunning Multiple Packages
Section titled “Running Multiple Packages”For monorepos, run each package separately with if: !cancelled() so all suites run even if one fails:
- name: Test core run: npx aver run working-directory: packages/core
- name: Test API adapter if: ${{ !cancelled() }} run: npx aver run working-directory: packages/my-api
- name: Test browser adapter if: ${{ !cancelled() }} run: npx aver run working-directory: packages/my-browserExample: Complete Workflow
Section titled “Example: Complete Workflow”name: CIon: push: branches: [main] pull_request:
jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
- uses: actions/setup-node@v4 with: node-version: 22 cache: npm
- run: npm ci
- name: Get Playwright version id: pw-version run: echo "version=$(npx playwright --version)" >> $GITHUB_OUTPUT
- name: Cache Playwright browsers uses: actions/cache@v4 with: path: ~/.cache/ms-playwright key: playwright-${{ runner.os }}-${{ steps.pw-version.outputs.version }} restore-keys: playwright-${{ runner.os }}-
- name: Install Playwright run: npx playwright install --with-deps chromium
- name: Build run: npm run build
- name: Test run: > npx vitest run --reporter=junit --reporter=github-actions --reporter=default --outputFile.junit=test-results.xml