No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Testing: wrapper.setValue() cannot be called on this element

    Framework
    1
    1
    1418
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      Denis Correia last edited by

      I can not assign a value to the q-input component when using jest

      //test.js
      import { mountQuasar } from '~/test/jest/utils'
      import PAGE from '../demo/QBtn-demo.vue'
      
      const wrapper = mountQuasar(PAGE)
      describe('Banco Page', () => {
        it ('Cadastro novo banco', () => {
          const inputCodigo = wrapper.find({ ref: 'codigo' })
          inputCodigo.setValue('bar')
          expect(wrapper.vm.codigo).toBe('bar')
        })
      })
      
      // QBtn-demo.vue
      
      <template>
        <q-page>
           <!--<input v-model="codigo" ref="codigo"/>-->
          <q-input v-model="codigo" ref="codigo"></q-input>
        </q-page>
      </template>
      
      <script>
      export default {
        name: 'PAGE',
        data () {
          return {
            codigo: ''
          }
        },
        methods: {
        }
      }
      

      I’m getting the following error: [vue-test-utils]: wrapper.setValue() cannot be called on this element however if I remove <q-input> and only use <input /> works perfectly.

      Do I need to do something different to assign value to a quasar input ?

      1 Reply Last reply Reply Quote 2
      • First post
        Last post