Skip to content

need await Vue.nextTick() before getting the updated DOM content #1878

Open
@PhoenixMenia

Description

@PhoenixMenia

Documentation Feedback

it doesn't work for me by using the example unit test code in the documentation, but it works below:

import { mount } from '@vue/test-utils'
import Vue from 'Vue'

describe('ParentComponent', () => {
  const wrapper = mount(ParentComponent)
  it("displays 'Emitted!' when custom event is emitted", async () => {
    const child = wrapper.findComponent(ChildComponent)
    child.vm.$emit('custom')
    await Vue.nextTick()
    expect(wrapper.html()).toContain('Emitted!')
  })
})

Affected documentation page: Insert a link to the affected page
https://vue-test-utils.vuejs.org/zh/guides/#%E5%B8%B8%E7%94%A8%E6%8A%80%E5%B7%A7

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions