allwright

API ReferenceTypeScriptVitest

Vitest

@allwright.dev/vitest layers Playwright-style test fixtures and retrying, negatable assertions on top of @allwright.dev/core, so a spec file never touches launch/config plumbing directly.

test

FunctionSince v0.0.24

A Vitest test extended with lazy page/browser/android/androidApp fixtures — nothing launches or connects until a fixture's method is first awaited.

test(name: string, fn: (ctx: { page: Page; browser: Browser; android: MobileAndroidDevice; androidApp: MobileAndroidApp }) => Promise<void>): void

Example

import { expect, test } from "@allwright.dev/vitest";

test("opens a page", async ({ page }) => {
  await page.goto("https://themoderninternet.vercel.app");
});

expect

FunctionSince v0.0.24

Vitest's expect, augmented: called with a Page/Locator (web or Android) it returns retrying matchers — toHaveText, toContainText, toHaveCount, toBeVisible — instead of the plain-value assertions it returns for anything else.

expect(actual: Page | MobileAndroidApp): PageExpectMatchers
expect(actual: Locator | MobileAndroidLocator): LocatorExpectMatchers

Negated assertions

MethodSince v0.1.3

Every matcher supports both the property form .not and the callable form .not() — matchers are immutable, so a second .not toggles back to positive.

expect(locator).not.toHaveText(expected)
expect(locator).not().toBeVisible()

Example

await expect(page.getByTestId('spinner')).not().toBeVisible();
await expect(page).not.toHaveCount('.error', 1);

allwrightVitestConfig

FunctionSince v0.0.57 – v0.0.58

Wraps a Vitest config to start the allwright engine once before the whole run and shut it down once after, instead of every test bootstrapping its own.

function allwrightVitestConfig<T extends UserConfig>(config: T): T

Example

import { allwrightVitestConfig } from "@allwright.dev/vitest/config";
export default allwrightVitestConfig(defineConfig({ test: {} }));