---
title: "Keeping end-to-end tests as YAML in your repo: review, lint and run them in CI"
description: "Keep end-to-end tests as YAML next to the code: monorepo layout, reviewing test changes in pull requests, linting, and running them in CI."
canonical: "https://momentic.ai/blog/end-to-end-tests-yaml-in-repo"
last-updated: "2026-11-10T17:36:34Z"
---

# Keeping end-to-end tests as YAML in your repo: review, lint and run them in CI

URL: https://momentic.ai/blog/end-to-end-tests-yaml-in-repo

[blog](/blog) [/ resources](/blog/category/resources)  / end-to-end-tests-yaml-in-repo

Resources

Keep end-to-end tests as YAML next to the code: monorepo layout, reviewing test changes in pull requests, linting, and running them in CI.

Wei-Wei Wu

CEO, Momentic

## TL;DR

- Keep end-to-end tests as YAML files in the repo. Validate them in a pre-commit hook, then run the test suite in CI.
- Review test changes in the same PR as application code. Check the steps and assertions for intent, while CI checks whether the test runs.
- In a monorepo, place app-specific tests near the package they exercise. Put reusable flows in a shared modules directory.
- Commit the test and the behavior it verifies together. Git history then shows which test change accompanied each feature or fix.

## Why end-to-end tests belong next to the code they test

End-to-end tests can drift when application code lives in Git and recorded tests live in a separate SaaS workspace. A developer might change a checkout flow in a pull request, then update its recorded test after the code merges. Even if the test tool keeps its own revision history, the application commit does not show which test change verifies the new behavior.

A YAML test in the repo can travel with the code it checks. If a pull request changes checkout behavior, the same diff can show the updated test steps and assertions. Reviewers can judge whether the test covers the intended behavior, and Git history preserves the relationship between the code change and the test change. You can draft these steps from the ticket itself; see [turning Jira tickets into end-to-end tests](/blog/jira-tickets-to-end-to-end-tests).

Keeping tests as files also lets you apply familiar checks. An editor or pre-commit hook can catch invalid YAML before a push, while CI can run the test against the proposed commit. Those checks require configuration, but the test file gives them a shared artifact to inspect and run.

## Can I write end-to-end tests as YAML files in my repo?

Yes. You can keep Momentic end-to-end tests as YAML files in the same repo as the application code. A test file uses `fileType` to identify its format, `id` to identify the test, and `steps` to describe what the test does. The `before` and `after` sections hold work that runs around those steps.

Keep the `id` unchanged when you rename or move a test file. Git tracks the file change, while the stable ID continues to identify the test independently of its path. Reviewers can then read changes to the steps and surrounding setup in the same PR as the application change.

Use `npx momentic` for web tests and `npx momentic-mobile` for mobile tests. Both use YAML files, though you should check the relevant test format before copying fields between web and mobile files.

## Where should end-to-end tests live in a monorepo

Keep a test beside the app or package whose behavior it verifies. In a monorepo, that gives reviewers a useful default. A change to `apps/storefront` and its test appear in the same part of the PR diff.

`apps/  storefront/  src/  e2e/  checkout.test.yaml  admin/  src/  e2e/  access.test.yaml e2e/  modules/  login.module.yaml`

Put flows used by multiple packages in a shared modules directory. For example, write the login flow once in `e2e/modules/login.module.yaml`, then reference it with `module:` from both `checkout.test.yaml` and `access.test.yaml`. The module uses `fileType: momentic/module/v2` and declares `parameters` for values that differ between callers, such as the account used for the run. Mobile modules use `fileType: momentic-mobile/mobile-module/v2`. Keep a module local to an app when no other package uses it, so the shared directory does not become a collection of one-off flows.

A top-level `e2e/` directory makes more sense for tests that cross package boundaries, such as a checkout journey that starts in the storefront and ends in an admin interface. Keep package-specific tests beside their apps, and reserve the top-level directory for cross-app tests and genuinely shared modules.

## How do I ship a test and the code change in one commit

A feature commit should include the test change that verifies its new behavior. Run the application on a local dev build, author or update the matching `*.test.yaml` file, and run the test before committing. Stage the YAML file with the source diff so reviewers can inspect both in one PR. CI can then build that commit and run its test suite against the code under review.

The same commit boundary works when a coding agent makes the application change. If the agent has access to the repo and the relevant MCP tools or skills, ask it to update the matching YAML test in the same diff. You still need to review the assertion and check the test run. An agent can produce both files, but a passing test only helps if it checks the behavior the change was meant to preserve.

## How do I review an end-to-end test change in a pull request

Review the YAML diff against the application diff. In `steps`, check whether a new assertion verifies the behavior the code change is meant to deliver, rather than merely confirming that a click succeeded. If a step changes its instruction for finding an element, compare the old and new targets. A broader instruction may make the test pass while letting it interact with the wrong control.

Check `before` and `after` changes for their effect on what the test proves. A `before` step might now create data that bypasses the behavior under test. An `after` change might leave state behind for another test. When a test adds a module parameter, confirm that its value selects the intended flow and that the shared module still makes sense for its other callers.

Human review answers whether the test covers the right behavior. A reviewer should question removed assertions, changed expected results, and setup changes even when the YAML is valid. Lint can catch malformed files, and a CI run can show whether the test passes against the application build. Neither check can tell you whether a passing test would catch the regression the PR is supposed to prevent.

## Linting and validating tests before they reach CI

