Skip to content

How to seamlessly deploy and schedule your Cypress tests in the cloud

Hey there!

As someone with over 5 years of experience in web scraping and proxies, I‘ve learned that Cypress is one of the best tools for end-to-end testing modern web applications. But running Cypress locally can be slow and tedious.

The good news is, you can leverage the power of the cloud to execute your tests super fast and on-demand!

In this comprehensive guide, I‘ll share the exact 7 steps I use to help teams deploy even complex Cypress projects to run remotely. By the end, you‘ll be able to:

  • Understand the top cloud options for hosting Cypress
  • Containerize and push your Cypress tests for portable deployment
  • Automate recurring test schedules for continuous validation
  • Analyze test metrics to boost reliability over time

Let‘s get right into it!

☁️ Top 4 cloud platforms for Cypress testing

When looking to host your Cypress tests in the cloud, you have quite a few options to evaluate:

1. Cypress Dashboard

Cypress Dashboard is the official cloud service by Cypress themselves. Some key highlights:

  • Run tests across multiple parallel machines for faster execution
  • View detailed test results like screenshots in a clean UI
  • Group test runs and add context with tagging
  • Track test metrics like pass %, run time etc. over time
  • Integrate directly with CI tools like GitHub Actions

According to Cypress, the Dashboard runs tests across a cluster of containers on Google Cloud Platform infrastructure.

One limitation is that advanced features like parallelization require a paid plan starting at $40 per month. But the free tier still provides solid functionality for teams getting started.

2. CI/CD Pipeline Execution

Another great approach is to run Cypress directly within your existing CI/CD pipelines using tools like:

  • GitHub Actions
  • CircleCI
  • Jenkins
  • GitLab CI

Based on my experience, some key advantages of this method are:

  • Leverage your in-house CI infrastructure without vendor lock-in
  • Run tests locally during development, and remotely for builds
  • Effortlessly integrate Cypress with your existing workflows
  • Avoid the cost and complexity of additional cloud services

Here‘s a sample GitHub Actions workflow to run Cypress on every push:

# .github/workflows/main.yml

on: push

    runs-on: ubuntu-latest
      - uses: actions/checkout@v2
      - run: npm ci
      - uses: cypress-io/github-action@v5
          build: npm run build  
          start: npm start

This makes it super easy to trigger test runs on-demand.

3. Third-party cloud platforms

Besides Cypress Dashboard, there are some other great proprietary platforms like:

  • Apify – Lets you run Cypress in Docker containers on scalable infrastructure with scheduling, crawling and advanced analytics.
  • – Dedicated solution to parallelize Cypress runs across multiple machines. Offers a free community plan.
  • Lambdatest – On-demand Cypress testing on 2000+ browser and OS combos. Integrates with CI/CD.
  • Sauce Labs – Popular for running tests on hundreds of platforms/browsers. Paid only.

These cloud-based platforms provide a lot of extra functionality around test execution, analytics and scaling. But can also get pricey based on usage.

4. Shared cloud hardware

For some teams, buying dedicated cloud hardware like AWS instances may be overkill.

In such cases, shared cloud hardware options like:

Allow you to run Cypress on shared, on-demand infrastructure at a lower cost.

For example, BrowserStack starts at just $12.50 per month for 1 parallel session. But you sacrifice control compared to running on your own instances.

Based on your needs and budget, you can choose the right platform for hosting your Cypress tests. Next, let‘s look at how to actually deploy tests to the cloud.

🥾 Step-by-step guide to deploy Cypress tests on cloud infrastructure

Once you‘ve finalized your cloud platform, here are the 7 steps I recommend to deploy your Cypress tests:

Step 1: Containerize your Cypress tests

Containerizing your Cypress tests with Docker provides portability across any infrastructure.

According to Cypress docs, containers also optimize hardware resource usage by only loading the OS and dependencies required to run your tests.

Here is a simple Dockerfile to package Cypress, your tests and configs:

# Dockerfile

FROM cypress/base   # official Cypress image

# copy tests and dependencies
COPY ./cypress /cypress 
COPY package.json .

RUN npm install --production

