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

121
Visualizações
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 à 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