Synthetic Monitoring and E2E Testing - 2 Sides of the Same Coin

Rate this content
Bookmark
Slides

Over the last few years, there has been a great focus on shifting tests left to earlier in the software development cycle. It's great that the emergence of trends such as e2e testing has enabled us to validate the user workflow earlier. However, they do not eliminate the need to monitor this workflow against a live production system. I have seen that the segregation of development and support teams leads to both teams using different tools to build similar automation that simply targets different environments of the same software.
By joining forces, we can build automated scripts that can be used both for production monitoring and testing within CI. In this talk, I will discuss the causes of this cultural divide, and why this needs to change for us to shift user testing both left and right. Furthermore, I shall show how this can be achieved using Playwright and Elastic Synthetics and also chat through the challenges you may face shifting left and right.

This talk has been presented at React Summit 2023, check out the latest edition of this React Conference.

Watch video on a separate page

FAQ

Development and operations teams often use different tools due to historical separations in team responsibilities, prioritization, and lack of communication. For example, developers might use Cypress for testing, while SREs might use Selenium for integration into their observability platforms. This separation can hinder collaboration and efficiency.

Using common tooling, such as Elastic Synthetics with Playwright, allows DevOps and SRE teams to use the same scripts for both testing and monitoring, fostering better collaboration, ensuring consistency, and streamlining workflows across development and production environments.

To set up a project, first install the Elastic Synthetics Playwright wrapper via NPM. Use the init wizard to create a sample project structure that includes synthetic configs and TypeScript journey examples. Teams can then write their own tests, run them locally or in CI pipelines, and deploy them to monitor production applications.

Integrating testing and monitoring tools allows for continuous validation and monitoring of applications, leading to quicker detection of defects, better understanding of user interactions, and improved overall quality of applications. This integration also supports a more agile and responsive development environment.

Cultural challenges in DevOps include departmental silos, competing priorities, and lack of communication and empathy between development and SRE teams. These challenges can lead to resistance when adopting new collaborative practices or tools, impeding effective integration and cooperation.

By using Elastic Synthetics and Playwright, teams can create detailed documentation of the user journey and expected interactions with the application. This documentation is maintained alongside the code, allowing both developers and SREs to have a shared understanding and source of truth for application features and behaviors.

Synthetic monitoring and end-to-end testing are both methods used to ensure application performance and functionality, but they are often used at different stages of the development cycle. Synthetic monitoring involves running scripts to check the accessibility or functionality of an application periodically, while end-to-end testing uses automated tests to validate the user journey through the application. Combining these into a common tool can enhance both monitoring and testing capabilities.

Carly Richmond
Carly Richmond
9 min
06 Jun, 2023

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Carly Richards discusses the challenges of using different tools for synthetic monitoring and end-to-end testing, emphasizing the need for a unified approach with playwright and Elastic Synthetics. The Playwright API and Elastic Synthetics can be used together to create tests and monitoring tools, ensuring consistent user experience and documenting application features. By bringing development and SRE teams together and using a common tool, collaboration and defect identification can be improved.

1. Challenges of Tooling and the Need for Unification

Short description:

In this part, Carly Richards discusses the challenges of using different tools for synthetic monitoring and end-to-end testing. She explains how the lack of collaboration between development and operations teams, differing priorities, and the use of different tooling can hinder automation efforts. Carly emphasizes the need for a unified approach and introduces playwright and Elastic Synthetics as a solution. By utilizing these tools, teams can create scripted journeys that serve both as tests and monitoring tools, ensuring consistent user experience and documenting application features. Carly also provides an overview of the implementation process and highlights the importance of maintaining the monitors within a project structure.

Hi, everyone. It's great to see you at React Summit. My name is Carly Richards, I'm a developer advocate at Elastic. And I want to talk about synthetic monitoring and end-to-end testing. You might wonder why these things might seem totally different constructs. But despite the emergence of DevOps and SRE practices, and about trying to unite among custom workflows, I'm finding that, for various reasons, we're still using different tools to try and achieve rather similar levels of automation, albeit at different points in the development cycle.

