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

129
Views
¿Cómo acceder correctamente al cuerpo de la respuesta cuando se usa Playwright?

Soy nuevo en Playwright y js, así que estoy un poco perdido aquí. Quiero poder enviar una solicitud y luego verificar el estado, el contenido de la respuesta, los encabezados, etc.

Pensé que sería capaz de hacer algo como

 test('blah', async ({ request }) => { await request.get('http://localhost:444').then(res => { expect(res.status()).toBe(200) expect(res.headers()['content-type']).toBe('application/octet-stream') expect(res.json()).toContain('foo') }) })

pero esto no funciona y la expectativa ve res.json() como "{}" y si trato de imprimir la respuesta a la consola con console.log(res.json()) obtengo Promise { <pending> }

Eventualmente conseguí que mi prueba funcionara correctamente usando el siguiente código, pero me parece complicado y no sé por qué tengo que hacer esto. ¿Estoy haciendo esto correctamente? o estoy muy lejos?

 test('blah', async ({ request }) => { await request.get('http://localhost:4444/') .then(res => { expect(res.status()).toBe(200) return res.json() }) .then(json => { expect(JSON.stringify(json)).toContain('foo') }) })
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!