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