Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

433
Visualizações
Error in vue-test-utils with call component method by ref

I'm trying to test a component that uses vue-multiselect. The component has a button that clears the options selection and causes the select to close via a method call toggle(). This all works in the application itself, but when testing this method, the test gives an error associated with calling this method toggle().

<button class="btn-unselect-all small-button" type="button" @click="cleanSelect">{{ $t("students.clear") }}</button>

cleanSelect: function (){
  this.$emit('cleanSelectInstitutes', [])
  this.$refs.multiselectInstitutes.toggle();
},





import {config, mount} from "@vue/test-utils"
import FiltersByStudents from '../../assets/src/components/FiltersByStudents'
import Multiselect from 'vue-multiselect';
import translations from "../../assets/src/common-resources/translations/translations"

const locale = "uk";
config.mocks["$t"] = msg => translations[locale][msg]

describe('testing students filters methods', () => {
let wrapper;
beforeEach(() => {
    wrapper = mount(FiltersByStudents, {
        propsData: {
            filters: {
                "optionsInstitutes": [
                    {
                        "id": 1,
                        "name": "VNZ 1"
                    },
                    {
                        "id": 2,
                        "name": "VNZ 2"
                    },
                ],
                "optionsStudents": [
                    {
                        "type": 0,
                        "name": "All"
                    },
                    {
                        "type": 1,
                        "name": "Authorized"
                    },
                    {
                        "type": 2,
                        "name": "Not Authorized"
                    }
                ],
                "selectedInstitutes": [],
                "selectedStudents": [],
                "fio": "",
                "cardNumber": ""
            },
            currentPage: 1,
            fnSearchStudents: jest.fn()
        },
        stubs: ['Multiselect']
    })
});
test('call method clear options and close select', async () => {
    let btnClearSelect = wrapper.find('.btn-unselect-all')
    await btnClearSelect.trigger('click')
    expect(wrapper.emitted().cleanSelectInstitutes[0]).toEqual([[]])
})

})

Test passed by in console I get error

enter image description here

I will be grateful for any help because I am at a dead end.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda