| name | synthetic-monitoring |
| description | Implement synthetic monitoring and automated testing to simulate user behavior and detect issues before users. Use when creating end-to-end test scenarios, monitoring API flows, or validating user workflows.
|
Synthetic Monitoring
Table of Contents
Overview
Set up synthetic monitoring to automatically simulate real user journeys, API workflows, and critical business transactions to detect issues and validate performance.
When to Use
- End-to-end workflow validation
- API flow testing
- User journey simulation
- Transaction monitoring
- Critical path validation
Quick Start
Minimal working example:
const { chromium } = require("playwright");
class SyntheticMonitor {
constructor(config = {}) {
this.baseUrl = config.baseUrl || "https://app.example.com";
this.timeout = config.timeout || 30000;
}
async testUserFlow() {
const browser = await chromium.launch();
const page = await browser.newPage();
const metrics = { steps: {} };
const startTime = Date.now();
try {
let stepStart = Date.now();
await page.goto(`${this.baseUrl}/login`, { waitUntil: "networkidle" });
metrics.steps.navigation = Date.now() - stepStart;
stepStart = Date.now();
await page.fill('input[name="email"]', "test@example.com");
await page.fill('input[name="password"]', "password123");
Reference Guides
Detailed implementations in the references/ directory:
Best Practices
✅ DO
- Test critical user journeys
- Simulate real browser conditions
- Monitor from multiple locations
- Track response times
- Alert on test failures
- Rotate test data
- Test mobile and desktop
- Include error scenarios
❌ DON'T
- Test with production data
- Reuse test accounts
- Skip timeout configurations
- Ignore test maintenance
- Test too frequently
- Hard-code credentials
- Ignore geographic variations
- Test only happy paths