Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

133
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda