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

173
Visualizações
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
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