test.allTheThings() with Cypress and TestCafe

Posted Jul 16, 2020

Multiple screens of code

We have expanded support for two more “developer-focused” testing frameworks: Cypress and TestCafe. See what's new in our Sauce Testrunner Toolkit—and how it can help developers realize the benefits of early pipeline testing as quality shifts left.

Earlier this year, Sauce Labs announced the release of our newest product to expand developer-first capabilities: Sauce Testrunner Toolkit. Currently in a free beta, it makes setting up, writing, and running web tests easier and faster for developers during early pipeline testing. This is the first in a number of updates to our platform that empower developers with the tools they need to achieve quality at scale.

But to realize that goal, we understand that we must meet developers where they are from a tooling perspective. This is why we also revealed support for Puppeteer in the same announcement, and soon after added Playwright. Today our team is thrilled to announce that we have expanded support for two more “developer-focused” testing frameworks: Cypress and TestCafe!

Introducing Cypress and TestCafe

Cypress and TestCafe logos

Cypress and TestCafe are open source testing frameworks for development teams. They contain tools that make it easy for developers to set up, write, run and debug tests. The Sauce Labs Testrunner Toolkit will create a containerized environment, so you can easily use these frameworks for quick test setup and execution without having to rely on any servers or drivers, and you never have to leave the terminal to achieve it!

For developers, using these frameworks really allows them to realize the benefits of early pipeline testing as quality shifts left, and take more ownership of the quality of the code they create. Using these frameworks in conjunction with Testrunner Toolkit provide even more value, including: 

  • Accelerate release velocity - Sauce Testrunner Toolkit allows for developers to execute tests on a preconfigured Docker container in Chrome and Firefox from their local machine. This allows for decreased testing times, instant feedback, and more productive developers, which in turn accelerates release speeds.

  • CI Integrations - with integrations via GitLab, GitHub, Travis or CircleCI, developers can also run tests in Testrunner Toolkit as part of their CI/CD pipeline. This allows them to plug tests into already-existing infrastructure, and avoids unnecessary load on their side.

  • Debugging and Insights - with access to the Sauce Labs platform, developers have the ability to pinpoint the reason for test failures with our suite of debugging tools (including video recordings, logs, and more). Combined with our Insights platform, which includes actionable data and recommendations to improve test efficiency, Sauce Labs provides a complete solution to help understand the quality of applications earlier in the software development lifecycle.

Getting Started

Testrunner Toolkit is easy to install, and is completely free! Here is a quick, 3-step setup guide straight from our documentation:

Requirements

  • Docker installed

  • Make sure the Docker daemon is running (e.g. docker info works in your terminal)

  • A Sauce Labs account; if you don't have one, start a free trial

 Installing Testrunner Toolkit

Using NPM:

npm i -g saucectl

You can also utilize our one line installer:

curl -L https://saucelabs.github.io/saucectl/install | bash

Would you like to inspect the content of our one line installer? Download it, have a look and execute it:

curl -fsSL -o get_saucectl.sh  https://saucelabs.github.io/saucectl/install
chmod 700 get_saucectl.sh
./get_saucectl.sh

Connecting to Sauce Labs

A Sauce Labs user name and access key are needed to post the test results. You can get your SAUCE_ACCESS_KEY from Account > User Settings in Sauce Labs.

To authenticate yourself, the following environment variables need to be set:

SAUCE_USERNAME
SAUCE_ACCESS_KEY

You can export them as follows:

export SAUCE_USERNAME=<your-username>
export SAUCE_ACCESS_KEY=<your-access-key>

If you are using a cloud CI/CD tool, we strongly suggest protecting these values through secrets or context variables.

After setup, you can use the new saucectl run command to run your tests in any of the supported frameworks, and then view the results in your Sauce Labs accounts. Here is a brief demo of how that works (using Cypress):

Cypress demo

To learn more about this, and how to run your first test, please reference the documentation on our GitHub repo, or take a look at this demo presentation from SauceCon 2020.

What’s Next

Today, developers using Sauce Labs Testrunner Toolkit can run tests on a local machine or through their CI/CD pipeline, as well as view results in the Sauce Labs UI. This means tests can be executed in only the Chrome and Firefox versions shipped with the pre-configured container provided by Sauce. In our next iteration, you will be able to configure tests from Testrunner Toolkit to execute in our virtual desktop cloud environment. This will give you access to hundreds of browser and OS combinations, as well as the ability to scale your efforts by running tests in parallel. This comprehensive coverage, along with the scalability to accelerate code velocity, will help developers truly embrace quality without sacrificing speed.

Try It For Yourself! 

Cypress and TestCafe are now both supported as a part of the Sauce Testrunner Toolkit beta, which is completely free! If you’d like to try it out for yourself, head over to our Github repo where you can get started right away.

Written by

Alissa Lydon