🏡 index : quine-global/webdriverio.git

name: Unit Tests

on:
  workflow_call:
    # Make this a reusable workflow, no value needed
    # https://docs.github.com/en/actions/using-workflows/reusing-workflows

jobs:
  check:
    name: Unit Test (${{ matrix.os }}.${{ matrix.node }})
    permissions:
      contents: read
      actions: write
    strategy:
      fail-fast: false
      matrix:
        node: ['20', '22', '24']
        os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
    runs-on: ${{ matrix.os }}
    steps:
      - name: ⬇️ Checkout Code
        uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0

      - name: 🧑‍🔧 Get Core Dependencies
        uses: ./.github/workflows/actions/get-core-dependencies

      - name: 🐢 Setup Node ${{ matrix.node }}
        uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
        with:
          node-version: ${{ matrix.node }}
          cache: 'pnpm'

      - name: Download Build Archive
        uses: ./.github/workflows/actions/download-archive
        with:
          name: webdriverio
          path: .
          filename: webdriverio-build.zip

      - name: Unit Tests
        run: pnpm run test:unit:run
        shell: bash

      - name: Check Git Context
        # currently fails in Windows due to changes to snapshots
        # in packages/wdio-browser-runner/tests/vite/__snapshots__/utils.test.ts.snap
        if: matrix.os != 'windows-latest'
        uses: ./.github/workflows/actions/check-git-context