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

116
Views
Vue 2 Composition API + Jest method testing

So previously I have a successfully working test with Vue 2.7 + Jest in Options API like this:

{
  data: () => ({}),
  methods: {
    async someFunction() {
      const result = await this.hiWorld()
      return result
    },
    async hiWorld() {
      return 'hi world'
    }
  }
}
test('helloWorld', async () => {
  console.log(wrapper.vm.someFunction) // [Function: bound someFunction] AsyncFunction
  const result = await wrapper.vm.someFunction()
  expect(result).toBe('hi world')
})

and after I converted it to using setup function, jest wasn't able to call it and throws a 5000 timeout (even after adjustments, nothing happens)

{
  setup() {
    async function someFunction() {
      const result = await hiWorld() // it wasn't able to call this now?
      return result
    }

    async function hiWorld() {
      return 'hi world'
    }

    return {
      someFunction,
      hiWorld
    }
  }
}
thrown: "Exceeded timeout of 5000 ms for a test.
    Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."

and from [Function: bound someFunction] AsyncFunction it now logs [AsyncFunction: someFunction].

Am I missing something 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!