name: test

on:
  pull_request:
    branches: 
      - master

jobs:
  build:

    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        node-version: [8.x, 10.x, 12.x, 14.x]
        browser: [chrome, firefox]

    steps:
    - uses: actions/checkout@v1
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - name: install macos-latest dependencies
      if: matrix.os == 'macos-latest' # TODO this if statement does not seem to work. The other builds on other os's do not fail entirely, but this command does fail
      run: |
        brew update && brew install --cask firefox && brew install --cask google-chrome
    - name: npm install and npm test
      run: |
        npm ci
        npm test
      env:
        CI: true
        OS: ${{ matrix.os }}
        BROWSER: ${{ matrix.browser }}