Here is a GitHub repository with sample code: momentic-github-actions-demo.

This is an example of how to setup Momentic tests to run on every pull request and commit to main using GitHub Actions. Make sure to set the MOMENTIC_API_KEY secret in your repository settings.

The YAML below assumes that the command npm run start will start your application on localhost:3000. Customize these values to suit your build process.

name: Test

env:
  MOMENTIC_API_KEY: ${{ secrets.MOMENTIC_API_KEY }}

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  run-tests:
    name: Run tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
      - run: npm install

        # make sure to install browsers first before running tests locally (not required for remote tests)
      - run: npx momentic@latest install-browsers

        # run tests locally
      - run: npx momentic@latest run ./momentic --local --start "npm run start" --wait-on http://localhost:3000

        # run tests remotely and wait
      - run: npx momentic@latest run test-path-1 --remote --wait