Back to changelog

Generic Attachments for Playwright Tests

You can attach arbitrary files and content directly to your Playwright tests, making it easier to capture relevant data for review and improved collaborat…

Generic Attachments for Playwright Tests

You can attach arbitrary files and content directly to your Playwright tests, making it easier to capture relevant data for review and improved collaboration with your team. With the recent update to Currents you can browse and download arbitrary test attachments.

The attachments will be securely uploaded and stored in Currents cloud storage.

  • Requires @currents/playwright 1.6.0+
  • No extra charge and no limit on volume
  • Subject to your plan’s retention policy

This change unlocks further improvements to Currents platforms that are based on parsing attachments associated with the tests. A few examples:

  • Markdown file for test documentation and notes
  • Lighthouse reports to track accessibility and web vitals
  • Mermaid for charts and diagrams

How to Attach Files to Playwright Tests

Use the following syntax to add attachments to your test:

test('example test with attachment', async ({ page }, testInfo) => {
  // Your test steps
  // ..
  // Attach an MD file
  await testInfo.attach("mdFile", {
    path: "./files/test.md",
  });
});

If you want to embed custom content directly, use:

test('example test with custom content', async ({ page }, testInfo) => {
  // Your test steps
  // Attach custom content
  const logContent = 'Example log content';
  await testInfo.attach('log', {
    body: Buffer.from(logContent),
    contentType: 'text/plain',
  });
});