Unit test failed when component has svelte-multiselect
See original GitHub issueHi @janosh, I like to thank you for creating such a great component! I love it!
Everything works great so far (v4.0.0) in my svelte app until I tried to add some unit tests.
Test failed when I tested component which has svelte-multiselect, Jest threw error (Vitest broke right away) like this:

I’d already setup transformers so it’s not a ESM problem in Jest, and other tests passed with different svelte libraries.
Here is a reproducible repo that you can check: https://github.com/davipon/test-failed I simply import svelte-tiny-virtual-list & svelte-multiselect in the same test file and try to render them. Test would fail before rendering Multiselect:
test('render multiselect', () => {
render(Multiselect, { options: webFrameworks });
});
I’m not familiar with creating Svelte package, but I found a difference in these two libraries’ index.js:
svelte-tiny-virtual-list:

svelte-multiselect:

Not sure if information above can help, and thanks again for your hard work!
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)

Top Related StackOverflow Question
I also tried
transformmodebut it failed as well.Anyway, I asked in Vitest Discord channel and got the answer! We need to use
dep.inlinein Vitest:Now we know how to deal with transpiling errors when unit testing most of the Svelte component packages (I believe) in both Jest and Vitest, I’ll create a PR to add a Unit Test section in README with examples.
Thanks again @janosh, your comments really helped me to dig in and find the root cause, please kindly close this issue, have a good one!
Thanks. Could you link this issue over there? I’d like to subscribe to your
vitestissue.Indeed which is why I’m very curious to hear if there’s a recommended solution.
Sure that would be great!