I'm going to talk about my own experiences of why I think that happens. And then I'm going to show how we can unite alongside a common tooling by using embedded end-to-end testing within a synthetic monitoring tooling, to allow us to basically do both of these things using the exact same scripted journeys.

So I used to work in a bank before I joined Elastic, and for the majority of that time, I found that dev and ops were not as joined up as we'd like to say. They were basically warring factions with competing interests, and the emerging best practices from SRE and DevOps coming through the observability space often were picked up by production management, but it never really permeated back very easily into the developer side of the fence. And it took a lot of convincing for that to happen. And I honestly think that stemmed from three key reasons that sadly I think still exist and some way today. The first is that we often have Dev and SRE as separate departments or separate teams, rather than being part as one multidisciplinary team. And with the separate departments with competing agendas, lack of communication and empathy tends to build up, which can be a big problem because it causes each group to feel like when someone comes with an idea of how to collaborate together, that we're throwing things over the fence for the other to pick up and break the flow and basically call into question the direction in which we knew we were meant to build as a developer or as an SRE. The second is often that there isn't a common prioritisation between these two groups. SRE can often find minor defects or have ideas for automation or enhancements to the application ecosystem but quite often those are deprioritised and instead you'll have a product owner pushing for new features for users that developers will happily be going away to build and we don't ever address this balance. And the final challenge that I've seen the first hand as well is that often development production teams are using different tooling to achieve similar objectives. So in my last role at the bank we were actively using cypress for developing end-to-end tests meanwhile colleagues in SRE were writing similar automations in Selenium because it integrated into their observability platform and they could use it for periodic monitoring and checks against the production application. And it meant that we couldn't really use the end-to-end tests in production without either of us switching to a new tooling. And the reality is the end-to-end testing using automation frameworks to validate the user journey through automated tests and synthetic monitoring where we run periodic scripts to either check the accessibility or endpoints or the achievability of user behavior to make sure it's still operating correctly are effectively two sides of the same coin. And if we unite amongst a common tooling we can end up using these same scripts not only as testing and monitoring tools in the same application suites across different environments, but we can also use them as a common way of documenting the user journey and how we expect users to use their application features.

So using playwright and Elastic Synthetics we can do that. The way that this works as you'll see in grey going through each of the boxes is that we'll have JavaScript and TypeScript journey files that will basically utilize playwright to automate those interactions and run locally as end-to-end tests against a locally running web app. Then through peer review, we can run the same monitors as end-to-end tests within the GitHub actions CI pipeline or any other CI provider that you're using. Once we get to deployment stage of our app, we can then push these same monitors using our own API key into the appropriate location, either the Elastic-specific location or our own running private location, to do the monitoring instead against the production web application, which will then store the results within Elasticsearch and make available the dashboards in Kibana so that we can actually see what's going on.

So how do we get started with this? Well, we need to create a project to house these monitors so that they can be maintained within source control using from both parties. The easiest way to do that is using the init wizard after installing the Elastic Synthetics Playwright wrapper via NPM. It'll give you a sample project structure looking like this, which will include synthetics configs for the specific configuration for the project and some example monitors including the TypeScript journeys that you can see there under the journeys folder. We then are able to write our own behavioral tests building on the examples using Elastic Synthetics. You'll see here on the top that the page object which is the playwright page object is exposed within our journey and also within each stick.

2. Using Playwright API and Elastic Synthetics

Short description:

We can use the Playwright API to locate elements, perform actions, and make assertions to ensure the expected results. These tests can be run locally and in CI pipelines, and the same definitions can be pushed to production using Elastic Synthetics. SRE audiences can monitor the state and track performance over time. By bringing development and SRE teams together and using a common tool, we can collaborate, identify defects, and build better applications. Thank you for attending React Summit!

And we can make use of the Playwright API to do things like locate elements via CSS selector, which you can see on line 16, by the various helper attributes introduced in versions 2017 and later, such as get by test ID. We can perform clicks and actions that a user would against these appropriate HTML elements and then we can perform various assertions to see that the appropriate result is showing there.

