question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Do we need to mount on the DOM?

See original GitHub issue

https://github.com/vuejs/vue-test-utils-next/blob/a66d8bcc09e85e5f8d977cfd2b53e705337a9134/src/mount.ts#L56

createApp(...).mount requires a real DOM element from what I can see - I’m not sure how VTU beta handled this, but I believe the default was NOT to mount on the dom, since we had an attachToDocument option.

We are currently tightly coupled to the DOM - not ideal, but I think it’s fine for a pre alpha.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
lmiller1990commented, Apr 30, 2020

Going to close this for now - we have a pretty good solution where we mount on an element on in the DOM as of this commit so we are not blowing up any potentially pre-existing state, which matches the VTU beta API.

If this turns out to be a problem (eg performance) we can look more deeply into how this was handled in Vue 2.

1reaction
LinusBorgcommented, Apr 28, 2020

I am guessing this is what Vue 2 was internally as well if you didn’t pass an element to $mount.

Did a quick check - seems that in Vue 2, mount could indeed work without an element to mount to.

https://github.com/vuejs/vue/blob/e1fbfac66403aa0df5cdae040a8edf2f219455ca/src/core/instance/lifecycle.js#L143

Read more comments on GitHub >

github_iconTop Results From Across the Web

"mount" vs "render"? - React Training
"Mounting" is when React "renders" the component for the first time and actually builds the initial DOM from those instructions. A "re-render" ...
Read more >
What is "Mounting" in React js? - Stack Overflow
The mounting refers to attaching the React component instance to the DOM node which is necessary to do tree diffing/incremental render updates on...
Read more >
Mounting components and asserting on the DOM
To test this, we need to mount the component into a DOM container and then look at the rendered query output. Before writing...
Read more >
What does it mean for a component to be mounted in ReactJS
Mounting is the initial phase in which the instance of the component is created and inserted into the DOM. When the component gets...
Read more >
Mounting React Components Explained - YouTube
What does it mean to Mount a Component in React? ... interacts with the DOM, and discussion about what it means to Mount...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found