Skip to content

How to check an element is displayed (v-show) ? #327

Closed
@Toilal

Description

@Toilal

I try to assert that elements are displayed or not. Those elements are children (or even grand-children) of a v-show node.

Consider the following, I wish to assert display of .item elements.

<div>
  <div v-show="modelAttrA">
    <span class="item">Ax</span>
    <span class="item">Ay</span>
  </div>
  <div v-show="modelAttrB">
    <span class="item">Bx</span>
    <span class="item">By</span>
  </div>
<div>

It seems a common use case, but I can't find any way in vue-test-utils to do that. I can't rely on DOM element properties as I run tests with JEST (JSDOM doesn't layout elements and can't tell if an element is displayed neither). Maybe there's something possible with VueJS VNode API ?

I would expect some kind of displayed method in the Wrapper API.

expect(wrapper.findAll('.item').at(3).displayed()).toBeTruthy()

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions