.svelte files, and the test.preload option in bunfig.toml to load it before your tests run.
First, install @testing-library/svelte, svelte, and @happy-dom/global-registrator.
terminal
Add this to
bunfig.toml so Bun preloads the plugin 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. Bun loads each Svelte component as a JavaScript module.
Use
bun test to run your tests.
terminal