Vue.js 比较道具和数据时出现测试错误

Vue.js 比较道具和数据时出现测试错误,vue.js,vuejs2,vue-test-utils,Vue.js,Vuejs2,Vue Test Utils,我有一个组件,它在创建时设置日期:null或props.datainical 在没有道具的DevTools中: 在带有一些道具的DevTools中: 当我做测试时: import { mount } from 'vue-test-utils' import SelecionadorData from '@/components/Shared/SelecionadorData.vue' describe('SelecionadorData.vue', () => { it('shou

我有一个组件,它在创建时设置日期:null或props.datainical

在没有道具的DevTools中:

在带有一些道具的DevTools中:

当我做测试时:

import { mount } from 'vue-test-utils'
import SelecionadorData from '@/components/Shared/SelecionadorData.vue'

describe('SelecionadorData.vue', () => {

  it('should receive the props datainicial', () => {
    const wrapper = mount(SelecionadorData)
    wrapper.setProps({
      datainicial: '2018-01-01'
    })
    expect(wrapper.vm.date).toBe('2018-01-01')
  })
})
我得到这个错误:

创建组件时,“创建”仅运行1次。 当您使用setProps时,组件props将被更新,但created方法将不再被调用

import { mount } from 'vue-test-utils'
import SelecionadorData from '@/components/Shared/SelecionadorData.vue'

describe('SelecionadorData.vue', () => {

  it('should receive the props datainicial', () => {
    const wrapper = mount(SelecionadorData,
    {
        propsData: {
          datainicial: '2018-01-01'
        }
    })
    expect(wrapper.vm.date).toBe('2018-01-01')
  })
})
import { mount } from 'vue-test-utils'
import SelecionadorData from '@/components/Shared/SelecionadorData.vue'

describe('SelecionadorData.vue', () => {

  it('should receive the props datainicial', () => {
    const wrapper = mount(SelecionadorData,
    {
        propsData: {
          datainicial: '2018-01-01'
        }
    })
    expect(wrapper.vm.date).toBe('2018-01-01')
  })
})