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

Getting a "ShadowRoot is not defined" error #293

Closed
peripateticus opened this issue Jan 11, 2021 · 2 comments
Closed

Getting a "ShadowRoot is not defined" error #293

peripateticus opened this issue Jan 11, 2021 · 2 comments

Comments

@peripateticus
Copy link

peripateticus commented Jan 11, 2021

Hello!

So, we are in the process of upgrading Vue 2 -> 3 and, for unit tests, we use a combination of mochapack and @vue/test-utils for unit testing. Currently, I'm testing with @vue/test-utils@2.0.0-beta.14.

What is happening is that when I mount the component in the mocha spec file, I hit this error:

 WEBPACK  Compiling...
 WEBPACK  Compiled successfully in 1393ms
 MOCHA  Testing...

 RUNTIME EXCEPTION  Exception occurred while loading your tests
ReferenceError: ShadowRoot is not defined
    at normalizeContainer (/.../code/vunit-client/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js:1261:30)
    at Object.app.mount (/.../code/vunit-client/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.js:1211:27)
    at mount (/.../code/vunit-client/node_modules/@vue/test-utils/dist/vue-test-utils.cjs.js:2416:18)
    ...

Looking at the error stack at line 1261 in the @vue/runtime-dom/dist/runtime-dom.cjs.js code, it says that ShadowRoot is undefined. So, in the code, if I change that to a window.ShadowRoot, it's happy. I see that window.ShadowRoot exists when JSDOM is set up, prior to when the tests run.

Any ideas? Thanks for the help!

@cexbrayat
Copy link
Member

@peripateticus Thanks for opening an issue

This is indeed a problem with vue-next and not in vue-test-utils-next, and you're intuition is right.

The good news is that there is already a fix ready to merge vuejs/core#2943
So it should be fixed soon!

I'm going to close this issue, as there is nothing we can do on VTU-next side.

@peripateticus
Copy link
Author

Excellent, thank you for the quick response and pointing me to the fix on this, @cexbrayat! 👍

klipstein added a commit to klipstein/webdriverio that referenced this issue Oct 19, 2022
fixes an issue in browsers where ShadowRoot is not available globally (e.g. Edge 18). Error message is "ShadowRoot is not defined".

A similar issue was reported here vuejs/test-utils#293 and the fix was referencing ShadowRoot from window instead: https://github.com/vuejs/core/pull/2943/files
christian-bromann pushed a commit to webdriverio/webdriverio that referenced this issue Oct 19, 2022
* fix: access ShadowRoot via window.ShadowRoot

fixes an issue in browsers where ShadowRoot is not available globally (e.g. Edge 18). Error message is "ShadowRoot is not defined".

A similar issue was reported here vuejs/test-utils#293 and the fix was referencing ShadowRoot from window instead: https://github.com/vuejs/core/pull/2943/files

* Revert accidentally changed return value
klipstein added a commit to klipstein/webdriverio that referenced this issue Oct 19, 2022
* fix: access ShadowRoot via window.ShadowRoot

fixes an issue in browsers where ShadowRoot is not available globally (e.g. Edge 18). Error message is "ShadowRoot is not defined".

A similar issue was reported here vuejs/test-utils#293 and the fix was referencing ShadowRoot from window instead: https://github.com/vuejs/core/pull/2943/files

* Revert accidentally changed return value
christian-bromann pushed a commit to webdriverio/webdriverio that referenced this issue Oct 19, 2022
* fix: access ShadowRoot via window.ShadowRoot

fixes an issue in browsers where ShadowRoot is not available globally (e.g. Edge 18). Error message is "ShadowRoot is not defined".

A similar issue was reported here vuejs/test-utils#293 and the fix was referencing ShadowRoot from window instead: https://github.com/vuejs/core/pull/2943/files

* Revert accidentally changed return value
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