Skip to main content

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.

Example pipeline for running Momentic on Buildkite. More reference configs live in momentic-ai/examples. Buildkite is auto-detected, so Momentic reads git metadata (branch, commit, pipeline) from the agent automatically. For a given root package.json:
package.json
{
  "name": "my-momentic-repo",
  "scripts": {},
  "devDependencies": {
    "momentic": "latest"
  }
}
Create a file called .buildkite/pipeline.yml in your repository with the following contents:
.buildkite/pipeline.yml
steps:
  - label: ":momentic: Test"
    commands:
      - npm install
      - npx momentic install-browsers --all
      - npx momentic run
      - npx momentic results upload test-results

Authentication

To run any commands, you must authenticate with Momentic by providing the MOMENTIC_API_KEY environment variable.
  1. Create an API key in the Momentic dashboard and copy the value.
  2. Store it as a secret with the Buildkite secrets tooling your agents use (the secrets Buildkite plugin, your secrets manager, or an agent environment hook). Avoid committing it to the pipeline file.
  3. Expose it to the momentic steps as MOMENTIC_API_KEY:
.buildkite/pipeline.yml
steps:
  - label: ":momentic: Test"
    env:
      MOMENTIC_API_KEY: "${MOMENTIC_API_KEY}"
    commands:
      - npm install
      - npx momentic install-browsers --all
      - npx momentic run

Sharding

If you have a large test set, you can use sharding to run tests in parallel. This can significantly speed up your CI runs. Buildkite exposes the parallel job index as BUILDKITE_PARALLEL_JOB (0-indexed) and the total as BUILDKITE_PARALLEL_JOB_COUNT. Momentic’s --shard-index is 1-indexed, so add one. To collect every shard into a single run group in the dashboard, add a step that merges and uploads results after the tests finish.
.buildkite/pipeline.yml
steps:
  - label: ":momentic: Test %n"
    parallelism: 4
    artifact_paths:
      - "test-results/**/*"
    commands:
      - npm install
      - npx momentic install-browsers --all
      - |
        npx momentic run \
          --shard-index $(($BUILDKITE_PARALLEL_JOB + 1)) \
          --shard-count $BUILDKITE_PARALLEL_JOB_COUNT \
          --output-dir test-results/shard-$BUILDKITE_PARALLEL_JOB

  - wait: ~
    continue_on_failure: true

  - label: ":momentic: Merge and upload results"
    commands:
      - npm install
      - buildkite-agent artifact download "test-results/**/*" test-results
      - npx momentic results merge --output-dir test-results/merged test-results
      - npx momentic results upload test-results/merged

Test Analytics

Momentic can emit a Buildkite-flavored JSON report with the buildkite-json reporter for Buildkite Test Analytics:
npx momentic run --reporter buildkite-json --reporter-dir reports