SolidJSS
SolidJSโ€ข3y agoโ€ข
41 replies
Guilherme Rosado

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?
describe("Turnstile Component", () => {
    it("renders the Turnstile component", () => {
        createRoot(() => {
            const container = (
                <Turnstile sitekey="" onToken={(t) => {}} />
            ) as HTMLDivElement;

            expect(container.outerHTML).toBe("<div></div>");
      console.log("SCRIPT: ", document.querySelector("#turnstile-script")); // null, onMount creates an element with the id="turnstile-script"
        });
    });
 });
Was this page helpful?