happy-dom icon indicating copy to clipboard operation
happy-dom copied to clipboard

Cannot read properties of undefined (reading 'getRootNode')

Open smarlhens opened this issue 2 years ago • 7 comments

Hi there 👋🏻 ,

I hope it is the right place to ask, and I apologize if not. I'm currently trying to bump version of happy-dom from 2.51.0 to a greater one using vitest & vue 3 but I'm facing the following error:

image

happy-dom version: 3.1.0 (I've tried multiple version between this one and 2.51.0)
vitest version: 0.10.0

It seems to be related to usage of @headlessui/vue (version 1.5.0) but I haven't found yet the root cause.

Thanks in advance for your help, wish you a nice day ☀️

smarlhens avatar May 03 '22 13:05 smarlhens

Thank you for reporting @smarlhens! :slightly_smiling_face:

It might be a bug as a change was made on that part of the code in v2.51.1.

I will investigate what may have caused it.

capricorn86 avatar May 04 '22 18:05 capricorn86

Hey! I'm also running into issues with this using vitest and react with happy-dom 3.1.1 in my case it seems like it might be related to certain components from the mui component library

WonderPanda avatar May 05 '22 23:05 WonderPanda

@WonderPanda you don't happen to have a open project that I can test in? :slightly_smiling_face:

capricorn86 avatar May 25 '22 14:05 capricorn86

I'm facing the same error while using a remix template with vitest. You can check out this repo and run the following to reproduce it:

  1. npm i
  2. npm run test

It should fail with the following error message: Screenshot 2022-06-18 at 17 44 13

The test is located in this file.

Somehow it's only possible to run the first test without errors although both tests are identical. I'm also not 100% sure if this a problem with happy-dom testing-library or vitest. But the error messages links the error to happy-dom.

Thanks in advance for any feedback and for your support!!!

knoefel avatar Jun 18 '22 15:06 knoefel

Here is a codesandbox with the minimal possible code to produce this error. Indeed, it only happens when running a second test (when adding a .only to the second test, it does not happen).

nilscox avatar Jun 22 '22 18:06 nilscox

I can confirm this is related to happy-dom. I changed the vitest environment to jsdom, and all tests passed. In my case, it also happens when running a second test.

brapifra avatar Jul 07 '22 07:07 brapifra

I'm blocked by this as well in [email protected] Reproducible example: https://stackblitz.com/edit/vitest-dev-vitest-ktnq7h

hornta avatar Jul 08 '22 22:07 hornta

Thanks for reporting @smarlhens! 🙂

I am sorry that it has taken such a long time for me to fix this. It has been a lot going on in my private and work life, but now I will have time to focus on Happy DOM again.

I have made a fix. Hopefully it will solve your problem. Feel free to re-open otherwise.

You can read more about the related releases here: https://github.com/capricorn86/happy-dom/releases/tag/v7.5.10 https://github.com/capricorn86/happy-dom/releases/tag/v7.5.9

capricorn86 avatar Oct 12 '22 15:10 capricorn86