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

Vitest · API reference · all subjects

hooks and meta

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

test.extend fixtures with scope option

Fixtures defined with test.extend can now specify a scope option with values 'file' or 'worker'. The file scope is similar to beforeAll and afterAll at the file top level but only executes if the fixture is used. The worker scope initiates once per worker, but by default Vitest creates one worker per test, so isolation must be disabled to benefit from worker scope.

test.extend supports type-aware hooks

When using test.extend with lifecycle hooks like beforeEach and afterEach, you can now reference them directly on the returned test object. These hooks are aware of the extended context and can access the fixture values. Example: test.beforeEach(({ todos }) => { todos.push(1) })

aroundEach hook wraps individual tests with context

The aroundEach hook registers a callback function that wraps around each test within the current suite. The callback receives a runTest function that must be called to run the test. Use aroundEach when tests need to run inside a context that wraps around them, such as AsyncLocalStorage context, tracing spans, or database transactions. Example: test.aroundEach(async (runTest, { db }) => { await db.transaction(runTest) }).

aroundAll hook wraps all tests in a suite

The aroundAll hook works similarly to aroundEach but is called for every suite, not every test. It registers a callback function that wraps around each suite and receives a runTest function that must be called to run the suite.

beforeAll, afterAll and aroundAll hooks receive file and worker contexts

Vitest now passes down file and worker contexts to beforeAll, afterAll and aroundAll hooks, allowing access to fixtures scoped at file or worker level within these hooks.

Give your agent this brain