End-to-end testing of your Kubernetes applications with Cypress

April 29, 2022
Est. reading time:
6 min.
Manage and run end-to-end Cypress testing in Kubernetes and access Cypress recorded videos easily with Testkube!
Abdallah Abedraba
Developer Advocate
Monokle, Kusk
Table of Contents
End-to-end testing of your Kubernetes applications with Cypress

## Cypress Test Runner

What is Cypress? [Cypress](https://www.cypress.io/) is a framework for making end-to-end tests of your applications, mostly used for front-end testing. When you run your Cypress tests, a browser is spun up so you can assert against it in an automatic way that, for example, when a button in your UI is clicked the desired behavior is correctly executed. Cypress can then record the test execution and provide you with a video of what happened with the actual test.

Traditionally when working with Kubernetes, you would run your Cypress tests in your Continuous Integration pipeline, and if you wanted to extract the videos recorded by Cypress, you would need to set up a complicated system of saving those videos in an external storage service like S3, with all the authentication, authorization and networking setups needed just to extract the recorded videos. 

## Testkube: Solution to Cypress Testing in Kubernetes

What is Testkube? **[Testkube](https://testkube.kubeshop.io/), a test execution framework for Kubernetes, solves these issues by running tests from inside your Kubernetes clusters**, saving the generated videos and providing a simple way to access the videos without exposing to the public unnecessary parts of your Kubernetes cluster.

At the end of this post, you will know how to create a Cypress test, add it through Testkube to your Kubernetes cluster, execute the test and access the resulting video of your Cypress tests.

## Cypress Tutorial

### 1- Install Testkube CLI

Follow the instructions for your machine [here](https://kubeshop.github.io/testkube/installing/#install-the-kubectl-testkube-plugin).

### 2- Install Testkube in your cluster

-- CODE language-bash --
kubectl testkube install

### 3- Create a Cypress test

We have setup a repository with a simple Cypress test which you can find and clone [here](https://github.com/aabedraba/testkube-cypress). We will use that repository to create our Testkube tests from. 

Following the pattern of having your tests in a git repository allows you to reap the benefits of a GitOps-based testing environment.

For more GitOps-based testing environments in Testkube, check out the blog ["GitOps-Powered Kubernetes Testing Machine"](https://kubeshop.io/blog/a-gitops-powered-kubernetes-testing-machine-with-argocd-and-testkube).

Now let’s create the test. You can replace the <span style="background-color:#efecf4; font-family:Consolas,sans-serif; font-size:11pt; color:#585260; ">--git-uri</span> link to match your repository if you have cloned our example repository

-- CODE language-bash --
kubectl testkube create test --git-uri
https://github.com/aabedraba/testkube-cypress.git --git-branch main --name
cypress-example --type cypress/project

### 4- Open the Testkube dashboard

Let’s continue our walkthrough from the dashboard, although you can run all these steps from the CLI as well! 

-- CODE language-bash --
kubectl testkube dashboard

### 5- Run your Cypress test

From the dashboard, go to the *Tests* section, click on our newly created test cypress-example, and Run. 

Testkube will run the Cypress commands for you to trigger the tests, and… wait! It takes some minutes to run, depending on your machine. 

### 6- Check out the test result and extract the recorded video

Click on the test execution and go to *Artifacts* section where you will find the video recorded by Cypress to download!

And the resulting video looks like the following

## More on End-to-End Testing

You could also [run your tests from your CI/CD pipelines](https://kubeshop.github.io/testkube/testkube-automation/) using the Testkube CLI or by triggering them manually. Testkube decouples your test execution from being strictly dependant on the CI/CD pipeline, allowing you to run tests both as part of your builds and for ad-hoc validation of your applications.

We support more integration test frameworks like Postman, K6 (for load testing) and many more. You can even incorporate your favorite testing tool by [creating your own Testkube executor](https://kubeshop.github.io/testkube/executor-custom/). The Testkube team aims to include most testing tools to improve integration tests in the Kubernetes realm!

You can also make use of [Testkube webhooks](https://kubeshop.github.io/testkube/cli/kubectl-testkube_create_webhook/) to connect your test execution results to Slack or any notification service. 

Check Testkube on [GitHub](https://github.com/kubeshop/testkube) — and let us know if you’re missing something we should be adding to make your k8s integration testing easier.

* [Download the latest release on GitHub](https://github.com/kubeshop/testkube/releases)
* Check out the [documentation](https://kubeshop.github.io/testkube/)
* Get in touch with us on our [Discord server](https://discord.gg/uNuhy6GDyn) 

Thank you!


Recent Articles

Subscribe to stay up to date by getting the blog direct to your inbox
Or join the Kubeshop Community in one of these channels