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

Vue fails to mount in environments that don't provide window.SVGElement #3590

Open
xinix opened this issue Apr 12, 2021 · 5 comments
Open

Vue fails to mount in environments that don't provide window.SVGElement #3590

xinix opened this issue Apr 12, 2021 · 5 comments
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. ✨ feature request New feature or request

Comments

@xinix
Copy link

xinix commented Apr 12, 2021

Version

3.0.11

Reproduction link

https://github.com/xinix/vue3-svg-bug

Steps to reproduce

Create a sample Vue3 app with Vue UI:

vue create demo

Select the following:

  • Manually select features
  • Choose Vue 3.x (preview)
  • Class-style syntax? No
  • Unit testing solution: Mocha
npm install 
npm run test:unit

What is expected?

Sample test to run

What is actually happening?

An error is thrown:

ReferenceError: SVGElement is not defined
    at Object.app.mount (dist/js/webpack:/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js:1259:1)
    at mount (dist/js/webpack:/node_modules/@vue/test-utils/dist/vue-test-utils.esm-bundler.js:2310:1)
    at shallowMount (dist/js/webpack:/node_modules/@vue/test-utils/dist/vue-test-utils.esm-bundler.js:2329:1)
    at Context.<anonymous> (dist/js/webpack:/tests/unit/example.spec.ts:8:1)
    at processImmediate (internal/timers.js:461:21)
@LinusBorg
Copy link
Member

vuejs/vue-cli#6400

Will be fixed in the next version of the mocha vue cli plugin.

@LinusBorg
Copy link
Member

On second though, we might want to consider making this more robust in Vue core. I'll reopen for further evalution.

@LinusBorg LinusBorg reopened this Apr 12, 2021
@LinusBorg LinusBorg added the ✨ feature request New feature or request label Apr 12, 2021
@LinusBorg LinusBorg changed the title Vue 3 sample unit test fails with error message ReferenceError: SVGElement is not defined Vue fails to mount in environments that don't provide window.SVGElement Apr 12, 2021
@LinusBorg LinusBorg added the 🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. label Apr 12, 2021
@HcySunYang
Copy link
Member

Does this really need a fix? For runtime-dom, we assume that it runs in a standard browser environment.

@LinusBorg
Copy link
Member

Probably not. Wanted to check out why it was a problem on vue-cli durting testing with mocha though, before I close it.

@fangbinwei
Copy link

I think it's similar to #2943

kikuomax added a commit to codemonger-io/dogs-business that referenced this issue Jul 3, 2021
- After upgrading `vue` and `@vue/test-utils`, I got errors
  "ReferenceError: SVGElement is not defined" when I ran unit tests.
  This is fixed by introducing `window.SVGElement` into `global`.
  vuejs/core#3590

issue #16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed. ✨ feature request New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants