name: Tests

on: [push, pull_request]

jobs:
  tests:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up Node.js
        uses: actions/setup-node@v2
        with:
          node-version: 16

      - name: Install, Lint & Unit test
        run: |
          npm i
          npm run unit:test

      - name: E2e tests
        id: e2e
        continue-on-error: true
        run: npm run e2e:test

      - name: Uploading screenshots on failure
        if: steps.e2e.outcome == 'failure'
        uses: actions/upload-artifact@v2
        with:
          name: failure-screenshots
          path: test/e2e/screenshots/

      - name: Exit signal
        if: steps.e2e.outcome == 'failure'
        run: exit 1
