> ## 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.

# Targets

> Reference for the `targets` map in `momentic.config.yaml`. A target selects a subset of tests and runs them with its own viewport, user agent, and locale.

Use targets to run the same tests under different browser settings without
copying test files. Each target picks tests by label or path and sets browser
overrides in `use`. Select one or more targets with `momentic run --target`.

```yaml momentic.config.yaml theme={null}
targets:
  desktop:
    use:
      viewport: "1440,900"
  mobile-fr:
    labels: [smoke]
    exclude:
      - "tests/desktop-only/**"
    use:
      viewport: "390,844"
      locale: fr-FR
      userAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X)"
```

```bash theme={null}
npx momentic run --target desktop --target mobile-fr
```

Each selected target runs its matching tests once. A test that matches both
targets runs twice, and reports name each run as `<test name> [<target>]`.

## Select tests

**targets.\<name>** `object`

A target name uses letters, digits, and hyphens and is case sensitive. `{}` is
a valid target: it selects every test and changes no settings.

**targets.\<name>.labels** `string[]`

Select tests that have at least one of these labels.

**targets.\<name>.include** `string[]`

Select tests whose file path matches one of these globs. Paths are relative to
the project root.

**targets.\<name>.exclude** `string[]`

Drop tests whose file path matches one of these globs. Exclusions apply after
`labels` and `include`.

A test must match every selector the target sets. Paths, `--labels`,
`--include`, and `--exclude` on the command line narrow the target further; they
don't replace its selectors. The CLI `--include` and `--exclude` flags take
regular expressions, while target `include` and `exclude` take globs.

If a selected target matches no tests, `momentic run` fails before any test
starts.

## Override browser settings

**targets.\<name>.use.viewport** `string | object`

Browser viewport, as `"<width>,<height>"` or `{ width, height }`.

**targets.\<name>.use.userAgent** `string | null`

User agent string. `null` uses the browser's native user agent; the string
`"null"` is sent as a literal user agent.

**targets.\<name>.use.locale** `string`

BCP 47 language tag such as `fr-FR`. Sets the browser language,
`navigator.language`, number and date formatting, and the default
`Accept-Language` header. It doesn't change the timezone, geolocation, or
URLs.

Settings apply in this order, with later layers winning: browser defaults,
environment `browser` settings, test settings, target `use`, then settings you
pass on the command line.

## Inspect targets

List each target with its selectors, settings, and number of matching tests:

```bash theme={null}
npx momentic list --targets
```

Preview what a run would do without logging in or starting a browser. The
preview shows the selected tests per target and where each test's environment,
URL, viewport, user agent, and locale come from:

```bash theme={null}
npx momentic run --target mobile-fr --dry-run
```

Add `--json` to either command for machine-readable output.

## Notes

* A run without `--target` ignores targets and uses test settings, even when the
  project defines targets.
* `--target` can't be combined with `--ai-select`, `--ai-select-dry-run`, or
  `--from-snapshot`.
* A target that sets `use.locale` fails the run if an `Accept-Language` header
  is also set in test, environment, or project settings, or with
  `--custom-headers`. Remove one of the two.
* Targets that set `use` skip [step cache](https://momentic.ai/docs/reliability/step-cache.md) reads and
  writes, since cached steps don't record the viewport, user agent, or locale.
* Targets that set `use` keep their own
  [visual diff](https://momentic.ai/docs/reference/commands/visual-diff.md) baselines under
  `<goldenFileDir>/targets/<name>/`. An explicit baseline path gets
  `targets/<name>/` inserted before the file name.
* Target names appear in local output and in JUnit, JSON, Allure, Playwright
  JSON, and Buildkite reports. Run pages in the Momentic app don't show the
  target yet.
* A target has no suite-level setup or teardown and can't set environment
  variables. Unknown keys under a target or its `use` fail config validation.


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