Responsive

How to run front-end tests on your Kubernetes apps

Last updated
February 7, 2024
Alejandra Thomas
Developer Advocate
Testkube

Table of Contents

Get Started with Testkube Pro

Testing is a crucial aspect of software development, ensuring that applications meet their requirements and perform as expected. Luckily, with modern testing advancements, testing our applications can be pretty intuitive as we have enough resources and tools available to guide us through it. In the world of Kubernetes, however, where containerized applications are orchestrated and deployed at scale, testing can become a little tricky. 

In this article, we'll explore front-end testing of Kubernetes applications using Testkube, a testing framework designed for Kubernetes environments. We'll illustrate this with a simple web app deployed to a local Kubernetes cluster using Minikube.

Pre-requisites

To follow this tutorial, you’ll need the following:

  • Docker
  • A Kubernetes cluster up and running (you can use Minikube, as we will in this article)
  • A web application using your tools of choice
  • A Testkube account. You can sign up here

For this tutorial, I’ll show you how I’m creating a very simple web app. You can of course use any you already have available, for which you’ll only need to write your Dockerfile to deploy it to your cluster.

Let’s take a look at a simple web application we created with Node.js:

Our app will have two components, `header.html` and `main.html`. 

We’ll now write the Dockerfile for it to be able to deploy it into our cluster:

Let’s build, deploy it, and get the service URL:

```sh

minikube service hellokube --url

```

Once you open the provided URL, you should be able to access your web app.

Now, let’s write a few tests for our application. We’ll be using three different testing tools to illustrate a more realistic scenario where we rely on different frameworks. In this case, we’ll use Cypress, Playwright, and SoapUI.

Cypress Test

Cypress is a powerful end-to-end testing framework. An example of a Cypress test for our web app can look like this:

Playwright Test

Playwright is a testing library that allows us to automate different browsers. We’ll use it to interact with our web application’s components: 

SoapUI

SoapUI is a widely used API testing tool. While primarily designed for API testing, it can also be used for web service testing. Let’s use a SoapUI test that simply checks the response of our header and main content:

Now that we have our test cases, running them locally should be no issue. You can do this through the frameworks’ UIs or through your terminal. But as we’re dealing with an app that’s deployed in Kubernetes, we need to use a different approach.

Running Front-End Tests from within your Kubernetes Cluster

Running tests from within your Kubernetes cluster involves setting up testing infrastructure within the cluster itself. Typically, you would deploy testing tools as part of your testing environment. 

For this, you would need to configure your own testing system and environment that’s integrated with your CI/CD pipeline, package all of your test scripts and other dependencies into Docker images, and provide the necessary access to your application, as well as putting a tool or system into place to store and retrieve test results.

Fortunately for us, Testkube can help us speed run through all these configurations.

Using Testkube for Front-End Testing

Testkube simplifies the process of running tests within your Kubernetes cluster by providing a Kubernetes-native system. With Testkube, you can create, manage, and execute tests using Custom Resource Definitions (CRDs) and a user-friendly dashboard. Let's explore how Testkube streamlines the testing workflow:

  1. Start by setting up Testkube 

Sign into Testkube, create an environment, and follow the instructions to install the Testkube Agent into your cluster.

  1. Start running your tests

Now all you need to do is tell Testkube where your project and your tests are. Testkube will do the rest.

To do this, head over to Add a New Test.

In this view, let’s add a name to our test, and assign the type for each of the tests we want to run or have already created.

Testkube comes with pre-existing testing types - which include Cypress, Playwright, and SoapUI, too. 

Let’s create our Cypress test first, for which we can use a repository as our source:

Once we fill in these details, our test is ready to be run. Simply click on it on the dashboard and then Run.

As we can see, our test is running successfully!

By clicking on the execution, you can see the logs in real time and run your test as many times as you wish. What’s even better is that you also get to customize the test definition, schedule it, and access the artifacts produced when running the test suite:

As you run your tests over time, you’ll be gathering analytics that you can automatically retrieve from the dashboard:

Now, let’s repeat the same process for our Playwright and SoapUI tests. 

Create a test > Run the test > Check the execution results

Both of these tests should be running successfully:

And that’s it - that’s how simple it is to bring your front-end tests to the cloud!

Conclusion

Testing front-end applications in Kubernetes clusters presents unique challenges, but with the right approach and tools, you too can overcome these hurdles. Cloud-based testing, coupled with Kubernetes-native tools like Testkube, offers a comprehensive solution to ensure that you’re still safeguarding the reliability and quality of your applications.

Get started with Testkube and experience all the features that it brings to the table! You can also join our Slack community for guidance and support.

About Testkube

Testkube is a test execution and orchestration framework for Kubernetes that works with any CI/CD system and testing tool you need, empowering teams to deliver on the promise of agile, efficient, and comprehensive testing programs by leveraging all the capabilities of K8s to eliminate CI/CD bottlenecks, perfecting your testing workflow. Get started with Testkube for free.

