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.

Finally, this configuration assumes that you have committed your Momentic tests and configuration files to your Git repository.

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-22.04
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20

        # install deps for your own application, if needed
      - run: npm install

        # installs "chromium" by default, pass arguments for other browsers
      - run: npx momentic@^1 install-browsers

        # start your application locally and run momentic tests
      - run: npx momentic@^1 run ./momentic --start "npm run start" --wait-on http://localhost:3000

        # run tests remotely and wait
      - run: npx momentic@^1 queue tests test-path-1 --wait