Skip to content

setComputed does not set computed values #273

Closed
@charliekassel

Description

@charliekassel

Seems to be a bug, I've not tested using Jest.

Using vue-cli webpack tempate.
vue-test-utils@1.0.0-beta.8
Vue 2.5
Karma 1.4.1
Mocha 3.2.0

import {shallow} from 'vue-test-utils'
const cmp = {
  data () {
    return {
      a: 1
    }
  },
  computed: {
    b () {
      return this.a * 2
    }
  }
}

describe('testing vue-test-utils', () => {
  it('has default properties', () => {
    const wrapper = shallow(cmp)
    expect(wrapper.vm.a).to.equal(1)
    expect(wrapper.vm.b).to.equal(2)
  })

  it('sets data', () => {
    const wrapper = shallow(cmp)
    wrapper.setData({a: 2})
    expect(wrapper.vm.a).to.equal(2)
    expect(wrapper.vm.b).to.equal(4)
  })

  it('sets computed', () => {
    const wrapper = shallow(cmp)
    wrapper.setComputed({b: 3})
    expect(wrapper.vm.b).to.equal(3)
  })
})
  testing vue-test-utils
    ✓ has default properties
    ✓ sets data
    ✗ sets computed
	expected 2 to equal 3

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