GlutenBoy
GlutenBoy

Reputation: 103

how to test a vue 3 component with cypress (10.x) using v-model

I've created a component using a v-model and I want to component test it, but I can't seem to make the v-model work with the mount(). Here's my test and a couple of things I've tried. Thx.

import { mount } from 'cypress/vue'
import Component from '../../../src/components/MyComponent.vue'

let myData = null
let columns = null

beforeEach(() => {
    cy.fixture('MyFixture.json').then(function (data) {
        myData = data
    })
})

...
it('initial test', () => {
    mount(Component, {
        props: {
            value: myData,
        }
    })
})

I've also tried 'v-model': myData but nothing seems to work.

Note that all other props works, they are omitted here for brevity.

Upvotes: 2

Views: 1816

Answers (1)

GlutenBoy
GlutenBoy

Reputation: 103

Turns out the answer is modelValue

it('initial test', () => {
    mount(Component, {
        props: {
            modelValue: myData,
        }
    })
})

Upvotes: 2

Related Questions