Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fimars opened this issue Jan 24, 2018 · 2 comments
Closed

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

fimars opened this issue Jan 24, 2018 · 2 comments
Labels

Comments

@fimars
Copy link
Contributor

fimars commented Jan 24, 2018

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?

@paparent
Copy link

Hi

@eddyerburgh I ran into similar issue. But instead of looking at .props(), I look at the .html(). The styles doesn't get updated, and I wanna make sure the color attribute change. Even if I do a Vue.nextTick.

Thanks

@eddyerburgh
Copy link
Member

Can you create new issue with a reproduction?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants