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

# Test tags

> Run a test only on some platforms or browsers, or relaunch the app before it, with tags in test titles or Gherkin.

Tags say where a test runs and how the app is reset before it. A test without tags runs on every
platform, after a soft reset.

## The tags

| Tag | Effect |
| - | - |
| `@ios`, `@android`, `@web` | Run the test only on these platforms (several tags: any of them) |
| `@native` | iOS and Android only |
| `@chromium`, `@firefox`, `@webkit` | On the web, run the test only in these browsers ([`devices.web.browser`](./config#devices-web)); iOS and Android ignore them |
| `@hard-reset` | Relaunch the app before this test instead of the [soft reset](https://docs.quiesco.dev/api-in-app.md#reset) |

Your own tags (e.g. `@smoke`) can sit next to them; Quiesco ignores those.

In Vitest and Jest code the tags are also [constants](https://docs.quiesco.dev/api-constants.md): `` `… ${Tag.android}` ``,
`{ tags: [Tag.native, Tag.hardReset] }`.

## Writing tags

```ts Vitest theme={null}
import { Tag, describe, test } from '@quiesco/vitest';

// in the title
test(`the back button closes the sheet ${Tag.android}`, async ({ app }) => {
  await app.pressBack();
});

// or in the tags option
test('Face ID login', { tags: [Tag.native, Tag.hardReset] }, async ({ app }) => {
  await app.device.biometrics.enroll();
});

describe(`settings ${Tag.native}`, () => {
  // runs on Android only: the innermost tag decides
  test(`the back button closes it ${Tag.android}`, async ({ app }) => {
    await app.pressBack();
  });
});
```

```js Jest theme={null}
// Jest has no test options: tags go in the test or describe title
const { Tag } = quiesco;

describe(`settings ${Tag.native}`, () => {
  // runs on Android only: the innermost tag decides
  test(`the back button closes it ${Tag.android}`, async () => {
    await quiesco.app.pressBack();
  });
});
```

```gherkin Cucumber theme={null}
@native
Feature: Settings

  # runs on iOS and Android
  Scenario: Dark mode
    When I turn on dark mode

  # runs on Android only
  @android
  Scenario: The back button closes the settings
    When I press back

  @hard-reset
  Scenario: First launch shows the onboarding
    Then I see the onboarding
```

With Vitest, `quiesco()` declares the platform and browser tags for the `tags` option; declare your own
with `extraTags` ([Vitest](https://docs.quiesco.dev/vitest.md)).

## The innermost level decides

Platform tags can sit on several levels: in Gherkin the feature, a `Rule`, the scenario or an `Examples`
block; with Vitest and Jest a `describe` title and the test. The innermost level that has a platform tag
decides:

* in a feature (or `describe`) tagged `@native`, an untagged test runs on iOS and Android, and a test
  tagged `@android` runs on Android only.

Browser tags follow the same rule, decided apart from the platform tags:

* `@web @webkit` runs on the web in WebKit only;
* a test tagged `@firefox` in a `@chromium` feature runs in Firefox only.

This differs from cucumber-js `--tags`, which matches inherited tags too.

## Renaming the tags

The [`tags`](./config#tags) config renames them:

```ts theme={null}
// quiesco.config.ts
export default defineConfig({
  tags: { web: '@browser', webkit: '@safari' },
});
```

With Vitest, pass the same object to `quiesco({ tags })`.


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