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

# 测试运行器

> Vitest（推荐）、Jest 或 Cucumber：整个运行共用一个会话，每个测试前重置，失败时留下证据。

Quiesco 通过你的测试运行器驱动 App。有三个运行器提供现成的集成，用法都一样：整个运行共用一个会话（设备和 App），每个测试前执行重置，跳过标记为其他平台或浏览器的测试（`@ios`、`@android`、`@web`、`@native`、`@chromium`、`@firefox`、`@webkit`；最内层的标记生效），失败消息会列出证据文件（截图、元素树、空闲状态、日志）。

| 运行器 | 包 | 测试 | App |
| - | - | - | - |
| **Vitest**（推荐） | `@quiesco/vitest` | TypeScript，`test(…)` | `app` fixture |
| Jest | `@quiesco/jest` | JavaScript，`test(…)` | 全局 `quiesco.app` |
| Cucumber | `@quiesco/cucumber` | Gherkin feature 和步骤定义 | 步骤中的 `this.app` |

## 选择运行器

`quiesco init` 会询问使用哪个运行器（默认选中 Vitest；在 CI 中不询问，直接用 Vitest），并且只安装该运行器的包、配置和第一个测试。想跳过询问直接指定：

```sh pnpm theme={null}
# 或 jest、cucumber
pnpm dlx quiesco init --runner vitest
```

```sh npm theme={null}
# 或 jest、cucumber
npx quiesco init --runner vitest
```

```sh bun theme={null}
# 或 jest、cucumber
bunx quiesco init --runner vitest
```

```sh yarn theme={null}
# 或 jest、cucumber
yarn dlx quiesco init --runner vitest
```

之后 `quiesco test`、`quiesco ui` 和 `quiesco list` 会使用已安装了 Quiesco 包的那个运行器，因此不需要 `--runner`。如果安装了多个（或一个都没有），则与 Quiesco 0.6 及更早版本一样使用 Cucumber；用 `--runner` 可以指定其他运行器。

## 配置方法

每个运行器的配置方法各有一页：

> [card] [Vitest](https://docs.quiesco.dev/zh/vitest.md)
>
> vitest.config.mts、quiesco() 的选项和 app fixture

> [card] [Jest](https://docs.quiesco.dev/zh/jest.md)
>
> preset、jest.config.cjs 和全局 quiesco

> [card] [Cucumber](https://docs.quiesco.dev/zh/cucumber.md)
>
> cucumber.mjs、registerQuiesco() 的选项和 World

## 运行

用 `npx quiesco test --platform ios` 运行测试（要使用已安装之外的运行器，加 `--runner vitest|jest|cucumber`），也可以用 [`quiesco ui`](./ui) 在浏览器中运行。三种示例都在 [examples/todo-app](https://github.com/h2nology/quiesco/tree/main/examples/todo-app) 中；详情见 [Vitest、Jest 和其他运行器](https://docs.quiesco.dev/zh/api-custom-runners.md)，多台设备同时运行见[并行运行](https://docs.quiesco.dev/zh/parallel.md)。


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