@cjournois/bun-test-setup (0.1.6)

Published 2026-11-17 15:04:35 +00:00 by cjournois

Installation

@cjournois:registry=
npm config set @cjournois:registry=
npm install @cjournois/bun-test-setup@0.1.6
"@cjournois/bun-test-setup": "0.1.6"

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 under dir, except .d.ts files and the exclude globs (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/dom registers happy-dom at http://localhost/; after each test it unmounts what Testing Library rendered and clears localStorage. Leave it out for non-DOM units.

Source

Repository: git.journois.com/cjournois/library

Dependencies

Development dependencies

ID Version
@biomejs/biome 2.6.8
@cjournois/biome-config-ts 2.1.2
@cjournois/eslint-config-ts 2.1.3
@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
Details
npm
2026-11-17 15:04:35 +00:00
1
2026-11-24 17:28:35 +00:00
Corentin JOURNOIS
UNLICENSED
latest
1.7 KiB
Assets (1)
Versions (5) View all
0.1.6 2026-11-17
0.1.5 2026-11-16
0.1.4 2026-11-12
0.1.3 2026-11-12
0.1.2 2026-11-09