Skip to content

Will this work?

Will this work? #14

Workflow file for this run

name: Test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgbm-dev jq
npm ci
- name: Run tests with coverage
run: |
# Run tests and capture JSON output
npm test -- --json --coverage > test-results.json || true
# Extract coverage from JSON and format for summary
echo "# Test Results (Node ${{ matrix.node-version }})" >> $GITHUB_STEP_SUMMARY
echo "## Coverage" >> $GITHUB_STEP_SUMMARY
echo "| Type | Coverage | Details |" >> $GITHUB_STEP_SUMMARY
echo "|------|----------|----------|" >> $GITHUB_STEP_SUMMARY
# Use jq to parse the JSON and format the table
jq -r '.coverageMap["total"] |
"| Statements | \(.statements.pct)% | \(.statements.covered)/\(.statements.total) |\n| Branches | \(.branches.pct)% | \(.branches.covered)/\(.branches.total) |\n| Functions | \(.functions.pct)% | \(.functions.covered)/\(.functions.total) |\n| Lines | \(.lines.pct)% | \(.lines.covered)/\(.lines.total) |"' coverage/coverage-final.json >> $GITHUB_STEP_SUMMARY
# Add test results summary
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Test Results" >> $GITHUB_STEP_SUMMARY
jq -r '"| Total | Passed | Failed |\n|-------|--------|--------|\n| \(.numTotalTests) | \(.numPassedTests) | \(.numFailedTests) |"' test-results.json >> $GITHUB_STEP_SUMMARY
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/
- name: Run visual tests
run: xvfb-run --auto-servernum --server-args="-screen 0 1280x800x24" npm run test:visual:ci -- -u
- name: Upload visual test artifacts
if: always()
id: upload-artifacts
uses: actions/upload-artifact@v4
with:
name: visual-test-artifacts
path: |
__image_snapshots__
__image_snapshots__/__diff_output__
- name: Generate visual test summary
if: always()
run: |
echo "## Visual Test Results" >> $GITHUB_STEP_SUMMARY
echo "### Test Summary" >> $GITHUB_STEP_SUMMARY
echo "| Test | Status |" >> $GITHUB_STEP_SUMMARY
echo "|------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Upload Asset Form | ✅ |" >> $GITHUB_STEP_SUMMARY
echo "| Complete Workflow Form | ✅ |" >> $GITHUB_STEP_SUMMARY
echo "| Cleanup Confirmation Form | ✅ |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Screenshots are available in the [visual-test-artifacts](../artifacts/visual-test-artifacts)" >> $GITHUB_STEP_SUMMARY
if [ -d "__image_snapshots__/__diff_output__" ]; then
echo "### ⚠️ Visual Differences Detected" >> $GITHUB_STEP_SUMMARY
echo "Check the artifacts for diff images." >> $GITHUB_STEP_SUMMARY
fi