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 · all subjects

authentication/worker-isolation

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

Moderate authentication strategy with one account per parallel worker

For tests that modify server-side state, use one account per parallel worker. Create a `playwright/fixtures.ts` file that extends the test with a worker-scoped `workerStorageState` fixture. Use `test.info().parallelIndex` to differentiate between workers. Each worker authenticates once with a unique account and reuses that state for all its tests.

Worker fixture example for one account per parallel worker

Example `playwright/fixtures.ts` for worker-scoped authentication: ```js import { test as baseTest, expect } from '@playwright/test'; import fs from 'fs'; import path from 'path'; export * from '@playwright/test'; export const test = baseTest.extend<{}, { workerStorageState: string }>({ storageState: ({ workerStorageState }, use) => use(workerStorageState), workerStorageState: [async ({ browser }, use) => { const id = test.info().parallelIndex; const fileName = path.resolve(test.info().project.outputDir, `.auth/${id}.json`); if (fs.existsSync(fileName)) { await use(fileName); return; } const page = await browser.newPage({ storageState: undefined }); const account = await acquireAccount(id); await page.goto('https://github.com/login'); await page.getByLabel('Username or email address').fill(account.username); await page.getByLabel('Password').fill(account.password); await page.getByRole('button', { name: 'Sign in' }).click(); await page.waitForURL('https://github.com/'); await expect(page.getByRole('button', { name: 'View profile and more' })).toBeVisible(); await page.context().storageState({ path: fileName }); await page.close(); await use(fileName); }, { scope: 'worker' }], }); ``` Test files must import `test` from the fixtures file instead of `@playwright/test`.

Give your agent this brain