Youโ€™re browsing the documentation for Vue Test Utils for Vue v2.x and earlier.

To read docs for Vue Test Utils for Vue 3, click here.

setData(data)

WrapperArray ใฎ Wrapper ใ”ใจใซ Wrapper ใซ vm ใƒ‡ใƒผใ‚ฟใ‚’ใ‚ปใƒƒใƒˆใ—ใพใ™ใ€‚

ใ™ในใฆใฎ Wrapper ใฏ Vue ใ‚คใƒณใ‚นใ‚ฟใƒณใ‚นใ‚’ๅซใ‚“ใงใ„ใชใ‘ใ‚Œใฐใชใ‚‰ใชใ„ใ“ใจใซๆณจๆ„ใ—ใฆใใ ใ•ใ„ใ€‚

  • ๅผ•ๆ•ฐ:

    • {Object} data
  • ไพ‹:

import { mount } from '@vue/test-utils'
import Foo from './Foo.vue'
import Bar from './Bar.vue'

test('setData demo', async () => {
  const wrapper = mount(Foo)
  const barArray = wrapper.findAll(Bar)
  await barArray.setData({ foo: 'bar' })
  expect(barArray.at(0).vm.foo).toBe('bar')
})