A local validation check should catch file errors before a test reaches CI. Configure your editor to parse `*.test.yaml` and `*.module.yaml` as YAML. Parsing catches indentation and quoting errors, but it cannot tell you whether a test has a required `id` or a valid step structure. Use a format-aware validator for those checks, and use installed skills or MCP tools to help coding agents edit the files. The agent should run the same validator you run locally.

Add that validator to a pre-commit hook that checks changed test and module files. Have the hook inspect the staged versions of those files, so it validates what the commit will contain rather than an unstaged edit in the working tree. A failed check should block the commit and name the file and field that need attention. Keep browser execution out of the hook. CI can run the committed tests against the application and report behavioral failures separately from file-format errors.

## Running the tests in GitHub Actions or GitLab CI

A CI run should install the browsers, execute the tests against the build under review, and preserve the results when a test fails. Keep `MOMENTIC_API_KEY` in a [GitHub Actions](/docs/running-tests/ci/github-actions) secret rather than in the repository. The job below shows the sequence, with a results directory that GitHub uploads as an artifact even if the test step fails.

`jobs:  e2e:  runs-on: ubuntu-latest  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 ci  - run: npx momentic install-browsers --all  - run: npx momentic run --output-dir ./momentic-results  - if: always()  run: npx momentic results upload  - if: always()  uses: actions/upload-artifact@v4  with:  name: momentic-results  path: ./momentic-results`

Adapt the application install and startup steps to your repo so the tests can reach the app. Check the `results upload` arguments for your installed Momentic CLI version before copying the example. GitHub’s artifact step preserves local output independently of the Momentic upload step.

For a stricter PR gate, label the tests that must pass before merge and run that subset in a [required check](/blog/ci-e2e-test-gating).

`npx momentic run --labels critical --reporter steps -y --upload-results`

Configure the branch rule to require that check, and reserve the `critical` label for behavior you intend to block merges on. Other tests can run in a separate job without making every failure part of the PR gate.

The same sequence applies in GitLab CI. Install dependencies and browsers, provide `MOMENTIC_API_KEY` through a CI variable, run the tests, and retain the output as a job artifact. Momentic also documents CI use with CircleCI, Jenkins, Travis, Buildkite, and Azure DevOps, but each runner needs its own configuration for secrets, the application under test, and result retention.

## Moving off a SaaS-only recorder: exporting tests into files

A recorder can hold the only copy of a test, so start by checking what your current tool actually lets you extract. For mabl or [testRigor](/blog/testrigor-alternatives), verify the export options available to your account rather than assuming a test file or script export exists.

If the tool exports Selenium- or [Playwright](/blog/playwright-ci-cd-guide)-style scripts, use those files as a reference for the actions and assertions you need to preserve. A browser script will not automatically become a repo-native YAML test. Review each exported flow for setup, test data, waits, and expected results before rewriting it in the target format.

If the tool offers no usable export, work from the recorded steps and rewrite the tests by hand. Start with a small set of flows, run each rewritten test against the same application behavior, and compare what it checks with the original. As you move tests into the repo, extract repeated flows such as login into shared modules rather than copying their steps into every file.

Do not plan a migration around an undocumented importer for [mabl](/blog/mabl-alternatives) or testRigor files. The reliable path is to inspect what you can export, preserve the behavior each test verifies, and review the new files in a PR before retiring the recorded versions.

## Engineering takeaway

Keeping end-to-end tests in the repo makes verification part of code review instead of a separate QA handoff. Reviewers can inspect the behavior change and its test in the same diff, while CI runs the committed version of both. A green check shows that the tests passed. The suite remains trustworthy only if its assertions change when the product’s behavior changes, regardless of which tool runs them.

## Frequently asked questions

Can tests reference environment variables or secrets in CI?    Yes. Steps read environment variables with {{ env.NAME }}, for example text: "{{ env.PASSWORD }}". Set the values as CI secrets (GitHub Actions passes MOMENTIC_API_KEY the same way) and keep secret values out of committed files.    What happens if a before step fails?    If a hard before step fails, Momentic skips the main steps and marks the test as a setup failure. The after section still runs whether the main steps pass or fail, so put teardown such as deleting test data there.    Do mobile tests need a different CI runner?    A mobile test needs a runner with the required device or emulator tooling. Check Momentic’s mobile CI requirements before reusing a runner configured for browser tests.    Can non-engineers review a YAML test diff?    Yes. A reviewer can check whether the changed steps and assertions describe the intended behavior, while an engineer checks configuration details and the CI result.

Still have additional questions?

## Keep reading.

[Resources   How to test pull requests from coding agents on preview deploys before you review them     Run end-to-end tests against the Vercel or Netlify preview of every Claude Code, Codex, Devin or Copilot pull request before a human reviews it.     Wei-Wei Wu     7 min read](/blog/test-coding-agent-pull-requests-preview-deploys)[Resources   Testing AI-Generated Code: A Guide for Engineering Teams     Testing AI generated code effectively requires a rethink of your software testing processes. Here’s how to prepare for the uptick in development velocity.     Wei-Wei Wu     10 min read](/blog/testing-ai-generated-code)[Resources   Why Claude Code Is Not Enough for End-to-End Testing     Using Claude Code for end-to-end testing will make test creation faster, but you’ll need to pair it with other tools for the strongest efficiency gains.     Wei-Wei Wu     8 min read](/blog/claude-code-for-end-to-end-testing)

## Try Mo on your app.

Mo is an AI QA engineer. It tests your running app and files each bug with repro steps. Free to start, no credit card.

[Try for free](https://app.momentic.ai/signup) [Contact sales](/sales)
