Skip to content

Should update wrapper.props() value after wrapper.setProps ? #374

Closed
@fimars

Description

@fimars

Version

1.0.0-beta.10

Reproduction link

https://github.com/fimars/vue-test-utils/blob/59a46bb342f924d0ff6e5e4a1af19911694a146b/test/unit/specs/mount/Wrapper/setProps.spec.js#L50-L62

Steps to reproduce

  // setProps.spec.js
  it('should update after setProps', () => {
    const prop1 = {}
    const prop2 = 'val1'
    const wrapper = mount(ComponentWithProps, {
      propsData: { prop1, prop2 }
    })

    expect(wrapper.props()).to.eql({ prop1: {}, prop2: 'val1' })
    // setProps
    wrapper.setProps({ prop2: 'val2' })
    expect(wrapper.vm.prop2).to.eql('val2') // pass
    expect(wrapper.props()).to.eql({ prop1: {}, prop2: 'val2' }) // fail still prop2: 'val1'
  })

I write a test-case in my fork. you can try it.

What is expected?

wrapper.props() should be updated

What is actually happening?

no update know.


The props of wrapper.vm are updated, maybe this is deliberately designed?

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