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

137
Views
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 answers
Answer question

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 Report
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!