Estoy tratando de probar un componente que usa vue-multiselect. El componente tiene un botón que borra la selección de opciones y hace que la selección se cierre a través de una llamada al método toggle(). Todo esto funciona en la propia aplicación, pero al probar este método, la prueba da un error asociado con llamar a este método 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([[]]) })})
Prueba superada en consola me sale error
Estaré agradecido por cualquier ayuda porque estoy en un callejón sin salida.