bestguy / sveltestrap

Bootstrap 4 & 5 components for Svelte
https://sveltestrap.js.org
MIT License
1.3k stars 183 forks source link

Testing components containing Sveltestrap fails tests (using svelte-testing-library) #437

Closed x-GF-x closed 2 years ago

x-GF-x commented 2 years ago

Hello, I have a component I am testing using svelte-testing-library. I am receiving this error:

TypeError: Cannot read property '$$' of undefined
      at tooltipEl (node_modules/sveltestrap/node_modules/svelte/internal/index.mjs:1863:32)
      at new Object.<anonymous>.t.FormGroup (node_modules/sveltestrap/src/Tooltip.svelte:126:18)

When I comment out the Sveltestrap components (FormGroup, InputGroup, Input) the test passes fine. Any help would be appreciated. Thank you.

bestguy commented 2 years ago

Hi, we are using @testing-library/svelte in this library without issues:

https://github.com/bestguy/sveltestrap/blob/master/src/__test__/Alert.spec.js#L2

Can you send a repo or sample of the test that is failing?

x-GF-x commented 2 years ago

Of course, here you go: https://github.com/x-GF-x/svelte_test_issue

bestguy commented 2 years ago

Hi, I think you need to make this repo public, seeing a 404

x-GF-x commented 2 years ago

Sorry about that, it should be working now.

bestguy commented 2 years ago

Hi @x-GF-x , Not sure the cause yet, but this seems to have started with sveltestrap@5.8.2.
As a temporary workaround you can revert to 5.8.1 as there should be no functional changes: npm install sveltestrap@5.8.1

I'll do some further comparisons and try and get a new release out asap if I can find the issue, thanks for the heads up

x-GF-x commented 2 years ago

Hey, no problem at all. Thanks for the help!

bestguy commented 2 years ago

Looks like this should be fixed by #438 , released as sveltestrap@5.8.4 if you'd like to confirm and close this issue

x-GF-x commented 2 years ago

@bestguy The fix works so I'll go ahead and close. Thanks for the prompt response and the great library.