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

writing tests & expect

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

diff flags customize diff output

Diff configuration flags: `--diff.aAnnotation` (expected annotation, default: Expected), `--diff.aIndicator` (expected indicator, default: -), `--diff.bAnnotation` (received annotation, default: Received), `--diff.bIndicator` (received indicator, default: +), `--diff.commonIndicator` (common indicator, default: space), `--diff.contextLines` (context lines, default: 5), `--diff.emptyFirstOrLastLinePlaceholder` (placeholder, default: empty string), `--diff.expand` (expand all common lines, default: true), `--diff.includeChangeCounts` (include change counts, default: false), `--diff.omitAnnotationLines` (omit annotations, default: false), `--diff.printBasicPrototype` (print basic prototype, default: true), `--diff.maxDepth` (depth limit, default: 20), `--diff.truncateThreshold` (lines to show, default: 0), `--diff.truncateAnnotation` (truncation annotation, default: ... Diff result is truncated).

expect.requireAssertions flag requires at least one assertion

The `--expect.requireAssertions` CLI flag requires that all tests have at least one assertion.

expect.poll.interval flag sets poll interval

The `--expect.poll.interval <interval>` CLI flag sets the poll interval in milliseconds for `expect.poll()` assertions. Default is `50`.

expect.poll.timeout flag sets poll timeout

The `--expect.poll.timeout <timeout>` CLI flag sets the poll timeout in milliseconds for `expect.poll()` assertions. Default is `1000`.

Unawaited asynchronous assertions fail the test

In Vitest 5.0, asynchronous assertions like resolves, rejects, and toMatchFileSnapshot now fail the test if not awaited. In Vitest 4, they were auto-awaited at the end of test with a warning. The reported error points to the unawaited assertion.

Test titles use pretty-format instead of loupe

In Vitest 5.0, test titles and inspected values are formatted with pretty-format instead of loupe. String values interpolated through $ placeholders are no longer wrapped in quotes. The length limit for interpolated values is controlled by taskTitleValueFormatTruncate option (default 40).

Test names use > separator in Vitest

Vitest joins test names with '>' symbol to distinguish tests from suites: 'describeTitle > testTitle'. Jest uses an empty space. This affects expect.getState().currentTestName and testNamePattern matching.

Give your agent this brain