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

Bun · Test runner · all subjects

expect matchers

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

Basic expect matchers in Bun

Bun's expect supports matchers including: toBe(), toBeGreaterThan(), toHaveBeenCalled(), toHaveBeenCalledTimes(), and toMatchSnapshot().

expect.hasAssertions to verify assertions are called

Use `expect.hasAssertions()` to verify that at least one assertion is called during a test. This is especially useful in async tests to ensure assertions actually run. The test fails if no assertions are called.

expect.assertions to verify exact assertion count

Use `expect.assertions(count)` to verify that exactly a specific number of assertions are called during a test. The test fails if the exact count is not met. This helps ensure all assertions run in complex async code with multiple code paths.

Basic matchers in Bun

Basic matchers available: `.not`, `.toBe()`, `.toEqual()`, `.toBeNull()`, `.toBeUndefined()`, `.toBeNaN()`, `.toBeDefined()`, `.toBeFalsy()`, `.toBeTruthy()`, `.toStrictEqual()`

String and Array matchers in Bun

String and Array matchers available: `.toContain()`, `.toHaveLength()`, `.toMatch()`, `.toContainEqual()`, `.stringContaining()`, `.stringMatching()`, `.arrayContaining()`

Object matchers in Bun

Object matchers available: `.toHaveProperty()`, `.toMatchObject()`, `.toContainAllKeys()`, `.toContainValue()`, `.toContainValues()`, `.toContainAllValues()`, `.toContainAnyValues()`, `.objectContaining()`

Number matchers in Bun

Number matchers available: `.toBeCloseTo()`, `.closeTo()`, `.toBeGreaterThan()`, `.toBeGreaterThanOrEqual()`, `.toBeLessThan()`, `.toBeLessThanOrEqual()`

Function and Class matchers in Bun

Function and Class matchers available: `.toThrow()`, `.toBeInstanceOf()`

Promise matchers in Bun

Promise matchers available: `.resolves()`, `.rejects()`

Mock function matchers in Bun

Mock function matchers available: `.toHaveBeenCalled()`, `.toHaveBeenCalledTimes()`, `.toHaveBeenCalledWith()`, `.toHaveBeenLastCalledWith()`, `.toHaveBeenNthCalledWith()`, `.toHaveReturned()`, `.toHaveReturnedTimes()`, `.toHaveReturnedWith()`, `.toHaveLastReturnedWith()`, `.toHaveNthReturnedWith()`

Utility matchers in Bun

Utility matchers available: `.extend`, `.anything()`, `.any()`, `.assertions()`, `.hasAssertions()`

Give your agent this brain