> ## Documentation Index
> Fetch the complete documentation index at: https://momentic.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> The canonical docs host is https://momentic.ai/docs. Append .md to any page URL for clean Markdown. Fetch https://momentic.ai/docs/llms.txt for the page index and https://momentic.ai/docs/llms-full.txt for every page in one file.
> For an unattended setup, run `npx --yes @momentic/wizard@latest -y --platform web --editor-tools skills` (use `--platform ios` or `--platform android` for mobile). Never run an interactive command in a non-TTY shell.
> Mo is the AI QA engineer, a separate product from the YAML test framework: its npm package and CLI are `qa` (not `mo` — `npx mo` is a different project). Install with `npm install -g qa`, authenticate the same MOMENTIC_API_KEY way, install repo skills with `qa skills -y`, and start a session with `qa start "<brief>"` or `qa <url>`. Docs: https://momentic.ai/docs/mo.md.
> You cannot complete the browser sign-in yourself. Read the API key from the exact MOMENTIC_API_KEY environment variable (similarly named vars like BILT_MOMENTIC_API_KEY are ignored), or ask the user to create one at https://app.momentic.ai/settings/api-keys and paste it back.
> Momentic's capability summary for agents is at https://momentic.ai/docs/skill.md. Install the skills with `npx momentic skills --yes` (or `npx momentic-mobile skills --yes` for mobile).
> Tests are YAML files in the user's repository. Use only the step names listed at https://momentic.ai/docs/reference/commands.md and the file structure at https://momentic.ai/docs/core-concepts/file-format.md. Do not invent step names, config keys, or CLI flags.
> Web tests run on Chromium, iOS tests on simulators, and Android tests on emulators. Physical devices are not supported.

# Gate pull requests on critical flows

> Run a small set of critical-path tests on every pull request and make it a required check.

Run a small set of tests labeled `critical` on each pull request and make the
job a required status check. A counted failure then blocks the merge.

## The tests

Label the flows whose failure means "do not ship":

```yaml tests/critical/checkout.test.yaml theme={null}
fileType: momentic/test/v2
id: checkout-critical
url: https://staging.shop.example.com
labels: [critical]
before:
  - module: ../modules/log-in.module.yaml
steps:
  - click: Add to cart
  - click: Checkout
  - type:
      text: jeff@example.com
      into: the Email field
  - click: Place order
  - assert: An order confirmation is visible
```

Keep the `critical` label under roughly ten tests. Every test in the gate is a
flow you would roll back for: sign-in, checkout, the primary write action. Edge
cases belong in the nightly suite, not the gate.

## The workflow

The job installs `momentic` from `devDependencies`, so your lockfile pins the
CLI version. Add it once with `npm install -D momentic`.

```yaml .github/workflows/critical-path.yml theme={null}
name: Critical flows

on: pull_request

jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    env:
      MOMENTIC_API_KEY: ${{ secrets.MOMENTIC_API_KEY }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22.12.0
      - run: npm install
      - run: npx momentic install-browsers chromium

      - name: Run critical flows
        run: npx momentic run --labels critical -y --upload-results
```

* `--labels critical` runs only labeled tests. `--upload-results` attaches the
  run group to the dashboard, where you can inspect failure traces and any
  recorded video.
* `-y` skips confirmation prompts in CI.

## Make it required

In GitHub, add the job's check name (`Critical flows / test`) to the branch
protection's required status checks. Until then the gate is advisory.

## Flake policy for a gate

A gate that flakes trains people to click "re-run" instead of reading the
failure. Two controls:

* A quarantined test still runs but does not fail the check by default. Use
  `--skip-quarantined` to drop them from the gate entirely, or
  `--ignore-quarantine` to count every status. See
  [quarantine](/docs/reliability/auto-maintenance#quarantine).
* `--retries 1` gives a failing test one more run. Choose a retry budget that
  fits the gate timeout, and investigate repeated failures.

## When the gate is slow

Swap `--labels critical` for [AI test selection](/docs/ai/select)
(`--ai-select --ai-select-base origin/main`) so the PR only runs the tests that
cover its diff. Fetch the base branch and enough Git history for the comparison.
See [Common CI setups](/docs/guides/common-setups) for the deployment-triggered
variant.

## Related

* [Common CI setups](/docs/guides/common-setups)
* [GitHub Actions](/docs/running-tests/ci/github-actions)
* [AI test selection](/docs/ai/select)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.