@cjournois/bun-test-setup (0.1.5)
Published 2026-11-16 06:01:52 +00:00 by cjournois
Installation
@cjournois:registry=npm config set @cjournois:registry=npm install @cjournois/bun-test-setup@0.1.5"@cjournois/bun-test-setup": "0.1.5"About this package
@cjournois/bun-test-setup
Shared bun test preloads. Bun's coverage only reports files a test imported, so every unit imports
all of its sources up front; and DOM units register happy-dom and clean up after each test.
Proprietary — Copyright (c) 2026 cjournois. All rights reserved. SPDX: UNLICENSED. See LICENSE for terms.
Install
bun add -d @cjournois/bun-test-setup
# DOM units also need
bun add -d @happy-dom/global-registrator @testing-library/react
Usage
# bunfig.toml
[test]
preload = ["@cjournois/bun-test-setup/dom", "./test/bun-preload.ts"]
// test/bun-preload.ts
import { importAllSources } from '@cjournois/bun-test-setup';
await importAllSources(new URL('../src', import.meta.url).pathname, { exclude: ['main.tsx'] });
importAllSources(dir, { glob, exclude })imports every**/*.{ts,tsx}file underdir, except.d.tsfiles and theexcludeglobs (entry points that render or listen on import). A source that throws fails the preload instead of silently leaving the file out of coverage. It resolves to the imported modules by relative path.@cjournois/bun-test-setup/domregisters happy-dom athttp://localhost/; after each test it unmounts what Testing Library rendered and clearslocalStorage. Leave it out for non-DOM units.
Source
Repository: git.journois.com/cjournois/library
Dependencies
Development dependencies
| ID | Version |
|---|---|
| @biomejs/biome | 2.6.7 |
| @cjournois/biome-config-ts | 2.1.1 |
| @cjournois/eslint-config-ts | 2.1.2 |
| @eslint/js | 10.0.1 |
| @happy-dom/global-registrator | 21.0.4 |
| @hughescr/stryker-bun-runner | 1.6.0 |
| @stryker-mutator/core | 10.1.1 |
| @testing-library/react | 16.3.3 |
| @types/bun | 1.4.4 |
| @types/react | 19.3.0 |
| eslint | 10.15.0 |
| react | 19.3.1 |
| react-dom | 19.3.1 |
| tsdown | 0.23.7 |
| typescript | 6.0.3 |
| typescript-eslint | 8.72.2 |
Peer dependencies
| ID | Version |
|---|---|
| @happy-dom/global-registrator | ^21.0.0 |
| @testing-library/react | ^16.3.0 |