Allow mount method to attach to specific HTML Element rather than generically attaching to the document · Issue #1487 · vuejs/vue-test-utils (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@jnields

Description

@jnields

What problem does this feature solve?

This allows the developer to attach a component within the context of a page, and potentially allows for more integrated testing, e.g. via puppeteer.

What does the proposed API look like?

Currently you offer this option in the API:

https://vue-test-utils.vuejs.org/api/options.html#attachtodocument

I believe it should be expanded to allow specification of where in the document it is attached.

const wrapper = mount(Component, {
  attachTo: document.getElementById('app'),
})

This is roughly equivalent to the API used by Enzyme
https://enzymejs.github.io/enzyme/docs/api/mount.html