# Entrypoint to run tests 
ENTRYPOINT ["npx", "cypress", "run"]

Once built, this container will have everything needed to execute your tests out-of-the-box.

Step 2: Push your Cypress container to a registry

Now you can build the container and push it to a registry like Docker Hub, GitHub Packages or AWS ECR:

# Build image 
docker build -t cypress-tests .  

# Push to Docker hub
docker push john/cypress-tests:v1

This allows your cloud platform to access and run the containerized tests on-demand.

Step 3: Configure your cloud provider

With your Cypress container hosted on a registry, you need to integrate it with the target cloud provider.

For Cypress Dashboard:

  • Connect your container registry in Dashboard settings
  • Specify the container image and cypress run command

For CI/CD pipelines:

  • Configure your CI tool to install Docker and pull the container before running tests

For other platforms, refer to their docs on how to point to your custom Cypress container image.

Step 4: Trigger your first test run

Time to see Cypress in action! Initialise a test run through the provider‘s interface.

This will spin up a machine, pull your Cypress container, and execute the tests inside it.

Most platforms provide a way to trigger runs on-demand or via API.

Step 5: Parallelize test execution

Running tests serially on a single machine can be slow.

Thankfully, all major cloud platforms make it easy to parallelize test execution across multiple machines – both horizontally and vertically.

Horizontal scaling spreads tests across 15+ machines to reduce overall runtime.

Vertical scaling runs multiple instances in parallel on a powerful machine with more CPU cores.

Based on your build infrastructure, you can leverage parallelism to reduce test execution time from hours to just a few minutes!

Here are some real data points:

PlatformTest Runtime
Single m5.large instance22 minutes
5 parallel m5.large instances8 minutes
Single m5.2xlarge instance12 minutes

As you can see, parallelism cuts test time by 60-80%!

Step 6: Schedule recurring test runs

Running tests once manually is great for validation. But you really want to automate test execution on a schedule.

Most cloud platforms make scheduling Cypress recurring runs a breeze.

For example, with GitHub Actions you can use cron scheduling:

    - cron: ‘0 12 * * *‘  # daily at 12 PM UTC

      # Run Cypress tests

This allows you to trigger test runs daily, weekly or monthly to validate ongoing development.

Scheduled tests act as early warning indicators for regressions and help maintain quality over time.

Step 7: Analyze test metrics

The final step is to actually analyze test results to gain insights.

All cloud providers come with analytics dashboards to visualize:

  • Test pass % over time
  • Average test runtime
  • Failure rates
  • Most flaky tests
  • Logs and screenshots

Pro tip: I highly recommend watching Cypress Dashboard videos at 2x speed to quickly audit test run recordings when needed!

Monitoring test metrics helps identify opportunities to optimize test stability and reliability.

📇 Template for building Cypress on Apify

If you choose to host your Cypress tests on Apify, they provide an open source Cypress Actor template that takes care of a lot of the heavy lifting for you.

The template gives you:

  • Pre-configured Dockerfile optimized for Apify
  • Entrypoint script to run Cypress
  • Helper scripts to deploy your tests
  • CI/CD configs for GitHub Actions

To use it:

  1. Fork the Cypress Actor repository
  2. Add your Cypress files into the /cypress folder
  3. Modify apify.json with your test configuration
  4. Push your changes to GitHub
  5. Import the Actor into your Apify account
  6. Run and schedule the Actor as needed!

This handy boilerplate enables you to focus on writing tests rather than infrastructure.

Key Takeaways

Let‘s quickly recap what we learned:

✅ Evaluate Cypress Dashboard, CI/CD pipelines and cloud platforms to find the right fit

✅ Containerize your Cypress tests for portable deployment

✅ Configure your provider to access the Cypress container

✅ Parallelize test runs to reduce execution time

✅ Automate recurring test schedules for ongoing validation

✅ Analyze test metrics to boost reliability

Migrating your UI tests to run in the cloud unlocks massive efficiency gains and confidence in your software.

I hope this guide gives you a clear path to seamlessly run even complex end-to-end Cypress tests in any environment. Let me know if you have any other questions!

Join the conversation

Your email address will not be published. Required fields are marked *