Description
Describe the feature
We are using Vuetify as component library in one of our projects. I would like to introduce vue-testing-library and came up with some setup troubles on the way. Vuetify requires a wrapper element containing the attribute data-app
. This element is used to append components like dialog to the root DOM level. The required setup can be done using jest setup files. Thought, the dialog content can not be found when using the exposed queries of the vue-testing-libraries render()
method.
To Reproduce
Steps to reproduce the behavior:
- Init a vue app with vuetify
- Create a basic dialog
- write a test which should validate that the dialog content is visible when a button is clicked
- Add Vuetify and
<div data-app></div>
to your test DOM instance before mount
=> queries like getByText will not query the dialog content
I tried to create a codesandbox, but failed. Is there a working example for vue-testing-library?
https://codesandbox.io/s/vuetify-with-vue-testing-library-bhu8f?previewwindow=tests
Expected behavior
I expect a configuration option like it exists for react:
- baseElement: Specify the base element for the queries.
- container: Specify the surrounding DOM node
Related information:
@testing-library/vue
version: 3.0.0Vue
version: 2.5.18node
version: 8.12.0yarn
version: 1.17.3Vuetify
version: 1.2.10
Relevant code or config (if any)
import CreateLorem from "./CreateLorem";
import { render } from "@testing-library/vue";
import Vuetify from "vuetify";
import Vue from "vue";
var app = document.createElement("div");
app.setAttribute("data-app", true);
document.body.appendChild(app);
Vue.use(Vuetify);
it("should create a lorem", () => {
const { getByText } = render(CreateLorem);
getByText("open");
});