Playwright · Middle · Question 28 of 75
How do you attach a file or text to the test report?
- 1
await testInfo.attach('log', { body, contentType }) - 2
await page.reportFile('log', { body, contentType }) - 3
await test.attachFile('log', { path, contentType })
Show the answer
Correct answer: await testInfo.attach('log', { body, contentType })
Explanation
Attachments such as server logs or API responses appear next to the failing test in the HTML report.