Playwright's testInfo.attach API lets you embed downloaded files, externally fetched files, and screenshots directly into your test report. This makes it easier for testers to access and verify file outputs without manually navigating the application. Three approaches are covered: attaching browser-downloaded files using suggestedFilename and path, fetching external files via APIRequestContext and attaching the response body, and capturing page screenshots with a specified content type. Attachments can also be stored as pipeline artifacts for historical comparison.

3m read timeFrom timdeschryver.dev
Post cover image
Table of contents
Add a downloaded file to the reportAdd an external file to the reportAdd a screenshot to the reportConclusion