test.preload
option in bunfig.toml
lets you configure your loader to start before your tests run.
Firstly, install @testing-library/svelte
, svelte
, and @happy-dom/global-registrator
.
terminal
Add this to
bunfig.toml
to tell Bun to preload the plugin, so it loads before your tests run.
bunfig.toml
Add an example
.svelte
file in your project.
Counter.svelte
Now you can
import
or require
*.svelte
files in your tests, and it will load the Svelte component as a JavaScript module.
Use
bun test
to run your tests.
terminal