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

# tests

> Export, archive, and delete the tests (goals) of an Openlayer project

The `openlayer tests` command exports the test definitions (goals) for the current
Openlayer project as JSON. This is useful for bootstrapping or syncing a local
[`tests.json`](/docs/development/tests-json) from tests defined in the platform.

Its `delete` subcommand removes tests in bulk, so you don't have to delete them one
at a time in the UI.

## Usage

```bash theme={null}
openlayer tests [flags]
openlayer tests delete [flags]
```

### Examples

```bash theme={null}
# Print the project's tests to stdout
openlayer tests

# Write the tests to a file
openlayer tests --output tests.json
```

Every exported test carries a [`tags`](/docs/development/tests-json#tags) list of tag names,
so you can export a project, edit the tags, and push them back:

```json Export output theme={null}
{
  "_meta": { ... },
  "items": [
    {
      "name": "Mean quasi-exact match above 0.7",
      "syncId": "7b3f2c1e-9d84-4a6b-8c2f-1e5d9a7b3c4f",
      "tags": ["regression", "release-gate"],
      ...
    }
  ]
}
```

Any tag name your project doesn't have yet is created when you push. A test with no
`tags` field keeps whatever tags it has on the platform — see
[`tags`](/docs/development/tests-json#tags) for the full behavior.

<Note>
  The export is wrapped in `{"_meta": ..., "items": [...]}`, while
  [`tests.json`](/docs/development/tests-json#structure) is the array of tests on its own.
  Take the `items` array when you turn an export into a `tests.json`:

  ```bash theme={null}
  openlayer tests | jq '.items' > tests.json
  ```

  To download a ready-to-use `tests.json` array instead,
  [export the test configurations from the Results page](/docs/tests/manage-tests#export-test-configurations).
</Note>

## Flags

| Flag | Alias | Default | Description |
| - | - | - | - |
| `--output` | `-o` | `stdout` | Output file to write the tests JSON. |

## `openlayer tests delete`

Archives — or, with `--force`, permanently deletes — the tests you select.

Archiving hides a test while preserving its result history, and can be undone from
the platform. `--force` deletes the test **and all of its results**, and cannot be
undone.

Tests are selected by the [`syncId`](/docs/development/tests-json#syncid) you author in
`tests.json`, by the test's platform id, or by name. Each flag is repeatable and
they can be mixed in a single command.

### Examples

```bash theme={null}
# Archive a test by the syncId from your tests.json
openlayer tests delete --sync-id 7b3f2c1e-9d84-4a6b-8c2f-1e5d9a7b3c4f

# Archive several tests at once, mixing selectors
openlayer tests delete \
  --sync-id 7b3f2c1e-9d84-4a6b-8c2f-1e5d9a7b3c4f \
  --sync-id 4e8a1d92-5c73-4b1f-a9e6-2d7c8b4f1a3e \
  --name "Faithful to context"

# Preview what would be removed, without changing anything
openlayer tests delete --sync-id 7b3f2c1e-9d84-4a6b-8c2f-1e5d9a7b3c4f --dry-run

# Permanently delete a test and its results, skipping the confirmation
openlayer tests delete --id 366c0fe7-179f-462d-b883-81e0837cf6d6 --force --yes
```

### Flags

| Flag | Alias | Default | Description |
| - | - | - | - |
| `--sync-id` | | | `syncId` of a test to remove. Repeatable. |
| `--id` | | | Platform id of a test to remove. Repeatable. |
| `--name` | | | Name of a test to remove. Repeatable. |
| `--force` | | `false` | Permanently delete the tests and all their results instead of archiving them. |
| `--yes` | `-y` | `false` | Answer yes to all prompts. |
| `--dry-run` | | `false` | List the tests that would be removed without modifying anything. |

At least one of `--sync-id`, `--id` or `--name` is required.

### Selector resolution

Before anything is modified, every selector must resolve to exactly one test. If any
selector matches nothing — or if a `--name` matches more than one test — the command
reports all of the problems at once and exits without removing anything, so a typo
can't leave a partially applied deletion behind:

```bash theme={null}
$ openlayer tests delete --sync-id typo-123 --name "Duplicate name"
Error: could not resolve every selector:
  - "Duplicate name" matches 2 tests (366c0fe7-..., 0097c943-...) -- select one with --id
  - no test with syncId typo-123
```

The command then lists what it matched and asks for confirmation before acting.

<Note>
  In non-interactive mode (`--output-mode ci`, used by agents and CI pipelines)
  the confirmation prompt cannot be answered, so pass `--yes` — otherwise the
  command fails fast rather than hanging.
</Note>

<Warning>
  `--force` is irreversible: it deletes the tests and every result they have
  recorded. Run with `--dry-run` first if you're selecting more than a couple of
  tests.
</Warning>

## Related guides

* [`tests.json`](/docs/development/tests-json)


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