• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

I Like Kill Nerds

The blog of Australian Front End / Aurelia Javascript Developer & brewing aficionado Dwayne Charrington // Aurelia.io Core Team member.

  • Home
  • Aurelia 2
  • Aurelia 1
  • About
  • Aurelia 2 Consulting/Freelance Work

Writing a GitHub Actions File To Test Against Multiple Node.js Versions

GitHub · February 23, 2023

If you’re distributing a package, say a plugin, you may want to test it against multiple Node versions (especially if you’re using Jest for tests). In my situation, I have a popular plugin for Aurelia called Aurelia Google Maps. It’s for Aurelia 1, but many people use it, so I wanted to test it against the LTS of Node and the latest version.

name: Node.js Jest Tests

on: [push, pull_request]

jobs:
  build-and-test:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3

    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v3
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'yarn'

    - name: Install dependencies
      run: yarn install

    - name: Run Jest tests
      run: yarn test

    strategy:
      matrix:
        node-version: [18.x, 19.x]

You will want to save this file in your .github/workflows directory at the root of your project. You can save it as whatever you want: run-tests.yml

As you can see in the on part, the tests will run on every push and pull request. It’s also worth going in and ensuring you have some rules to ensure only pull requests that pass the tests meet the criteria for merging too.

Dwayne

Leave a ReplyCancel reply

0 Comments
Inline Feedbacks
View all comments

Primary Sidebar

Popular

  • Handling Errors with the Fetch API
  • How To Get The Hash of A File In Node.js
  • Testing Event Listeners In Jest (Without Using A Library)
  • The Quad Cortex Desktop Editor is Finally Announced
  • How To Paginate An Array In Javascript

Copyright © 2023 · Dwayne Charrington · Log in

wpDiscuz