Skip to content
Open
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
62 changes: 62 additions & 0 deletions .github/workflows/jest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Jest

on:
# Run tests on PRs to verify code doesn't break before merge
pull_request:
types: [opened, synchronize]
# Your production branch. If not the default, update here and set Target Branch at https://gitauto.ai/settings/rules to match
branches: [main]
paths:
- '**/*.js'
- package.json
- package-lock.json
- jest.config.js
# Run tests after merge and collect coverage as canonical source of truth
push:
# Your production branch. If not the default, update here and set Target Branch at https://gitauto.ai/settings/rules to match
branches: [main]
paths:
- '**/*.js'
- package.json
- package-lock.json
- jest.config.js
# Allow manual trigger for debugging
workflow_dispatch:

# Cancel older runs when new commits are pushed to the same PR/branch
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
# Match your project's Node.js version
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run tests
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
# Skip coverage on PRs to keep runs fast
NODE_OPTIONS='--experimental-vm-modules' npx jest --no-coverage
else
# Collect lcov coverage on push/workflow_dispatch
NODE_OPTIONS='--experimental-vm-modules' npx jest --coverage --coverageReporters=lcov --coverageDirectory=coverage
fi

- name: Upload coverage report
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage/lcov.info