Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Provide options to adapt the document before mount #98

Closed
Labels
bugSomething isn't working released
@ChristophWalter

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.0
  • Vue version: 2.5.18
  • node version: 8.12.0
  • yarn version: 1.17.3
  • Vuetify 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");
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working released

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /