name: test

on:
  pull_request:

permissions:
  contents: read
  actions: read
  checks: write

jobs:
  jest-coverage:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 18.x
          cache: 'npm'

      - name: Install Dependencies
        run: npm install

      - name: Run Tests
        run: npm run test:ci
        env:
          CI: true

      - name: Test Report
        uses: dorny/test-reporter@v1
        if: success() || failure()
        with:
          name: Jest Tests
          path: junit*.xml
          reporter: jest-junit
