Writing tests
A second person
Open another user's browser in the same test, for chat, sharing and anything one person sees another do.
Some features need two people: a teammate sees a message the moment it's posted, an invite
arrives, a shared document updates. users.open(name) opens another person's browser beside the
test's own, so one test covers both sides.
Open a second browser
import { test } from "@danwo/sdk"
test("a teammate sees a post the moment it is made", async ({ app, screen, expect, users }) => {
const bob = await users.open("bob", { session: "bob" })
await bob.app.open("/")
await app.open("/")
await screen.getByRole("textbox", { name: "Message" }).fill("Lunch at noon")
await screen.getByRole("button", { name: "Post" }).click()
await bob.expect(bob.screen.getByText("Lunch at noon")).toBeVisible()
})bob has the same fixtures a test does, each scoped to that browser:
On bob | Works like |
|---|---|
app, screen | the test's own, in Bob's browser |
expect, agent | checks and agent steps on his pages |
mail, secret | his mail and the run's secrets |
Pass { session } to start Bob from a saved session. Leave it out to start
signed out.
What both browsers share
| Shared | Separate |
|---|---|
| the proxy and every emulator | cookies, storage and tabs |
the clock: time.travel moves both | their video and steps in the record |
| your app and its database | the session each one starts from |
A name is up to 40 letters, digits, dots, underscores or dashes, and each name opens once per
test. Call bob.close() to close that browser early. Every browser closes when the test ends.
In the record
The flight record tags each step, call, socket and console line with its person. Each person
gets their own video, so the player shows bob · tab 1 beside you · tab 1. Go to on Bob's
step switches to that video.
In the matrix
A socket Bob's browser opened is faulted for Bob alone. Run only those trials with a filter:
npx @danwo/cli matrix tests/chat.danwo.ts --faults "for bob"The trial reads like connection dropped on WS <host>/<path> for bob.
users.open isn't supported on Android yet. It fails with CONFIG_INVALID.