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 Type | Purpose |
| HTML | Interactive execution report |
| JSON | Machine-readable data |
| JUnit XML | CI/CD integration |
| List | Console output |
| Dot | Compact 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
- Create an SMTP transporter.
- Read credentials from environment variables.
- Define recipients.
- Create an HTML email.
- Attach the report.
- 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:
| Scenario | Recommendation |
| Every execution | Daily smoke suites |
| Failures only | Large regression suites |
| Critical failures | High-priority production validation |
| Scheduled reports | Weekly 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
| Problem | Solution |
| SMTP authentication failed | Verify username, password, and SMTP settings |
| Email not delivered | Check spam filters and recipient addresses |
| Report missing | Generate reports before sending the email |
| Attachment too large | Compress reports or publish them as pipeline artifacts |
| Secrets unavailable | Configure environment variables correctly |
| Broken report links | Verify 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
- Developer commits code.
- Jenkins starts the Playwright pipeline.
- Tests execute across Chromium and Firefox.
- HTML, JSON, and JUnit reports are generated.
- Screenshots and traces are archived.
- Failed test summary is prepared.
- NodeMailer sends an email to the QA and development teams.
- Recipients review the report and begin investigating failures.
This workflow minimizes manual effort and speeds up issue resolution.
Playwright Email Notification Interview Questions
- What is Playwright HTML Report?
- Why are email notifications useful in automation?
- What is NodeMailer?
- How do you install NodeMailer?
- How do you configure SMTP?
- How do you store SMTP credentials securely?
- Why use environment variables?
- What report formats does Playwright support?
- What is JUnit XML used for?
- How do you attach reports to emails?
- How do you attach screenshots?
- How do you attach trace files?
- What is Trace Viewer?
- How do you configure screenshots on failure?
- How do you configure video recording?
- How do you integrate Playwright with Jenkins?
- How do you integrate with GitHub Actions?
- How do you integrate with Azure DevOps?
- What are conditional email notifications?
- Why send emails only on failures?
- How do you reduce email attachment size?
- How do you debug email delivery issues?
- What enterprise practices improve reporting?
- How do you archive reports?
- 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.