And then we can run these locally and make sure that all of the changes associated with our new feature are passed. We can then run the same things within our CI pipelines as well and then we can push those same definitions to production to the Elastic Synthetics location which will allow you to run those same tests as monitors against your production application.

Then SRE audiences can monitor the state. They can see the basic pings, they can see as highlighted in the background of these cards what the duration has been over time using the chart in the background. Then when things go wrong we can actually see the individual steps, we can see what particular expectations or errors happened and we can then do smart things like have alerts or anomaly detections to try and pick up if there's perhaps a degradation in performance if these particular tests are taking longer as per our trends.

So for me DevOps is always meant to be about bringing the dev and the SRE factions together. We need to leave that cultural baggage behind that's been sitting for so long and work together and if we use a common tool there's some great benefits to be afforded in terms of documenting the user journey, collaborating together, to pick up defects in testing and in production and just generally best building better applications for users.

So thank you so much it's been great speaking here at React Summit. Hopefully I get to catch you around the conference and if not feel free to check out the code example on the QR code on the screen or you can also contact me with any questions at currentlyellrichmond.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Testing Web Applications with Playwright
TestJS Summit 2022TestJS Summit 2022
20 min
Testing Web Applications with Playwright
Top Content
Watch video: Testing Web Applications with Playwright
Testing web applications with Playwright, a reliable end-to-end testing tool. Playwright offers fast execution, powerful tooling, and support for multiple languages. It provides precise selectors, web-first assertions, and code generation for easy testing. Playwright also offers features like live debugging, tracing, and running tests on CI. The future of Playwright aims to make testing easy and fun, with a focus on creating frustration-free web experiences.
Full-Circle Testing With Cypress
TestJS Summit 2022TestJS Summit 2022
27 min
Full-Circle Testing With Cypress
Top Content
Cypress is a powerful tool for end-to-end testing and API testing. It provides instant feedback on test errors and allows tests to be run inside the browser. Cypress enables testing at both the application and network layers, making it easier to reach different edge cases. With features like AppActions and component testing, Cypress allows for comprehensive testing of individual components and the entire application. Join the workshops to learn more about full circle testing with Cypress.
Everyone Can Easily Write Tests
TestJS Summit 2023TestJS Summit 2023
21 min
Everyone Can Easily Write Tests
Playwright is a reliable end-to-end testing tool for modern web apps that provides one API, full isolation, fast execution, and supports multiple languages. It offers features like auto-weighting, retrying assertions, seamless testing of iframes and shadow DOM, test isolation, parallelism, and scalability. Playwright provides tools like VS Code extension, UiMode, and Trace Viewer for writing, debugging, and running tests. Effective tests prioritize user-facing attributes, use playwright locators and assertions, and avoid testing third-party dependencies. Playwright simplifies testing by generating tests, providing code generation and UI mode, and allows for easy running and debugging of tests. It helps in fixing failed tests and analyzing DOM changes, fixing locator mismatches, and scaling tests. Playwright is open source, free, and continuously growing.
Tiny Tests, Large Results
TestJS Summit 2022TestJS Summit 2022
21 min
Tiny Tests, Large Results
Automated atomic tests are a great way to improve UI tests by making them less brittle and faster. The tests focus on testing a single feature or component and have minimal UI interactions. The Talk explores examples of automated atomic tests and their implementation on web applications. It also discusses the analysis of atomic tests, login tests, and working with JSON Web Tokens for authentication and authorization. The Talk concludes by highlighting the use of UI and web requests in automated atomic testing.
We May Not Need Component Testing
Vue.js Live 2024Vue.js Live 2024
26 min
We May Not Need Component Testing
Component testing is a gray area between integration and unit testing. The demo app focuses on the cart component and writing test cases for Playwright component test and VTest. The first cart test encounters a bug with the invisible method in View Test.
Testing Mail Service With Playwright
TestJS Summit 2022TestJS Summit 2022
17 min
Testing Mail Service With Playwright
Top Content
Watch video: Testing Mail Service With Playwright
This Talk discusses how to test mail service with Playwright, covering e-mail verification, reset password user journey, and more. It explores the use of third-party providers for reliable e-mail delivery and demonstrates how Playwright can help perform checks on e-mail content. The Talk also introduces the concept of a fake SMTP server and showcases how fixtures can be used to access the SMTP server and perform assertions on the HTML body of emails. Playwright's HTML rendering feature allows for interaction with email content as if it were a regular web page. It highlights the ability to render HTML from API calls, perform assertions on the rendered page, and exclude dynamically generated data from visual regression tests.

Workshops on related topic

Detox 101: How to write stable end-to-end tests for your React Native application
React Summit 2022React Summit 2022
117 min
Detox 101: How to write stable end-to-end tests for your React Native application
Top Content
WorkshopFree
Yevheniia Hlovatska
Yevheniia Hlovatska
Compared to unit testing, end-to-end testing aims to interact with your application just like a real user. And as we all know it can be pretty challenging. Especially when we talk about Mobile applications.
Tests rely on many conditions and are considered to be slow and flaky. On the other hand - end-to-end tests can give the greatest confidence that your app is working. And if done right - can become an amazing tool for boosting developer velocity.
Detox is a gray-box end-to-end testing framework for mobile apps. Developed by Wix to solve the problem of slowness and flakiness and used by React Native itself as its E2E testing tool.
Join me on this workshop to learn how to make your mobile end-to-end tests with Detox rock.
Prerequisites- iOS/Android: MacOS Catalina or newer- Android only: Linux- Install before the workshop
Testing Web Applications Using Cypress
TestJS Summit - January, 2021TestJS Summit - January, 2021
173 min
Testing Web Applications Using Cypress
WorkshopFree
Gleb Bahmutov
Gleb Bahmutov
This workshop will teach you the basics of writing useful end-to-end tests using Cypress Test Runner.
We will cover writing tests, covering every application feature, structuring tests, intercepting network requests, and setting up the backend data.
Anyone who knows JavaScript programming language and has NPM installed would be able to follow along.
Building out a meaningful test suite that's not all E2E
TestJS Summit 2023TestJS Summit 2023
89 min
Building out a meaningful test suite that's not all E2E
Workshop
David Burns
David Burns
We're all taught to follow the Testing Pyramid but the reality is that we build out the Testing Christmas Tree. In this workshop, David will talk you through how to break down projects and put the tests where they need to be. By the end of the workshop you will be able to update your projects so that anyone and everyone can start contributing and truly living up to "Quality is everyone job".
He will walk you through:- Component Testing- API Testing- Visual Regression Testing- A11Y testing
He will also talk you through how to get these all setup in your CI/CD pipeline so that you can get shorter and faster feedback loops.
Live e2e test debugging for a distributed serverless application
TestJS Summit 2021TestJS Summit 2021
146 min
Live e2e test debugging for a distributed serverless application
WorkshopFree
Serkan Ozal
Oguzhan Ozdemir
2 authors
In this workshop, we will be building a testing environment for a pre-built application, then we will write and automate end-to-end tests for our serverless application. And in the final step, we will demonstrate how easy it is to understand the root cause of an erroneous test using distributed testing and how to debug it in our CI/CD pipeline with Thundra Foresight.

Table of contents:
- How to set up and test your cloud infrastructure
- How to write and automate end-to-end tests for your serverless workloads
- How to debug, trace, and troubleshot test failures with Thundra Foresight in your CI/CD pipelines
Uniform Browser Automation Infrastructure
TestJS Summit - January, 2021TestJS Summit - January, 2021
127 min
Uniform Browser Automation Infrastructure
Workshop
Ivan Krutov
Ivan Krutov
In this workshop, I will show you how to quickly deploy and use browser automation infrastructure with Moon solution. We will start deploying everything on your workstation and will soon be able to run Selenium, Playwright and Puppeteer tests in parallel in the same cluster. Then I will demonstrate how to easily deliver the same experience for your team using a remote cluster in the cloud platform.