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

153
Views
Cree una prueba de broma para fallar una función asíncrona que no usa await
async function isContentUser (userEmail, studentStatus) { const hasContentAccess = getContentCreatorAccess() const hasContentStudentStatus = studentStatus === CONTENT return hasContentStudentStatus || hasContentAccess } async function getContentCreatorAccess () { const { contentCreatorAccess } = await api.getContentCreatorPermission() return contentCreatorAccess }

Como puede ver en la función isContentUser , no estamos esperando getContentCreateAccess , sino la aprobación de la prueba existente a continuación, porque hasContentAccess en el valor de retorno es una promesa y estamos esperando la promesa en la prueba.

Y quiero crear un PR que agregue await antes de llamar a getContentCreatorAccess , ¿cómo puedo crear una prueba que funcione con await pero no en el código actual?

 it(`should return true if studentStatus is not Content but user has content permission`, async () => { api.getContentCreatorPermission.mockResolvedValue({ contentCreatorAccess: true }) expect(await isContentUser('email@gmail.com', 'Audit')).toBe(true) })
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!