Responsive

How to run front-end tests on your Kubernetes apps

Last updated
February 7, 2024

Table of Contents

Get Started with Testkube Pro

Testing is a crucial aspect of software development, ensuring that applications meet their requirements and perform as expected. Luckily, with modern testing advancements, testing our applications can be pretty intuitive as we have enough resources and tools available to guide us through it. In the world of Kubernetes, however, where containerized applications are orchestrated and deployed at scale, testing can become a little tricky. 

In this article, we'll explore front-end testing of Kubernetes applications using Testkube, a testing framework designed for Kubernetes environments. We'll illustrate this with a simple web app deployed to a local Kubernetes cluster using Minikube.

Pre-requisites

To follow this tutorial, you’ll need the following:

  • Docker
  • A Kubernetes cluster up and running (you can use Minikube, as we will in this article)
  • A web application using your tools of choice
  • A Testkube account. You can sign up here

For this tutorial, I’ll show you how I’m creating a very simple web app. You can of course use any you already have available, for which you’ll only need to write your Dockerfile to deploy it to your cluster.

Let’s take a look at a simple web application we created with Node.js:

Our app will have two components, `header.html` and `main.html`. 

We’ll now write the Dockerfile for it to be able to deploy it into our cluster:

Let’s build, deploy it, and get the service URL:

```sh

minikube service hellokube --url

```

Once you open the provided URL, you should be able to access your web app.

Now, let’s write a few tests for our application. We’ll be using three different testing tools to illustrate a more realistic scenario where we rely on different frameworks. In this case, we’ll use Cypress, Playwright, and SoapUI.

Cypress Test

Cypress is a powerful end-to-end testing framework. An example of a Cypress test for our web app can look like this:

Playwright Test

Playwright is a testing library that allows us to automate different browsers. We’ll use it to interact with our web application’s components: 

SoapUI

SoapUI is a widely used API testing tool. While primarily designed for API testing, it can also be used for web service testing. Let’s use a SoapUI test that simply checks the response of our header and main content:

Now that we have our test cases, running them locally should be no issue. You can do this through the frameworks’ UIs or through your terminal. But as we’re dealing with an app that’s deployed in Kubernetes, we need to use a different approach.

Running Front-End Tests from within your Kubernetes Cluster

Running tests from within your Kubernetes cluster involves setting up testing infrastructure within the cluster itself. Typically, you would deploy testing tools as part of your testing environment. 

For this, you would need to configure your own testing system and environment that’s integrated with your CI/CD pipeline, package all of your test scripts and other dependencies into Docker images, and provide the necessary access to your application, as well as putting a tool or system into place to store and retrieve test results.

Fortunately for us, Testkube can help us speed run through all these configurations.

Using Testkube for Front-End Testing

Testkube simplifies the process of running tests within your Kubernetes cluster by providing a Kubernetes-native system. With Testkube, you can create, manage, and execute tests using Custom Resource Definitions (CRDs) and a user-friendly dashboard. Let's explore how Testkube streamlines the testing workflow:

  1. Start by setting up Testkube 

Sign into Testkube, create an environment, and follow the instructions to install the Testkube Agent into your cluster.

  1. Start running your tests

Now all you need to do is tell Testkube where your project and your tests are. Testkube will do the rest.

To do this, head over to Add a New Test.

In this view, let’s add a name to our test, and assign the type for each of the tests we want to run or have already created.

Testkube comes with pre-existing testing types - which include Cypress, Playwright, and SoapUI, too. 

Let’s create our Cypress test first, for which we can use a repository as our source:

Once we fill in these details, our test is ready to be run. Simply click on it on the dashboard and then Run.

As we can see, our test is running successfully!

By clicking on the execution, you can see the logs in real time and run your test as many times as you wish. What’s even better is that you also get to customize the test definition, schedule it, and access the artifacts produced when running the test suite:

As you run your tests over time, you’ll be gathering analytics that you can automatically retrieve from the dashboard:

Now, let’s repeat the same process for our Playwright and SoapUI tests. 

Create a test > Run the test > Check the execution results

Both of these tests should be running successfully:

And that’s it - that’s how simple it is to bring your front-end tests to the cloud!

Conclusion

Testing front-end applications in Kubernetes clusters presents unique challenges, but with the right approach and tools, you too can overcome these hurdles. Cloud-based testing, coupled with Kubernetes-native tools like Testkube, offers a comprehensive solution to ensure that you’re still safeguarding the reliability and quality of your applications.

Get started with Testkube and experience all the features that it brings to the table! You can also join our Slack community for guidance and support.

About Testkube

Testkube is a test execution and orchestration framework for Kubernetes that works with any CI/CD system and testing tool you need, empowering teams to deliver on the promise of agile, efficient, and comprehensive testing programs by leveraging all the capabilities of K8s to eliminate CI/CD bottlenecks, perfecting your testing workflow. Get started with Testkube for free.