I'm use(vue with jest + vue-test-utils). I'm trying to check the correctness of the function and it has a foreach that removes a certain class from all elements(class - show). The problem is that if you do this in a native way, then the test returns a collection of classes with a class that should be deleted, the only way how it works is to delete it via refs
<span ref="typeFiles" class="error error-type">{{ $t("schedulesFormatFiles") }}</span>
<span ref="sizeFiles" class="error error-weight">{{ $t("schedulesMaxWeightFiles") }}</span>
<span ref="elseError" class="error error-load">{{ $t("schedulesErrorText") }}</span>
removeFile(){
this.$refs.fileName.innerHTML = '';
this.$refs.labelText.classList.remove('filled');
this.$refs.btnClear.style.display = 'none';
this.$refs.iconUpload.setAttribute('data-load', '')
document.querySelectorAll('.error').forEach(item => {
item.classList.remove('show');
})
},
test('file remove', () => {
wrapper.vm.removeFile()
expect(wrapper.findComponent({ref: 'fileName'}).text()).toBe('');
expect(wrapper.vm.$refs.labelText.classList.contains('filled')).toBe(false)
expect(wrapper.findComponent({ref: 'btnClear'}).isVisible()).toBe(false)
expect(wrapper.findComponent({ref: 'iconUpload'}).attributes()['data-load']).toBe('');
const wrapperArray = wrapper.findAll('.error')
wrapperArray.wrappers.map(w => console.log(w.classes()))
})