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

132
Visualizações
unit testing computed properties

I'm currently trying to unit test a computed properties.

I have a fileOne.ts file :

export const fileOne = () => {
   
   const fx1 = computed ( () => { ... } );
   const fx2 = computed ( () => { ... } );
   const fx3 = computed ( () => { ... } );

}

this 'fileOne' is used in a Vue.vue aswell :

<template>
   ...
</template>

<script lang="ts">
   import { fileOne } from './fileOne';
   
   const fileOneState = fileOne( ... );

   ...
</script>

I want to unit test my computed properties of fileOne. At the moment i have a file named : 'fileOne.spec.ts' with :

describe('testing computed properties', () => {
  it('should return the right value', () => {
    expect().toBe();
  })
});

The problem is : I don't know what I need to import either how to get a instance with my computed properties to test.

I believe this is not clear but if someone understood, i'll be happy to have some helps.

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Most likely you don't need to test the computed value, but extract the methods you are passing as arguments to computed and test those.

There is no need for unit testing to test the computed versions, but just your own business logic.

One of doing this is to either

  • extract them to a new file and import them in both fileOne.ts and fileOne.spec.ts or
  • export them from fileOne.ts and import them in fileOne.spec.ts.

I would go with option 1 as it clearly marks the fact that you are exporting some custom business logic and the fact that it ends up in a computed method is secondary. You can import that anywhere now.

about 4 years ago · Juan Pablo Isaza Relatório
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