Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

168
Views
Jest test always return removed class

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()))
})

enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!