Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<div> required to wrap <For each> in order to query elements. #53

Open
birkskyum opened this issue Jan 19, 2024 · 1 comment
Open

<div> required to wrap <For each> in order to query elements. #53

birkskyum opened this issue Jan 19, 2024 · 1 comment

Comments

@birkskyum
Copy link

birkskyum commented Jan 19, 2024

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

@atk
Copy link
Collaborator

atk commented Jan 24, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants