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

# 型

> APIリファレンスのメソッドシグネチャに出てくる型：マッチャー、戻り値、オプション、ランナーとアプリ内で使う型。

メソッドのシグネチャに出てくるすべての型と、Quiescoのソースでの宣言です。`import type { … } from '@quiesco/core'` でインポートします。
アプリ内で使う型は `@quiesco/agent`、ランナーのオプションは各ランナーのパッケージから。文字列のユニオン型（`Direction`、`Permission` …）は[定数](https://docs.quiesco.dev/ja/api-constants.md)を見てください。

## マッチャー

### `MatcherInput`

```ts theme={null}
type MatcherInput = ElementQuery | string;
```

### `ElementQuery`

```ts theme={null}
interface ElementQuery {
  /** testID：完全一致の文字列またはRegExp。 */
  id?: TextQuery;
  /** 要素のサブツリーのテキスト（一致する最も深い要素が返される）。 */
  text?: TextQuery;
  /** accessibilityLabel / aria-label。 */
  label?: TextQuery;
  /** accessibilityRole / role。 */
  role?: string;
  /** セマンティック型（`'button'`、`'input'`、`'switch'` …：どのプラットフォームでも同じ）、ホストコンポーネントの型（`'RCTView'`、`'div'`）、または要素をレンダリングするコンポーネントのdisplayName。 */
  type?: SemanticType | (string & {});
  /** 子孫のいずれかが一致する（Detoxの `withDescendant`）。 */
  has?: ElementQuery | string;
  /** 要素自身は一致しない。 */
  not?: ElementQuery | string;
  /** このマッチャーに一致する唯一の要素の内側（Detoxの `withAncestor`）。 */
  within?: ElementQuery | string;
  /** n番目の一致（0始まり）。レンダリング順で、どのプラットフォームでも同じ順序。 */
  index?: number;
}
```

### `TextQuery`

```ts theme={null}
type TextQuery = string | RegExp;
```

## 戻り値

### `ElementSummary`

```ts theme={null}
/** エージェントが一致した要素について返す情報。 */
interface ElementSummary {
  /** ホストコンポーネントの型。例：`RCTView`、`RCTText`、`div`。 */
  type: string;
  testID?: string;
  text: string;
  role?: string;
  label?: string;
  rect: Rect | null;
  visible: boolean;
  /** 要素の面積のうち見えている割合（0–1）：ウィンドウの内側で、かつ内容をクリップするすべての祖先（スクロールビュー、`overflow: hidden`）の内側にある部分。スタイルで非表示のときは0。 */
  visibleRatio: number;
  /** 要素がSEMANTIC_TYPESのいずれかのときの、プラットフォームに依存しない種類。 */
  semanticType?: SemanticType;
  /** 入力フォーカスを持っている（テキスト入力。WebではフォーカスされたDOM要素）。 */
  focused: boolean;
  /** 無効のときfalse（`disabled`、`accessibilityState.disabled`、`aria-disabled`、`editable={false}`）。 */
  enabled: boolean;
  /** スイッチ、チェックボックス、ラジオの選択状態（`accessibilityState.checked`、`aria-checked`、Switchの `value`）。 */
  checked?: boolean | 'mixed';
  /** 現在の値：TextInputのテキスト、Switch / Slider / Pickerの値、または `accessibilityValue`。 */
  value?: JsonValue;
  /** 要素のpropsのうちシリアライズできる部分（関数とReact要素は除かれる）。 */
  props: Record<string, JsonValue>;
}
```

### `Rect`

```ts theme={null}
/** 矩形。プラットフォームの論理単位（Androidはdp、iOSはpt、WebはCSS px）、ウィンドウ座標。 */
interface Rect {
  x: number;
  y: number;
  width: number;
  height: number;
}
```

### `TreeNode`

```ts theme={null}
interface TreeNode {
  type: string;
  testID?: string;
  text?: string;
  role?: string;
  semanticType?: SemanticType;
  /** 丸めた矩形。 */
  rect?: Rect;
  children: TreeNode[];
}
```

### `TrackerState`

```ts theme={null}
/** アイドルトラッカー1つの状態。 */
interface TrackerState {
  name: string;
  idle: boolean;
  /** 人が読めるビジーの理由。例：`GET https://api.example.com/todos (1200ms)`。 */
  busy: string[];
  /** frame-stableは呼び出しが待っている間だけサンプリングするため、同期タイムアウトの後はアイドルと報告する：これは、最後のアイドル待ちが要素ツリーの変化中に終わったときのビジーの理由。 */
  lastWait?: string[];
  /** SYNC_TIMEOUTの中で：このトラッカーはタイムアウト時点ではアイドルだったが、その何ミリ秒か前まではビジーだった。`busy` はそのときのビジーの理由。 */
  idleForMs?: number;
}
```

### `TrackerName`

```ts theme={null}
type TrackerName = 'network' | 'timer' | 'react' | 'idle-callback' | 'frame-stable' | 'native' | 'native-module';
```

## 座標

### `Point`

```ts theme={null}
/** 点：要素自身の座標（`point`）またはウィンドウ座標（`tapAt`）、論理単位。 */
interface Point {
  x: number;
  y: number;
}
```

### `TimedPoint`

```ts theme={null}
/** ある時刻の指の位置：ジェスチャー開始からのミリ秒。 */
interface TimedPoint {
  x: number;
  y: number;
  t: number;
}
```

## 呼び出しのオプション

### `CallOptions`

```ts theme={null}
/** すべてのDriver呼び出しが受け付けるオプション。 */
interface CallOptions {
  /** 呼び出しごとのタイムアウト（エージェント側）。デフォルト：`sync.timeoutMs`。 */
  timeoutMs?: number;
  /** `false`：この呼び出しの前後でアイドルを待たない（無限ループのアニメーションなど）。 */
  sync?: boolean;
}
```

### `ActionOptions`

```ts theme={null}
interface ActionOptions extends CallOptions {
  mode?: ActionMode;
}
```

### `TapOptions`

```ts theme={null}
/** `tap()` のオプション。 */
interface TapOptions extends ActionOptions {
  /** タッチする位置。要素自身の座標（デフォルト：中心）。 */
  point?: Point;
}
```

### `LongPressOptions`

```ts theme={null}
/** `longPress()` のオプション。 */
interface LongPressOptions extends ActionOptions {
  /** 押し続ける時間（デフォルト800 ms）。 */
  durationMs?: number;
  /** タッチする位置。要素自身の座標（デフォルト：中心）。 */
  point?: Point;
}
```

### `LongPressAtOptions`

```ts theme={null}
/** `longPressAt()` のオプション。 */
interface LongPressAtOptions extends ActionOptions {
  /** 押し続ける時間（デフォルト800 ms）。 */
  durationMs?: number;
}
```

### `TypeOptions`

```ts theme={null}
/** `type()` のオプション。 */
interface TypeOptions extends ActionOptions {
  /** ユーザーのように1文字ずつ入力し、アプリがすべてのキー入力を受け取れるようにする（デバウンス付き検索、入力マスク、`onKeyPress`）。デフォルト：テキスト全体を一度に入力。 */
  perCharacter?: boolean;
  /** `perCharacter` と併用：2文字の間隔（デフォルト80 ms）。呼び出しの最後にアイドルを待つ。 */
  intervalMs?: number;
}
```

### `ScrollOptions`

```ts theme={null}
/** `scroll()` のオプション。 */
interface ScrollOptions extends ActionOptions {
  /** スクロールする距離。論理単位。 */
  distance?: number;
  /** 要素内で指が動き始める位置。0–1に正規化（デフォルト：中心付近）。 */
  from?: Point;
}
```

### `ScrollToIndexOptions`

```ts theme={null}
/** `scrollToIndex()` のオプション。 */
interface ScrollToIndexOptions extends ActionOptions {
  /** 行が最終的に来るリスト内の位置：0が上端、0.5が中央、1が下端（FlatListの `viewPosition`）。 */
  viewPosition?: number;
}
```

### `SwipeOptions`

```ts theme={null}
/** `swipe()` のオプション。 */
interface SwipeOptions extends ActionOptions {
  speed?: Speed;
  /** スワイプする距離。論理単位。 */
  distance?: number;
  /** 要素内で指が動き始める位置。0–1に正規化（デフォルト：中心付近）。 */
  from?: Point;
}
```

### `DragOptions`

```ts theme={null}
/** `drag()` のオプション。 */
interface DragOptions extends ActionOptions {
  /** 動かす前に押し続ける時間（デフォルト800 ms：長押しで始まるドラッグに十分）。 */
  holdMs?: number;
  speed?: Speed;
}
```

### `PinchOptions`

```ts theme={null}
/** `pinch()` のオプション。 */
interface PinchOptions extends ActionOptions {
  /** 指が動く直線の角度。ラジアン（デフォルト0：水平）。 */
  angle?: number;
  speed?: Speed;
}
```

### `RotateOptions`

```ts theme={null}
/** `rotate()` のオプション。 */
interface RotateOptions extends ActionOptions {
  speed?: Speed;
}
```

### `MultiTouchOptions`

```ts theme={null}
/** `multiTouch()` のオプション。 */
interface MultiTouchOptions extends ActionOptions {
  /** 点の座標を、ウィンドウではなくこの要素自身の座標にする（要素が見えている必要がある）。 */
  within?: MatcherInput;
}
```

### `VisibleOptions`

```ts theme={null}
interface VisibleOptions extends CallOptions {
  /** 要素の面積のうち見えていなければならない最小の割合。0–1（Detoxの `toBeVisible(75)` は `{ ratio: 0.75 }`）。 */
  ratio?: number;
}
```

### `WaitForIdleOptions`

```ts theme={null}
/** `waitForIdle()` のオプション。 */
interface WaitForIdleOptions {
  /** 待つ時間。デフォルト：`sync.timeoutMs`。 */
  timeoutMs?: number;
}
```

## デバイス

### `RelaunchOptions`

```ts theme={null}
interface RelaunchOptions {
  /** 起動引数（任意のJSON）。設定の `launchArgs` の上にマージされる。`quiesco.launchArgs()` で読む。 */
  args?: LaunchArgs;
  /** このディープリンクでアプリを開く（例：`myapp://todos/1`。Webではそのパスを開く）。 */
  url?: string;
  /** 先にアプリのデータを削除する（ネイティブ：アプリのストレージ、Web：新しいブラウザコンテキスト）。 */
  clearData?: boolean;
  /** 先にアプリをアンインストールしてからインストールする（アプリの `binaryPath` が必要。Web：clearDataと同じ）。 */
  reinstall?: boolean;
  /** 起動前に許可する権限。設定の権限に加えて。 */
  permissions?: Permission[];
}
```

### `StatusBarOptions`

```ts theme={null}
/** きれいなスクリーンショットのためのステータスバーの上書き。設定しないフィールドは実際の値のまま。 */
interface StatusBarOptions {
  /** 時計。`H:MM` / `HH:MM`（例：`9:41`）。 */
  time?: string;
  /** 0–100。 */
  batteryLevel?: number;
  charging?: boolean;
  /** Wi-Fiの電波、0–3本。 */
  wifiBars?: number;
  /** 携帯の電波、0–4本。 */
  cellularBars?: number;
  /** アンテナの横に表示するデータ通信の種類。`hide` で携帯のインジケーターを隠す。 */
  dataNetwork?: 'wifi' | '3g' | '4g' | 'lte' | '5g' | 'hide';
}
```

### `NotificationSpec`

```ts theme={null}
/** `app.device.sendNotification()` に渡す通知。 */
interface NotificationSpec {
  title: string;
  body?: string;
  /** カスタムデータ：iOSではプッシュのペイロードで `aps` の隣に、Androidでは起動インテントのextrasに入る。 */
  data?: Record<string, string>;
}
```

### `OpenNotificationOptions`

```ts theme={null}
/** `app.device.openNotification()` のオプション。 */
interface OpenNotificationOptions {
  /** 通知が届くまで待つ時間（デフォルト10000 ms）。 */
  timeoutMs?: number;
}
```

### `SystemQuery`

```ts theme={null}
/** テキスト（完全一致またはRegExp）と / またはid（完全なid、または `:id/` より後ろの部分）。 */
interface SystemQuery {
  text?: string | RegExp;
  id?: string;
}
```

### `SystemWaitOptions`

```ts theme={null}
interface SystemWaitOptions {
  /** システムUIが表示される（または消える）まで待つ時間。デフォルト10 s。 */
  timeoutMs?: number;
}
```

### `ScreenshotTarget`

```ts theme={null}
/** `app.device.screenshot` が撮る対象：要素、または `fullPage` でスクロールビューの内容全体（`true`：画面上のスクロールビュー）。 */
type ScreenshotTarget = MatcherInput | { fullPage: true | MatcherInput };
```

### `ScreenshotOptions`

```ts theme={null}
/** `app.device.screenshot()` のオプション。 */
interface ScreenshotOptions {
  /** 要素を指定したとき：要素の全体を、スクロールしてつなげて撮る（デフォルトfalse）。 */
  full?: boolean;
  /** PNGをこの名前でシナリオのアーティファクトにも保存する。 */
  name?: string;
}
```

## WebView

### `WebElementQuery`

```ts theme={null}
/** テストに書くWebViewのロケーター：`{ text }` はRegExpも受け付ける。 */
type WebElementQuery = ({ css: string } | { xpath: string } | { id: string } | { text: TextQuery }) & { index?: number };
```

### `PageElement`

```ts theme={null}
interface PageElement {
  tag: string;
  id: string;
  text: string;
  value: string | null;
  visible: boolean;
  disabled: boolean;
  /** ページのCSSピクセル、ビューポートからの相対位置。 */
  rect: { x: number; y: number; width: number; height: number };
}
```

## JSON

### `JsonValue`

```ts theme={null}
type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue };
```

### `JsonPrimitive`

```ts theme={null}
/** JSON.stringify / JSON.parseを通しても変わらない任意の値。 */
type JsonPrimitive = string | number | boolean | null;
```

## アプリ内

### `WithQuiescoOptions`

```ts theme={null}
/** `withQuiesco()` のオプション。 */
type WithQuiescoOptions = {
  enabled?: boolean;
  env?: NodeJS.ProcessEnv;
  projectRoot?: string;
  artifactsDir?: string | false;
  nativeModules?: boolean;
  argv?: readonly string[];
};
```

### `Backdoor`

```ts theme={null}
/** バックドア：ホストから呼べるテスト専用の関数。引数と戻り値はJSONにシリアライズできる必要がある。 */
type Backdoor = (...args: never[]) => unknown;
```

### `StorageAdapter`

```ts theme={null}
/** ソフトリセットのときに永続ストアを1つ消去する（AsyncStorage、MMKV、SecureStore …）。 */
interface StorageAdapter {
  name: string;
  clear(): void | Promise<void>;
}
```

## ランナー

### `QuiescoVitestOptions`

```ts theme={null}
interface QuiescoVitestOptions {
  /** quiesco.configでタグの名前を変えたときのタグ名（そこの `tags`）。 */
  tags?: Partial<TagNames>;
  /** デフォルト300 s（最初のテストにはセッションの開始が含まれる）。 */
  testTimeout?: number;
  /** 追加で宣言する独自のタグ。例：`['@smoke']`。 */
  extraTags?: readonly string[];
  /** 並列ワーカー数。ワーカーごとに専用のデバイスを使う。デフォルト1（直列）。 */
  workers?: number;
}
```

### `RegisterOptions`

```ts theme={null}
interface RegisterOptions extends LifecycleOptions {
  /** 独自のWorldを使う（QuiescoWorldを継承している必要がある）。デフォルトはQuiescoWorld。`typeof QuiescoWorld` ではなく普通のコンストラクタ型：前者はworldパラメーターについてジェネリックで、どのサブクラスも満たせない。 */
  world?: new (options: IWorldOptions<any>) => QuiescoWorld<any>;
  /** ステップのデフォルトのタイムアウト。Driverの呼び出しにはそれぞれ同期タイムアウトがあり、これはステップ全体の上限。デフォルト60 s。 */
  stepTimeoutMs?: number;
  /** BeforeAllのタイムアウト：エミュレーターの起動には数分かかることがある。デフォルト10 min。 */
  setupTimeoutMs?: number;
  /** シナリオごとのリセット（Before）のタイムアウト。アプリがいなければ起動し直すため、接続タイムアウトの最大3倍待つ。デフォルト3 min。 */
  resetTimeoutMs?: number;
}
```

### `LifecycleOptions`

```ts theme={null}
interface LifecycleOptions {
  /** `quiesco.config.*` を読み込む代わりに使う設定（QUIESCO_CONFIGで別のファイルを指定できる）。 */
  config?: QuiescoConfig;
  /** QUIESCO_PLATFORMの代わりに使うプラットフォーム。 */
  platform?: Platform;
  /** セッションのファクトリ（テスト、独自の構成）。 */
  createSession?: (options: SessionOptions) => Promise<Session>;
  env?: NodeJS.ProcessEnv;
  /** このライフサイクルが動く並列ワーカー。ランナーアダプターから渡される：設定関数がこれを受け取り、セッションは専用のデバイス、ポート、アーティファクトディレクトリを使う。デフォルト：唯一のワーカー。 */
  worker?: WorkerInfo;
  /** 繰り返し失敗のヒントの出力先。デフォルト：コンソール。 */
  logger?: Logger;
}
```

### `ScenarioTags`

```ts theme={null}
/** シナリオのタグ：フラットなリスト（1階層）、またはGherkinの階層ごとにまとめたもの。外側が先（feature、rule、scenario、examples）。 */
type ScenarioTags = readonly string[] | readonly (readonly string[])[];
```

### `ScenarioResult`

```ts theme={null}
interface ScenarioResult {
  tags: readonly string[];
  failed: boolean;
  /** 失敗（Error、またはランナーのメッセージ）。同じ失敗の繰り返しを見分けるのに使う。 */
  error?: unknown;
}
```

### `AfterResult`

```ts theme={null}
interface AfterResult {
  /** 添付に対応したランナー向け：スクリーンショット、要素ツリー、ログ … */
  attachments: Attachment[];
  /** このテストのために書き出したファイル（証拠、ログ、動画）：添付に対応していないランナーはこれを表示する。 */
  files: string[];
}
```

### `Attachment`

```ts theme={null}
interface Attachment {
  data: Buffer | string;
  mediaType: string;
  /** 添付に名前を付けるレポーターが表示する。 */
  fileName?: string;
}
```

### `SessionOptions`

```ts theme={null}
interface SessionOptions {
  config: QuiescoConfig;
  platform: Platform;
  logger?: Logger;
  /** デバイスプロバイダーを差し替える（テスト、独自のプロバイダー）。 */
  provider?: DeviceProvider;
  /** このセッションが属する並列テストワーカー：専用のデバイス、サーバーポート（`server.port + index`）、アーティファクトディレクトリ。デフォルト：唯一のワーカー。 */
  worker?: WorkerInfo;
  /** アプリの再接続を待つ間にプロセスを確認する間隔。デフォルト500 ms。 */
  crashPollMs?: number;
}
```

### `WorkerInfo`

```ts theme={null}
/** プロバイダーが担当する並列テストワーカー。ワーカーごとに専用のデバイスが必要。 */
interface WorkerInfo {
  /** 0始まりのワーカー番号。 */
  index: number;
  /** この実行のワーカー数（直列実行のときは1）。 */
  count: number;
}
```

### `ScenarioInfo`

```ts theme={null}
interface ScenarioInfo {
  tags?: readonly string[];
  /** シナリオの名前：アーティファクトディレクトリになる。 */
  name?: string;
}
```

### `ScenarioArtifacts`

```ts theme={null}
interface ScenarioArtifacts {
  /** レポート用：スクリーンショット、ログ、タイムラインの要約はインラインで、動画 / トレースはパスで。 */
  attachments: Attachment[];
  /** このシナリオのために書き出したファイル。 */
  files: string[];
}
```

### `Evidence`

```ts theme={null}
interface Evidence {
  screenshot?: Buffer;
  tree?: TreeNode | null;
  /** 要約した要素リストとルート。 */
  elements?: ResultOf<AgentMethods['listElements']>;
  idle?: TrackerState[];
  /** 収集できなかった項目とその理由。 */
  errors: string[];
  /** アプリがクラッシュした：要素ツリー、リスト、アイドル状態は収集しない。 */
  crash?: QuiescoError;
}
```


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