Files
e2e/docs/reference/app.mdx
T

67 lines
2.8 KiB
Plaintext

---
title: app
description: The portable app lifecycle fixture, available on every platform.
---
Every `app` method exists on every platform. The engine implements each; the
runner owns the timeouts.
```ts
export interface App {
/**
* The resolved base URL of the target's app, with the port the run
* allocated when the engine declared port 0; undefined for a surface whose
* engine declares no `url`.
*/
readonly baseUrl: string | undefined;
/** Opens the app: the declared URL, a path relative to it, or any absolute http(s) URL. */
open(path?: string): Promise<void>;
/**
* Recreates the execution context while preserving persisted state, then
* reopens the app at its base URL when the engine declares one.
*/
restart(): Promise<void>;
/**
* Clears persisted client state, recreates the execution context, then
* reopens the app at its base URL when the engine declares one.
*/
clearState(): Promise<void>;
/** Navigates back once. */
back(): Promise<void>;
/** Captures a redacted evidence screenshot. */
screenshot(label?: string): Promise<string>;
}
```
No `App` method takes a `timeout` option. Each budget is additionally capped
by the remaining test timeout.
| Method | Timeout | Throws |
| --- | --- | --- |
| `open(path?)` | `config.timeout`, 120000 ms | `APP_URL_REQUIRED` when the engine declares no `url`, `POLICY_DENIED` for a `file:`, `data:`, or `javascript:` URL, `APP_UNREACHABLE`, `ACTION_FAILED`, `UNSUPPORTED_CAPABILITY` without `session.open` |
| `restart()` | `config.timeout`, 120000 ms | `ACTION_FAILED`, `ENGINE_FAILURE`, `UNSUPPORTED_CAPABILITY` without `session.restart` |
| `clearState()` | `config.timeout`, 120000 ms | `ACTION_FAILED`, `ENGINE_FAILURE`, `UNSUPPORTED_CAPABILITY` without `session.reset` |
| `back()` | `config.actionTimeout`, 30000 ms | `APP_NOT_OPEN`, `ACTION_FAILED`, `UNSUPPORTED_CAPABILITY` without `session.back` |
| `screenshot(label?)` | `config.actionTimeout`, 30000 ms | `POLICY_DENIED` after a secret fill, `UNSUPPORTED_CAPABILITY`, `ENGINE_FAILURE` |
`screenshot` registers the file as an attempt artifact and returns its path
relative to the artifact root; `label` names the step and joins the file
name.
```ts
await app.open('/settings/billing');
const shot = await app.screenshot('after-checkout');
```
<Warning>
`clearState` inside a serial group destroys the shared state the group
depends on. Use it in `beforeEach` of an ordinary group instead.
</Warning>
Once a `Secret` has been filled, pixels are withheld for the rest of the
session, including later tests in a serial group. `app.screenshot()` then
fails with `POLICY_DENIED` and creates no artifact.
Browser-only operations live on the [`web`](/reference/playwright) fixture;
device operations on [`device`](/reference/agent-device).