[Vuejs]-Cannot click on Vue Select Box using vue-test-utils

0👍

the component you are using does not use select input element. In order to simulate selecting an option, you would do something like this.

wrapper.findAll('.el-select-dropdown__item').at(1).trigger('click'); // simulates clicking of one of the options

if you want to simulate clicking of select element itself(to show the dropdown). you could do the following.

 wrapper.find('.el-select-dropdown').trigger('click');

0👍

Whitespace’s answer above helped, however also needed to ensure you use

await Vue.nextTick() 

before your expect statement. Like so:

wrapper.findAll('.el-select-dropdown__item').at(1).trigger('click');
await Vue.nextTick();
expect(enterResultBtn.is('[disabled]')).toBe(true);

This allows the DOM to update it’s cycle, more info here

Leave a comment