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

expect api completeness

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.

Matchers type for custom matcher extension

Vitest provides a Matchers type that can be extended to add type support for custom matchers in one place. This type affects expect().to*, expect.to*, and expect.extend({ to* }) use cases. Users can declare a module augmentation extending the Matchers interface from 'vitest' to provide type-safe custom matchers.

vi.defineHelper for better stack traces

The vi.defineHelper function wraps a helper function so that Vitest removes its internals from the stack trace and points errors back to the call site instead of the helper implementation. This is useful for custom assertion libraries and reusable test utilities.

mockThrow and mockThrowOnce API methods

The mockThrow and mockThrowOnce methods provide a concise way to make mocks throw errors. mockThrow makes a mock throw an error on every call, while mockThrowOnce makes it throw only on the next call. These are alternatives to using mockImplementation with a throw statement.

expect.assert in Vitest 4

Vitest 4 exposes expect.assert which provides access to Chai's assert methods. This is useful for type narrowing since expect.to* methods do not support narrowing.

expect.schemaMatching asymmetric matcher

Vitest 4 introduces expect.schemaMatching, an asymmetric matcher that accepts a Standard Schema v1 object and validates values against it. It can be used in equality matchers like toEqual, toStrictEqual, toMatchObject, toContainEqual, toThrow, toHaveBeenCalledWith, toHaveReturnedWith, and toHaveBeenResolvedWith.

Give your agent this brain