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

bun apis/testing

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

Testing module: bun:test

Bun provides a built-in testing framework through the bun:test module.

bunfig.toml test.root setting

In the [test] section, the root field specifies the root directory to run tests from. Default is ".".

bunfig.toml test.preload setting

In the [test] section, the preload field works like the top-level preload field but only applies to bun test. Example: [test] preload = ["./setup.ts"].

bunfig.toml test.pathIgnorePatterns setting

In the [test] section, pathIgnorePatterns excludes files and directories from test discovery using glob patterns. Matched directories are pruned during scanning so their contents are never traversed. Example: pathIgnorePatterns = ["vendor/**", "submodules/**", "fixtures/**"]. Equivalent CLI flag: --path-ignore-patterns which overrides the bunfig.toml value entirely.

bunfig.toml test.smol setting

In the [test] section, the smol field works like the top-level smol field but only applies to bun test.

bunfig.toml test.coverage setting

In the [test] section, the coverage field enables coverage reporting. Default is false. Use --coverage to override.

bunfig.toml test.coverageThreshold setting

In the [test] section, coverageThreshold sets the coverage threshold as a decimal (e.g., 0.9 for 90%). Default is null (no threshold). If the test suite does not meet it, bun test exits with a non-zero exit code. Can also use object syntax for separate thresholds: coverageThreshold = { lines = 0.7, functions = 0.8, statements = 0.9 }.

bunfig.toml test.coverageSkipTestFiles setting

In the [test] section, coverageSkipTestFiles is a boolean that controls whether to skip test files when computing coverage statistics. Default is false.

bunfig.toml test.coverageIgnoreSourcemaps setting

In the [test] section, coverageIgnoreSourcemaps is a boolean that controls whether to report coverage against transpiled output instead of remapping line numbers through sourcemaps back to the original source. Default is false. Primarily useful for debugging.

bunfig.toml test.coveragePathIgnorePatterns setting

In the [test] section, coveragePathIgnorePatterns excludes files from coverage reports using glob patterns. Accepts a single pattern or an array of patterns. Example: coveragePathIgnorePatterns = ["**/*.spec.ts", "**/*.test.ts", "src/utils/**", "*.config.js"].

bunfig.toml test.coverageReporter setting

In the [test] section, coverageReporter configures how coverage reports are output. By default, coverage reports are printed to console. For persistent reports that CI and other tools can read, use: coverageReporter = ["text", "lcov"]. Default is ["text"].

bunfig.toml test.coverageDir setting

In the [test] section, coverageDir sets the path where coverage reports are saved. Default is "coverage". This only applies to persistent reporters like lcov.

bunfig.toml test.randomize setting

In the [test] section, randomize is a boolean that runs tests in random order. Default is false. Running tests in different order helps catch bugs related to test interdependencies. The --randomize CLI flag overrides this.

bunfig.toml test.seed setting

In the [test] section, seed sets the random seed for test randomization. This option requires randomize to be true. A seed makes the randomized test order reproducible across runs, which helps when debugging flaky tests. The --seed CLI flag overrides this.

bunfig.toml test.rerunEach setting

In the [test] section, rerunEach re-runs each test file a specified number of times. Default is 0 (run once). Use this to catch flaky tests or non-deterministic behavior. The --rerun-each CLI flag overrides this.

bunfig.toml test.retry setting

In the [test] section, retry sets the default retry count for all tests. Failed tests are retried up to this many times. Per-test { retry: N } overrides this value. Default is 0 (no retries). The --retry CLI flag overrides this.

bunfig.toml test.concurrentTestGlob setting

In the [test] section, concurrentTestGlob is a glob pattern where test files matching it run all their tests concurrently, as if the --concurrent flag was passed. Example: concurrentTestGlob = "**/concurrent-*.test.ts". Use this to migrate a test suite to concurrent execution gradually or to run integration tests concurrently while keeping unit tests sequential. The --concurrent CLI flag overrides this.

bunfig.toml test.onlyFailures setting

In the [test] section, onlyFailures is a boolean that when enabled, displays only failed tests in the output to reduce noise in large test suites. Default is false. Equivalent to the --only-failures flag.

bunfig.toml test.reporter.dots setting

In the [test.reporter] section, dots is a boolean that enables the dots reporter, which prints one dot per test. Default is false.

bunfig.toml test.reporter.junit setting

In the [test.reporter] section, junit enables JUnit XML reporting and specifies the output file path. Example: junit = "test-results.xml". CI systems and other tools can consume the report.

Give your agent this brain