Look, No Strings! Puppeteer, Jest, and Sauce Labs

Posted May 12, 2020

Sauce Labs Rubiks Cube

Over the years software tools, testing frameworks, and development practices have evolved to meet new challenges. This shift means testing is happening earlier in the software development lifecycle with developers increasingly taking on more responsibility for testing with a focus on speed. That’s why we’re excited to announce the expansion of our developer-first test capabilities.   

At SauceCon Online, we will be introducing a Puppeteer + Jest native javascript solution in beta. The Sauce Testrunner Toolkit beta is already fully cloud CI/CD ready and connects to the entire Sauce Labs platform. The roadmap is rich with plans for supporting additional open source frameworks. Our goal is to bring you a magical test experience based on years of platform and runtime experience.  

What is Sauce Testrunner Toolkit?

Sauce Testrunner Toolkit makes setting up, writing, running, and debugging web tests easier and faster for developers during early pipeline testing. It has everything you need to run end-to-end tests. We’ve compiled a container with Chrome and Firefox browsers pre-installed and also includes all types of automation frameworks like Puppeteer and Playwright with support for Cypress coming soon. With a single command, you can execute tests from your laptop and report data to the Sauce Labs public cloud for further analysis. Or if you want to test on more than Chrome and Firefox (ie: mobile), you can run the Sauce Testrunner Toolkit on our platform where the test would be executed close to the virtual machine to speed up test execution.

diagram showing the testrunner toolkit

Why Puppeteer + Jest?

As a Developer, QE, SDET, or Automation Engineer we are all looking for the same thing.  We want a solution that is easy to maintain, fast, deterministic, and well adopted. We want the benefit of community and all of the support, improvement, and engagement that goes with it.  For years, Selenium and Appium have fit this description. And they still do. But they are not alone. Puppeteer, Playwright, and others have shifted left and are also providing developers the type of magical test experience that QA and QEs find in Selenium and Appium. Today we start with Puppeteer, tomorrow we will add more.

Why Open Source?

At Sauce Labs, we believe in more than just using open source software (OSS). Sauce Labs maintains a strong contributor connection to OSS as well as to critical standards bodies that make the internet great. Puppeteer and Jest fit this model. Puppeteer is a broadly adopted OSS project, born at Google, that enables developers to do just about anything with a Chromium browser. Jest is a widely used “delightful JavaScript Testing Framework with a focus on simplicity.” Together they are easy to use in any toolchain that involves a browser.

How Does it Work?

In the global developer survey by GitLab, testing was identified as one of the key pain points that hasn’t been solved. This is as much because the definition of test has changed as it is that our underlying toolchains have changed dramatically. DevOps, continuous integration, and continuous delivery are no longer unusual terms. We’ve therefore taken a purposefully lightweight, open, approach that you can easily expand on. Let’s dig in.

  1. Use standard Jest and Puppeteer to write your tests. There isn’t a lot to it. Here is an example that simply visits our demo app and verifies the page title is “Swag Labs”:

An example of how pipeline testing can be used.

2. We’ve introduced a new Sauce Labs entity called saucectl. The new saucectl is a binary that you can use to run tests locally or to execute tests in an arbitrary Pipeline. The commands are simple such as saucectl run. By using a single CLI tool you will be able to run your framework of choice preconfigured with Sauce Labs. This eliminates any setup time and lets you focus on writing tests.

3. For those of you using a cloud CI/CD tool, we have a variety of Docker images available to use. Each Docker image contains everything you need to start testing. Just add your Sauce Labs credentials and your CI pipeline is connected to Sauce! Our example repo has both a GitHub Actions workflow template and a CircleCI config template.  If you are using something else, don’t worry. Just instantiate the container and execute  saucectl run or download the binary and go from there.  Either will work.

4. Navigate to your Sauce Labs account to see not only the test you ran but also the visual output, and your test analytics. Speaking of analytics, now would be a good time to take a look at Failure Analysis too. We designed our new capabilities to automatically link to the AI/ML capabilities, called Failure Analysis, that find common problems across tests from any source.  Have a flaky API or test, Failure Analysis can tell you where it is happening regardless of where the test executed - mobile, functional browser, or native pipeline.

5. Actually that’s it. We did a lot more, but those are the keys to getting started.

What’s Next?

Where do we go from here? Well, we have a lot that we are excited about. Join us at SauceCon Online during our keynote session to hear more about our future direction and in the Containerized Testing with Puppeteer session to see a demo, and learn how you can start using this new native javascript test capability. Or if you’d rather dive right in, check out our Github repo to get started right away with the beta version. Happy testing!

Written by

Matthew Wyman

Topics

Continuous testingProgramming languagesSoftware Testing