Playwright Test Report Email Notification: Complete Guide to Sending Playwright HTML Reports via Email

Introduction

A successful automation framework does more than execute tests—it communicates results quickly and clearly. One of the most effective ways to achieve this is through Playwright Test Report Email Notification. Instead of manually opening reports after every execution, your framework can automatically email HTML reports, screenshots, videos, and trace files to developers, testers, managers, and stakeholders.

In this Playwright Test Report Email Notification guide, you’ll learn how to generate Playwright reports, send email notifications using NodeMailer, integrate reporting into Jenkins, GitHub Actions, and Azure DevOps, and build an enterprise-ready reporting workflow. You’ll also see complete TypeScript examples, SMTP configuration, and best practices for secure credential management.


Why Email Notifications Are Important in Test Automation

Automated email notifications improve communication across QA, development, and DevOps teams.

Benefits

  • Immediate visibility into test results
  • Faster defect investigation
  • Reduced manual effort
  • Improved release confidence
  • Easy sharing of execution artifacts
  • Better CI/CD feedback

Without automated notifications, teams often need to log in to CI/CD tools to inspect reports. Email summaries bring important information directly to recipients.


Understanding Playwright HTML Reports and Test Results

Playwright supports several reporting formats.

Report TypePurpose
HTMLInteractive execution report
JSONMachine-readable data
JUnit XMLCI/CD integration
ListConsole output
DotCompact console report

The HTML report includes:

  • Passed tests
  • Failed tests
  • Execution time
  • Error messages
  • Stack traces
  • Screenshots (when configured)
  • Trace links (when available)

Prerequisites (Node.js, Playwright, SMTP Service, CI/CD Tools)

Before implementing Playwright Test Report Email Notification, install:

  • Node.js
  • Playwright
  • TypeScript
  • NodeMailer
  • SMTP provider (Gmail, Outlook, or corporate SMTP)
  • Jenkins, GitHub Actions, or Azure DevOps (optional for CI/CD)

Install NodeMailer:

npm install nodemailer

Keep credentials out of your source code by using environment variables or CI/CD secrets.


Generating Playwright Test Reports

Configure reporting in playwright.config.ts.

import { defineConfig } from ‘@playwright/test’;

export default defineConfig({

  reporter: [

    [‘html’, { open: ‘never’ }],

    [‘json’, { outputFile: ‘reports/results.json’ }],

    [‘junit’, { outputFile: ‘reports/results.xml’ }]

  ],

  use: {

    screenshot: ‘only-on-failure’,

    video: ‘retain-on-failure’,

    trace: ‘retain-on-failure’

  }

});

What This Configuration Does

  • Generates an HTML report.
  • Produces JSON and JUnit XML reports.
  • Saves screenshots only for failed tests.
  • Keeps videos and trace files when failures occur.

This setup provides both human-readable and machine-readable reports.


Sending Reports Using NodeMailer

After the test execution finishes, use NodeMailer to send an email with the report.

import nodemailer from ‘nodemailer’;

async function sendReport() {

  const transporter = nodemailer.createTransport({

    host: process.env.SMTP_HOST,

    port: 587,

    secure: false,

    auth: {

      user: process.env.SMTP_USER,

      pass: process.env.SMTP_PASSWORD

    }

  });

  await transporter.sendMail({

    from: process.env.SMTP_USER,

    to: ‘qa-team@example.com’,

    subject: ‘Playwright Test Execution Report’,

    html: `

      <h2>Automation Execution Completed</h2>

      <p>Please find the attached Playwright report.</p>

    `,

    attachments: [

      {

        filename: ‘playwright-report.zip’,

        path: ‘./playwright-report.zip’

      }

    ]

  });

}

sendReport();

Step-by-Step Explanation

  1. Create an SMTP transporter.
  2. Read credentials from environment variables.
  3. Define recipients.
  4. Create an HTML email.
  5. Attach the report.
  6. Send the message.

Attaching HTML Reports, Screenshots, Videos, and Trace Files

Large teams often attach additional debugging artifacts.

Typical attachments include:

  • HTML report
  • JUnit XML
  • JSON report
  • Screenshots
  • Videos
  • Trace files
  • Execution logs

Example:

attachments: [

  {

    filename: ‘report.zip’,

    path: ‘./reports/report.zip’

  },

  {

    filename: ‘trace.zip’,

    path: ‘./traces/trace.zip’

  }

]

Compress reports and traces before attaching them to reduce email size.


Sending Email Notifications from Jenkins, GitHub Actions, and Azure DevOps

Jenkins

Typical workflow:

Developer Commit

        │

        ▼

Jenkins Pipeline

        │

        ▼

Playwright Tests

        │

        ▼

Generate HTML Report

        │

        ▼

Archive Artifacts

        │

        ▼

Send Email Notification

The Jenkins Email Extension Plugin can send emails after the pipeline completes. Include report links or attach archived artifacts depending on your organization’s email policies.


GitHub Actions

Example workflow:

name: Playwright Tests

on:

  push:

jobs:

  test:

    runs-on: ubuntu-latest

    steps:

      – uses: actions/checkout@v4

      – uses: actions/setup-node@v4

        with:

          node-version: 20

      – run: npm ci

      – run: npx playwright install –with-deps

      – run: npx playwright test

      – run: node sendReport.js

Store SMTP credentials in GitHub Secrets instead of committing them to the repository.


Azure DevOps

Typical workflow:

Code Commit

      │

      ▼

Azure Pipeline

      │

      ▼

Playwright Tests

      │

      ▼

Publish Reports

      │

      ▼

Send Notification

Azure DevOps securely stores SMTP credentials using pipeline variables or secret variable groups.


Customizing Email Templates and Test Summaries

Instead of sending a generic message, include useful execution details.

Example summary:

<h2>Playwright Execution Summary</h2>

<table border=”1″>

<tr>

<th>Total</th>

<th>Passed</th>

<th>Failed</th>

</tr>

<tr>

<td>150</td>

<td>147</td>

<td>3</td>

</tr>

</table>

You can also include:

  • Build number
  • Branch name
  • Commit ID
  • Environment
  • Execution duration
  • Report URL
  • Failed test names

These summaries help recipients understand results without opening the full report.


Handling Failed Tests and Conditional Notifications

Many teams only send email when tests fail.

Example logic:

if (failedTests > 0) {

  await sendReport();

}

You may choose different notification strategies:

ScenarioRecommendation
Every executionDaily smoke suites
Failures onlyLarge regression suites
Critical failuresHigh-priority production validation
Scheduled reportsWeekly automation summaries

This reduces unnecessary email volume while keeping important failures visible.


Enterprise Best Practices for Automated Reporting

For reliable Playwright Email Report workflows:

  • Generate HTML, JSON, and JUnit reports.
  • Archive screenshots, videos, and traces.
  • Store SMTP credentials in environment variables or CI/CD secrets.
  • Avoid hardcoded passwords.
  • Compress large artifacts.
  • Send concise email summaries.
  • Include links to CI/CD jobs.
  • Use conditional notifications for large regression suites.
  • Retain historical reports for trend analysis.
  • Review failed test artifacts before rerunning tests.

Common Errors and Troubleshooting

ProblemSolution
SMTP authentication failedVerify username, password, and SMTP settings
Email not deliveredCheck spam filters and recipient addresses
Report missingGenerate reports before sending the email
Attachment too largeCompress reports or publish them as pipeline artifacts
Secrets unavailableConfigure environment variables correctly
Broken report linksVerify artifact publishing paths

Troubleshooting Workflow

Email Failed

      │

      ▼

SMTP Settings

      │

      ▼

Authentication

      │

      ▼

Attachments

      │

      ▼

Pipeline Logs

      │

      ▼

Successful Delivery


Real-Time Enterprise Reporting Workflow Example

Imagine an e-commerce application with nightly regression tests.

Workflow

  1. Developer commits code.
  2. Jenkins starts the Playwright pipeline.
  3. Tests execute across Chromium and Firefox.
  4. HTML, JSON, and JUnit reports are generated.
  5. Screenshots and traces are archived.
  6. Failed test summary is prepared.
  7. NodeMailer sends an email to the QA and development teams.
  8. Recipients review the report and begin investigating failures.

This workflow minimizes manual effort and speeds up issue resolution.


Playwright Email Notification Interview Questions

  1. What is Playwright HTML Report?
  2. Why are email notifications useful in automation?
  3. What is NodeMailer?
  4. How do you install NodeMailer?
  5. How do you configure SMTP?
  6. How do you store SMTP credentials securely?
  7. Why use environment variables?
  8. What report formats does Playwright support?
  9. What is JUnit XML used for?
  10. How do you attach reports to emails?
  11. How do you attach screenshots?
  12. How do you attach trace files?
  13. What is Trace Viewer?
  14. How do you configure screenshots on failure?
  15. How do you configure video recording?
  16. How do you integrate Playwright with Jenkins?
  17. How do you integrate with GitHub Actions?
  18. How do you integrate with Azure DevOps?
  19. What are conditional email notifications?
  20. Why send emails only on failures?
  21. How do you reduce email attachment size?
  22. How do you debug email delivery issues?
  23. What enterprise practices improve reporting?
  24. How do you archive reports?
  25. How would you explain your reporting workflow in an interview?

FAQs

Can Playwright send email reports directly?

Playwright generates reports, but email delivery is typically handled by tools such as NodeMailer or by CI/CD platform integrations.

Which report format should I use?

HTML reports are ideal for manual review, while JSON and JUnit XML are commonly used for integrations and automation.

Is NodeMailer the only option?

No. NodeMailer is a popular choice for Node.js projects, but organizations may also use CI/CD plugins, cloud email services, or internal notification systems.

How should I store SMTP credentials?

Use environment variables or secret management features provided by your CI/CD platform. Avoid hardcoding credentials in your source code.

Should I email reports after every run?

That depends on your workflow. Many teams send reports only when failures occur or provide a summary after scheduled regression runs to reduce email noise.

What if my report is too large?

Compress the report, publish it as a pipeline artifact, or include a link to the report instead of attaching large files.

Leave a Comment

Your email address will not be published. Required fields are marked *