How do I test this behavior?
I want to test the following behavior but I think there's no DOM tree here, right? When we're testing SolidJS components how do I visualize the current tree?
26 Replies
How are you testing this? I would advise to use vitest + jsdom +
@solidjs/testing-library
using jsdom as environment, you can expect a dom tree (though timing might be an issue).Hmmm I'm only using vitest, I'll take a look 💪
Do you have any example that already incorporates both? Any github repo
Already found it
yes.
I think I got this 💪
Thanks
If you have any issues with our testing-library, please ping me, I'm the maintainer 🙂
@lexlohr This is not related to the library, but I'm pretty much stuck. I'm trying to test a
<script>
that is loaded async
and is injected on the head
of the DOM tree. This script is suposed to fetch the turnstile
widget and then I can execute window.turnstile.render
. The test hangs on loading the scripts (5 seconds limit)
Do you have any experience when testing something like this?Testing library has waitFor for those cases.
Yeah!
The
turnstile
isn't injected into the window
object
Maybe this isn't possible to test? window behaves differently on jest
env?Not that much usually.
Have you tried https://github.com/solidjs-community/solid-primitives/blob/main/packages/script-loader/README.md ?
GitHub
solid-primitives/README.md at main · solidjs-community/solid-primit...
A library of high-quality primitives that extend SolidJS reactivity. - solid-primitives/README.md at main · solidjs-community/solid-primitives
Deam
Pretty neat
Will check it out
Hope it'll help.
We try to cover all the bases 😉
Hehe I've seen 🙂
Currently using lot of solid, it's been an awesome experience!
Happy to hear that.
Really love using the Real DOM, then I can just hammer on the
gsap
and other client-side libraries
Yeah! It isn't injecting the turnstile
property on window
You can use onError to check if something went amiss.
I gave up
I'll try later on 🥲
I'll be back in ~5h, if you want, I can do some pair-programming with you then.
Ups! I'm sorry just answering now.
Well that would be awesome.
If you're still up to!
I'm currently a bit busy, will ping you when I'm ready.
🙌
OK, I'm available now.
At least for the next 30-45 minutes.
Alright! What voice channel should we go?
https://app.gotomeeting.com/?meetingId=779414933
That's my personal GoToMeeting (until this year, I developed on that product myself).
Uh nice!
GitHub
Testing script-loader in a jsdom environment is problematic · Issue...
Needs: testing, documentation.