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

test/configuration

136 notes in this subject, read out of this brain and free to use. This is page 3 of 3.

Default test timeout is 5 seconds

The default timeout for each test is 5000ms (5 seconds) if not overridden by the timeout option passed to test() or jest.setTimeout().

Retry flaky tests with test.retry option

Use the retry option to automatically retry a flaky test when it fails. The test passes if it succeeds within the specified number of attempts. Example: test('flaky test', async () => { ... }, { retry: 3 }) retries up to 3 times.

Run test multiple times with test.repeats option

Use the repeats option to run a test multiple times regardless of pass/fail status; the test fails if any iteration fails. Example: { repeats: 20 } runs the test 21 times total (1 initial run + 20 repeats).

Cannot use both retry and repeats on same test

The retry and repeats options are mutually exclusive and cannot be used together on the same test.

Skip tests with test.skip

Use test.skip() to skip individual tests. Skipped tests are not run.

Mark tests as todo with test.todo

Use test.todo() to mark a test as todo. Todo tests are not run by default.

Run todo tests with --todo flag

Pass the --todo flag to bun test to run todo tests and identify which ones pass unexpectedly. Failing todo tests do not cause an error, but passing todo tests are marked as failures.

Run only specific tests with test.only

Use test.only() or describe.only() to run only that test or suite. When only() is used, all other tests are skipped. Run with bun test --only flag.

Conditionally run tests with test.if

Use test.if(condition) to run a test only if the condition is truthy. This is useful for tests that should only run on specific architectures or operating systems.

Skip tests conditionally with test.skipIf

Use test.skipIf(condition) or describe.skipIf(condition) to skip a test or suite if the condition is truthy.

Mark tests as todo conditionally with test.todoIf

Use test.todoIf(condition) or describe.todoIf(condition) to mark a test or suite as TODO if the condition is truthy. Use this to signal 'planned but not implemented yet' versus 'invalid for this target' (which would use skipIf).

Track failing tests with test.failing

Use test.failing() when you know a test is failing but want to track it and be notified when it starts passing. This inverts the test result: a failing test passes, and a passing test fails with a message that it now passes and should be fixed.

Conditional modifiers work on describe blocks

The conditional modifiers .if(), .skipIf(), and .todoIf() work on describe blocks and affect all tests in the suite.

Parametrized tests with test.each

Use test.each(cases) to run the same test with multiple sets of data. Each test case is passed as arguments to the test function. If a table row is an array, each element is passed as an individual argument; if a row is not an array (like an object), it's passed as a single argument.

Parametrized suites with describe.each

Use describe.each(cases) to create a parametrized suite that runs once for each test case, allowing multiple tests within the suite to be executed with each set of data.

Format specifiers for test.each titles

test.each supports format specifiers in test titles: %p (pretty-format), %s (String), %d (Number), %i (Integer), %f (Floating point), %j (JSON), %o (Object), %# (Index of test case), %% (Single percent sign).

Give your agent this brain