Skip to main content
Quiesco has adapters for Cucumber, Vitest and Jest (test runners). This page describes what the Vitest and Jest adapters do, and how to use @quiesco/core directly from any other runner (Mocha, a plain script).

Vitest and Jest

@quiesco/vitest and @quiesco/jest behave like the Cucumber adapter. Examples are in Vitest, Jest and examples/todo-app/e2e. Details:
  • The innermost level with a platform tag decides, as in Gherkin: a test tagged @android in a describe('… @native') runs on Android only (test tags).
  • A session that fails to start fails the remaining tests at once, instead of starting again for each.
  • With Jest, a config’s own globalTeardown replaces the preset’s: call @quiesco/jest/teardown from it (see the example app).
  • The first test of a Vitest run also waits for the session to start, and booting a device can take minutes: quiesco() sets testTimeout to 300 s for that reason.

Lifecycle

Any other runner uses @quiesco/core directly. Lifecycle maps a run onto four calls; the adapters above are thin layers over it.

new Lifecycle(options?)

Types: LifecycleOptions

beforeAll()

Loads the config, starts the server and the device, installs and launches the app, and waits for the agent to connect.

before(tags, name?)

Types: ScenarioTags Before each test. Returns 'skipped' for a test tagged for another platform or browser (or once the run bailed out after repeated identical failures, bailOnRepeatedFailure); otherwise it starts the test’s artifacts and resets the app. Pass the tags grouped by level, outermost (suite / feature) first, so the innermost platform tag decides.

current

The running session; lifecycle.current.driver is the driver. Throws when beforeAll did not complete.

after({ tags, failed, error? })

Types: ScenarioResult · AfterResult After each test. On failure it collects the evidence; with the artifacts policy it also keeps video, logs and timeline. It returns { attachments, files }: attachments for runners with a report that takes them, the files written for runners that print paths. Pass error (an Error or the runner’s message) so repeated identical failures can be told apart. A test that passed still fails (after throws) when the app reported an error after its last step.

afterAll()

Closes the connection, the app and the device (per config).

titleTags(title)

The tags written in a test or suite title.

The session

Below Lifecycle is the session itself, for full control: tags and skipping are then up to you.

createSession({ config, platform, worker?, logger? })

Types: SessionOptions · Session Starts the server, boots the device, installs and launches the app, and waits until the agent connects. worker ({ index, count }, default the only worker) gives the session its own device, server port (server.port + index) and artifacts directory.

startScenario({ name })

Types: ScenarioInfo Starts a test’s artifacts (timeline, video) in a directory named after it. Call it before beforeScenario, so the reset is part of the video.

beforeScenario({ tags?, name? })

Types: ScenarioInfo Undoes the previous test’s runtime sync and device changes, brings a backgrounded app back or starts a terminated one, then soft resets the app, or terminates and relaunches it for @hard-reset (or reset.default: 'hard'). If the app crashed or stopped answering, it is started again.

afterScenario({ failed })

Types: ScenarioArtifacts Ends the test. On failure: the framed screenshot, element tree and idle state; plus video, logs and timeline per the artifacts policy. Returns { attachments, files }.

collectEvidence()

Types: Evidence Returns the failure evidence alone, without writing artifacts: screenshot, tree, elements, idle, and errors for any piece it could not collect (after a crash, the screenshot and crash only).

dispose()

At the end: undoes the last test’s device changes and closes the app. The device keeps running unless devices.*.shutdown is set.

Running

One session drives one device; for parallel runs each worker has its own, with its worker index. quiesco test --runner cucumber|jest|vitest sets QUIESCO_PLATFORM and starts the runner. For other runners, set QUIESCO_PLATFORM (or pass the platform to resolvePlatform) and start the runner yourself: