E2E Testing in Production with Playwright and Checkly
We all do testing. We all test code as we write it, and before we release it. But somehow regressions, bugs and even downtime still happens. Code that worked perfectly on our laptop somehow fails when it meets production, and in ways so obscure that simple integration tests, even canary deploys, don’t catch every failure. When we want to ensure reliable software, traditional testing methods often fall short at monitoring real-world scenarios. Enter Playwright and Checkly, two powerful tools that enable end-to-end (E2E) testing in production. In this guide, we’ll explore how these tools work together to provide robust monitoring and testing solutions, ensuring your application performs flawlessly for end users.The Problem: Monitoring in a Complex World
Modern software systems are no longer simple. With the rise of cloud-native technologies, microservices, and distributed systems, applications have become more complex than ever. Front-end frameworks like React and Angular, each implementing modeling that’s more complex than an entire 2010 web application, have added further edge cases and wrinkles. Questions like ‘if this microservice goes down, will users still be able to add items to their cart?’ are harder to answer than ever.

Why Traditional QA Falls Short
Traditional QA processes, including unit tests and end-to-end tests, are essential but often stop at the pre-production stage. Once the application goes live, monitoring takes over, typically handled by a different team using different tools. This disconnect between QA and monitoring creates gaps in visibility and reliability.
- Can we agree that no level of pre-deployment QA will catch every failure? And if so,
- Is it acceptable that everything not caught by QA will have to be found and reported by a user?

Enter Playwright: A Modern Browser Automation Tool
Playwright is Microsoft’s open-source browser automation framework that simplifies end-to-end testing. It supports multiple platforms and provides a robust API for interacting with web pages and APIs. Here’s why Playwright stands out:- Web-First Locators and Assertions: Playwright uses web-first locators, making it easier to interact with dynamic web elements without relying on brittle CSS selectors.
- Automatic Retries and Waits: Playwright automatically retries actions and waits for elements to be visible, reducing flaky tests.
- Powerful Debugging Tools: Playwright provides traces, videos, and screenshots to help diagnose issues quickly.
- API Testing: Beyond browser automation, Playwright can also handle API testing, making it a versatile tool for end-to-end workflows.
- Detailed Assertions: No more do we call every
200 OK
response a passing test, Playwright can make complex, programmatic assertions about the responses it receives, checking things like ‘every loaded record has a connected ID’ or ‘all buttons are set to be a brand-approved color’
Testing in Production with Playwright and Checkly
While Playwright excels at browser automation, Checkly takes it a step further, automating runs of Playwright tests and enabling monitoring as code. Checkly enables you to run and schedule Playwright tests against production environments, providing real-time insights into your application’s health. Run a Playwright test every hour or every minute from locations all across the globe, all managed from a workflow that fits into your current CI/CD model, rather than requiring a cumbersome interface to manage monitors.Key Features of Checkly:
- Global Test Execution: Run your Playwright scripts from multiple geographic locations to ensure your application performs well for users worldwide.
- Monitoring Cadence: Run tests every minute or every hour, and set a monitoring cadence that defends your SLA
- Alerting and Notifications: Set up alerts via email, Slack, PagerDuty, or other channels to notify your team of failures.
- Connect Backend Traces: With Checkly Traces, harness the power of OpenTelemetry to see backend traces connected to each testing session.
- Code Workflow Integration: Manage your monitoring scripts as code, enabling version control, collaboration, and CI/CD integration.
A Practical Example: Monitoring an E-Commerce Workflow
Let’s say you’re running an e-commerce platform. Any regression, missing feature, or unavailability means users can’t check out on your site, so even a few minutes of a problem costs your business money. A critical user journey might involve:- Logging into the application.
- Searching for a product.
- Adding the product to the cart.
- Checking out.
- Write the Playwright Script: Automate the login, product search, and checkout steps. Run initial tests through the Checkly network to make sure it’s working from all your users’ geo locations.
- Configure Monitoring Settings: Define how often the script should run (e.g., every 15 minutes) and from which locations (e.g., Ireland, Frankfurt).
- Set Up Alerts: Notify your team if the script fails, ensuring quick resolution of issues.
- Deploy to Production: Use Checkly’s CLI to deploy the script and start monitoring your production environment.
- Use Hooks to Clean Up After Tests: If you’ve run a real ecommerce site you’d know, you can’t have your database clogged with test run data, throwing off your analytics, but with Checkly and playwright you can use hooks to make sure that each test makes the necessary calls to clean up after itself.