Skip to content
API reference / 02

Context lifecycle and server helpers.

Context ​

The Context object manages the browser session lifecycle and server-side helpers.

In Laravel tests, access it as $this->context.

Browser lifecycle ​

  • $context->createBrowserShim(options?, shimOptions?) creates a Browser shim around a page in a new browser context. The first argument configures browser creation; the second configures shim options such as timeouts.
  • $context->destroy(options?) tear down the context (supports delayed destroy).

Test status ​

  • $context->testFailed() mark the test as failed.
  • $context->testSuccess() mark the test as success.
  • $context->testSucceeded() alias for success.

Snapshots ​

  • $context->getSnapshotsByType(type) return snapshots for a given type.

Temporary files ​

  • $context->saveTemporaryFile(name, content) uploads base64-encoded content to a temporary file on the server and returns its path. The file is removed during context cleanup.

Portal settings ​

The portal and detour options are set when the context is created and cannot be changed afterwards. See portal and detours for the options and each client's defaults.