new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Playwright · Test runner API · all subjects

fixtures

6 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Fixtures concept and purpose

Playwright Test is based on test fixtures that establish an environment for each test. Fixtures give a test everything it needs and nothing else. Playwright Test analyzes the set of fixtures each test needs and prepares those fixtures specifically for that test. Values prepared by fixtures are merged into a single object available to the test, hooks, annotations, and other fixtures as a first parameter.

Built-in fixtures available

Playwright Test comes with built-in fixtures: browser, browserName, context, page, request, and mount. Additional custom fixtures can be added.

Fixtures are configurable via TestOptions

Playwright Test provides options to configure the browser, context, and page fixtures through TestOptions.

test.extend() creates custom test object

test.extend() extends the test object by defining fixtures and/or options. It returns a new Test object. Fixtures and options are defined as an object where each key is a fixture/option name and value is either a default value (for options as [value, { option: true }]) or an async function (for fixtures). Fixtures can use built-in fixtures and options. Options can be overridden in the config file.

test.use() specifies options or fixtures

test.use() specifies options or fixtures for a test file or test.describe() group. Can be called at global scope or inside test.describe(), but not within beforeEach or beforeAll. Can override fixtures by providing a function. Returns the options to apply locally.

test.extend() fixture definition example

import { test as base } from '@playwright/test'; import { TodoPage } from './todo-page'; export type Options = { defaultItem: string }; export const test = base.extend<Options & { todoPage: TodoPage }>({ defaultItem: ['Do stuff', { option: true }], todoPage: async ({ page, defaultItem }, use) => { const todoPage = new TodoPage(page); await todoPage.goto(); await todoPage.addToDo(defaultItem); await use(todoPage); await todoPage.removeAll(); }, });

Give your agent this brain