Skip to content

Latest commit

 

History

History
44 lines (32 loc) · 1.43 KB

github-actions.mdx

File metadata and controls

44 lines (32 loc) · 1.43 KB
description
How to integrate Momentic with GitHub Actions.

GitHub Actions

You can use the Momentic CLI to easily integrate Momentic tests into your GitHub Actions steps and jobs.

Usage

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 --local --start "npm run start" --wait-on http://localhost:3000 --tests c2c2fee4-4778-4bbb-8f0c-31f25f774726

        # run tests remotely
      - run: npx momentic@latest run --remote --tests c2c2fee4-4778-4bbb-8f0c-31f25f774726