Skip to content

Testing for visibility with transition (v-show) #210

Closed
@soullpoint

Description

@soullpoint

Hi, I was trying to test that an element is not visible after triggering an event, but am having trouble with getting the test to pass when the element is wrapped in a transition. I wasn't able to find any related issues, apart from the fact that isVisible is no longer supported. I was hoping someone would be able to point me in the right direction

Consider the following structure where state.showItem is toggled between true/false on mouse enter/leave in a different element:

<transition name="fade">
    <span class="item" v-show="state.showItem">
      {{content}}
    </span>
</transition>

The following test fails on the second assertion:

await wrapper.find(".trigger-item").trigger("mouseenter");
expect(
  wrapper.find(".item").attributes("style").includes("display: none")
).toBe(false);

await wrapper.find(".trigger-item").trigger("mouseleave");
expect(
  wrapper.find(".item").attributes("style").includes("display: none")
).toBe(true);

But succeeds once I've removed the wrapping transition component. I have tried using await nextTick to no avail.

Perhaps I am doing something wrong?

Any advice would be appreciated.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions