Skip to content

@lit/react package is not setting properties passed to the component during Vitest tests #4446

@tylerbmyers

Description

@tylerbmyers

Which package(s) are affected?

React (@lit/react)

Description

When running tests in Vitest and using any version of @lit/react or @lit-labs/react versions 2 and up, any lit element wrapped with createComponent is not setting the properties of the web component that are passed as props.

This works fine in a real browser using Vite, and seems to be only an issue in the tests. The other thing that is interesting is that if I copy and paste the create-component.ts file into my project and import it directly, it works just fine, so my guess is that something with the minified file is not compatible with Vitest for some reason.

Reproduction

I have created this repo with a simple Lit web component to reproduce the issue. In App.test.tsx you will see the component that is created using the @lit/react package is not setting the name property, but the component created using the direct import of create-component.ts is setting the name property.

Workaround

My current workaround is to use @lit-labs/react version 1 as this works fine with Vitest.

Is this a regression?

Yes. This used to work, but now it doesn't.

Affected versions

Failing any version of @lit/react or @lit-labs/react versions 2 and up

Browser/OS/Node environment

Node version: 20.10.0

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions