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

Select.Content cannot render in happy-dom #2166

Open
llllvvuu opened this issue May 26, 2023 · 1 comment
Open

Select.Content cannot render in happy-dom #2166

llllvvuu opened this issue May 26, 2023 · 1 comment

Comments

@llllvvuu
Copy link

llllvvuu commented May 26, 2023

Bug report

EDIT: I re-tested this replacing happy-dom with jsdom and it fixed it, so now I am open to the idea that this is a happy-dom issue and should be reported to their issues.

The minimal repro linked below is a fresh create-next-app with vitest, @testing-library/react, and happy-dom installed.

I put only the "Anatomy" code: https://www.radix-ui.com/docs/primitives/components/select#anatomy

And the test is just

describe("Select", () => {
  it("should render", () => {
    render(<Select />)
  })
})

Current Behavior

TypeError: Cannot read properties of null (reading 'createElement')

Expected behavior

<Select /> should render

Reproducible example

https://github.com/llllvvuu/radix-ui-minimal-repro
CodeSandbox (open Terminal and type yarn vitest)

Suggested solution

It looks like <Select.Content> specifically is the culprit, since removing it causes the render to be successful, but removing everything inside of it the test still fails.

Additional context

I will try with jsdom instead of happy-dom and report back. vitest (not jest) is a hard requirement for me though.

Your environment

"@radix-ui/react-select@^1.2.2":
  version "1.2.2"
  resolved "https://registry.yarnpkg.com/@radix-ui/react-select/-/react-select-1.2.2.tgz#caa981fa0d672cf3c1b2a5240135524e69b32181"
  integrity sha512-zI7McXr8fNaSrUY9mZe4x/HC0jTLY9fWNhO1oLWYMQGDXuV4UCivIGTxwioSzO0ZCYX9iSLyWmAh/1TOmX3Cnw==

[email protected]:
  version "18.2.0"
  resolved "https://registry.yarnpkg.com/react/-/react-18.2.0.tgz#555bd98592883255fa00de14f1151a917b5d77d5"
  integrity sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==

"@testing-library/react@^14.0.0":
  version "14.0.0"
  resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-14.0.0.tgz#59030392a6792450b9ab8e67aea5f3cc18d6347c"
  integrity sha512-S04gSNJbYE30TlIMLTzv6QCTzt9AqIF5y6s6SzVFILNcNvbV/jU96GeiTPillGQo+Ny64M/5PV7klNYYgv5Dfg==

see yarn.lock for more

Node v18.16.0
yarn 1.22.19
MacOS Ventura 13.1 (M1)

@llllvvuu llllvvuu changed the title Select.Content causes @testing-library/react to fail with "TypeError: Cannot read properties of null (reading 'createElement')" Select.Content cannot render in happy-dom May 26, 2023
@benoitgrelard
Copy link
Contributor

EDIT: I re-tested this replacing happy-dom with jsdom and it fixed it, so now I am open to the idea that this is a happy-dom issue and should be reported to their issues.

Yeah I was going to say that doesn't sound like a Radix issue to me, rather some kind of setup issue.

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