DEV Community

Natasha Lekh for Apify

Posted on • Originally published at blog.apify.com on

How to deploy and schedule your Cypress tests in the cloud

If you're already using Apify and have Cypress code that needs a home, you're in luck. We created Cypress Test Runner to make running Cypress tests in the Apify cloud a breeze.

If you're already using Apify and have Cypress code that needs a home, you're in luck. We created Cypress Test Runner to make running Cypress tests on the Apify cloud platform a breeze. Let's see how you can use it.

☁️Cloud alternatives for testing

When it comes to running your Cypress tests in the cloud, there are a few options available:

  1. Cypress Cloud and its alternatives. Cypress Cloud provides a hosted solution for running your Cypress tests, allowing you to easily execute your tests on a remote infrastructure. There are also open-source alternatives for running Cypress tests and collecting test results.

  2. Run it in CI/CD pipelines. Integrating your Cypress tests into your CI/CD pipelines is another effective approach tested and used by us here at Apify on a daily basis. By plugging your tests into your existing processes, such as to GitHub Actions, you can seamlessly incorporate testing into your development workflow.

Example of our CI/CD pipeline we have on GitHub

Example of our CI/CD pipeline we have on GitHub

🥾Guide on how to deploy and schedule Cypress tests in the cloud

If you want to set regular runs for your Cypress tests in the Apify cloud, follow these steps:

Step 1. Choose Cypress Test Runner

Cypress Test Runner Actor card in Apify Store

Step 1. Choose Cypress Test Runner

Head over to Apify Store and search for Cypress. You'll find the Cypress Test Runner 🔗. Click Try for free and sign in using your email to get started.

Step 2. Record or write your tests

An example of exporting a test made through Cypress Test Recorder

How to record a Cypress test using Cypress Recorder

Of course, you can add manually written tests as well. But by using the Cypress Test Recorder extension, you can make your test writing a bit faster. Check out our guide 🔗 on how to record your tests using the Cypress Recorder Extension in Chrome.

How to use Cypress Test Recorder

Is Cypress Recorder the tool to automate writing manual tests?

favicon blog.apify.com

Step 3. Export and paste your tests

Step 3. Export and paste your tests

After recording your tests, export them from the Recorder and paste the test code into Cypress Test Runner. This step allows you to set up the runner with your specific tests for execution.

Step 4. Start the run

Run result: one test failed and one test succeeded

Run result: one test failed and one test succeeded

Now click on Start and wait for the run to complete the test. Once your tests are done running, you'll see the Status of the run change to Succeeded or Failed. Note that if any of your Cypress tests fail, the whole run will be marked as Failed.

You can also check the full log of every test run.

Step 5. Check the dashboard

To see the test results just copy the dashboard link on top of the Run panel. The dashboard will provide you some valuable insights into your test runs, including detailed test results, metrics, and visual aid. You can use this information to analyze the performance and identify any issues or areas for improving your tests.

Step 5. Check the dashboard

Step 6. Save your run as a task

Step 6. Save your run as a task

Step 6. Save your run as a task

If you want to schedule your test to run on a regular basis, you'll have to create a Task. To create a Task, simply head for the Input of your Run and click Save input to new task.

Now name your task, tweak the Input if needed, and click Schedule.

Step 7. Schedule your test to run hourly, daily, etc.

One last thing left to do: choose how often you want the Cypress test to run (weekly, monthly, daily, hourly, custom time or by cron expression). Don't forget to pick your time zone so the run happens exactly when you need it to.

Step 7. Schedule your test to run hourly, daily, etc.

Step 7. Schedule your test to run hourly, daily, etc.

By following these steps with Cypress Test Runner, you can effortlessly deploy and schedule your Cypress tests in the Apify cloud. Enjoy the benefits of running your tests remotely, gaining valuable insights, and improving the quality of your software.

📇 Template for Cypress Actors

If you prefer to build your own Cypress Actor, we have a template available to help you get started. This template serves as the foundation for any container with Cypress tests (including the one this tutorial is about) and helps our users to create their own Cypress testing solutions faster. Try it and see if it helps you too!

Template for creating Cypress Actors

Top comments (0)