node. So you can do that, or you can also set the
+// attribute to the DOM.
+document.body.setAttribute('data-app', true)
+// Another solution is to create a custom renderer that provides all the
+// environment required by Vuetify.
+
+test('renders a Vuetify-powered component', async () => {
+ const {getByText} = render(VuetifyDemoComponent, {
+ vuetify: new Vuetify(),
+ })
+
+ await fireEvent.click(getByText('open'))
+
+ expect(getByText('Lorem ipsum dolor sit amet.')).toMatchInlineSnapshot(`
+
+ Lorem ipsum dolor sit amet.
+
+ `)
+})
diff --git a/src/vue-testing-library.js b/src/vue-testing-library.js
index 77316df0..acfb1176 100644
--- a/src/vue-testing-library.js
+++ b/src/vue-testing-library.js
@@ -11,9 +11,19 @@ const mountedWrappers = new Set()
function render(
TestComponent,
- {store = null, routes = null, ...mountOptions} = {},
+ {
+ store = null,
+ routes = null,
+ container: customContainer,
+ baseElement: customBaseElement,
+ ...mountOptions
+ } = {},
configurationCb,
) {
+ const div = document.createElement('div')
+ const baseElement = customBaseElement || customContainer || document.body
+ const container = customContainer || baseElement.appendChild(div)
+
const localVue = createLocalVue()
let vuexStore = null
let router = null
@@ -53,15 +63,12 @@ function render(
})
mountedWrappers.add(wrapper)
-
- const div = document.createElement('div')
- wrapper.element.parentNode.insertBefore(div, wrapper.element)
- div.appendChild(wrapper.element)
+ container.appendChild(wrapper.element)
return {
- container: wrapper.element.parentNode,
- baseElement: document.body,
- debug: (el = wrapper.element) => logDOM(el),
+ container,
+ baseElement,
+ debug: (el = baseElement) => logDOM(el),
unmount: () => wrapper.destroy(),
isUnmounted: () => wrapper.vm._isDestroyed,
html: () => wrapper.html(),
@@ -70,7 +77,7 @@ function render(
wrapper.setProps(_)
return wait()
},
- ...getQueriesForElement(wrapper.element.parentNode),
+ ...getQueriesForElement(baseElement),
}
}
@@ -116,7 +123,7 @@ fireEvent.touch = async elem => {
// Small utility to provide a better experience when working with v-model.
// Related upstream issue: https://github.com/vuejs/vue-test-utils/issues/345#issuecomment-380588199
-// Examples: https://github.com/testing-library/vue-testing-library/blob/master/tests/__tests__/form.js
+// Examples: https://github.com/testing-library/vue-testing-library/blob/master/src/__tests__/form.js
fireEvent.update = (elem, value) => {
const tagName = elem.tagName
const type = elem.type