solid-testing-library
solid-testing-library copied to clipboard
<div> required to wrap <For each> in order to query elements.
In order to use Vitest getByText with solid, I found it was necessary to wrap <For each />
with a <div>
element. This isn't necessary in the jest or uvu examples.
https://github.com/solidjs/templates/pull/140/files#diff-bd38a4b23a37c0b01fcb17b274fa2578fccce12a7ec824627c84003858ef819d
I've just added a test to my local version:
test("For does not need a parent wrapper", () => {
const { getByText } = render(() => <For each={['a', 'b', 'c']}>{(i) => <span>{i}</span>}</For>);
expect(getByText('b')).toBeInTheDocument();
});
This works right out of the box. Let me test this in the template again. I'm pretty sure it is not related to our testing-library, though, if it works with jest, but not with vitest. There might be an issue with module loading in vitest.