Integrating Jenkins in your automated tests for CI/CD.

Cedric Damian
Practical Software Testing
4 min readNov 23, 2021

--

In this article, we will be covering the following areas:

  1. The importance of using Jenkins in your test automation
  2. How to Setup Jenkins with an automated test suite using NodeJs.

Why is Jenkins important for your test automation?

  • First, it provides numerous plugins for an array of frameworks such as Selenium, Cucumber, Appium, WebdriverIO, etc. These plugins can be integrated into CI pipelines to run automated tests for every build.
  • Most of these plugins will summarise your test results and display them neatly as you will see later in the article.
  • Jenkins provides various options for reporting your test results such as Allure and JUnit.

Due to this and more reasons, Jenkins is popular and has over 1.65 million users worldwide.

Now that you know why Jenkins is popular, let’s get into the flesh of this.

How to set up Jenkins in an automated test suite using NodeJs.

  1. Download Jenkins and set up an account.
  2. Create a new item and choose the ‘Freestyle Project’ option.

3. Link your Github repository by choosing the ‘Git’ option and pasting it in the URL input. For this tutorial, fork this repo and get going.

4. Schedule your build to run at 08:30 in the morning, from Monday to Friday. Under the ‘Build Triggers’ section, select the ‘Build periodically’ option. We will use cron expressions to set our schedule in the input box.

5. Install the NodeJs Plugin by opening <your_jenkins_url>/pluginManager/availableand searching for the plugin.

6. Once installed, you will need to refresh your Jenkins instance by opening ‘<your_jenkins_url>/pluginManager/advanced’ and clicking the ‘Check Now’ button at the bottom right of the page. For some instances, you might need to restart Jenkins for this effect to take place

7. Once the plugin is installed, back to the configuration of your project. Click the ‘Provide Node & npm bin/ folder to PATH’ option under ‘Build Environment’ and choose the name of the plugin you just installed. This will enable you to run your test scripts automatically from Jenkins.

8. Choose the ‘Execute shell’ option under ‘Add Build Step’ and add these two commands. npm install and npm run test . When your build is triggered, these commands will be executed. Your project’s dependencies will be installed and the test script will run.

9. Save your configurations and a new workspace will be created for you.

10. Click ‘Build Now’ and refresh the page to see your first build.

11. Open the build, and choose ‘Console Output’ on the left side. This will show you detailed information about your tests as they execute and show the results of your tests too. A cool clean way to debug!

That brings us to the end of this article. I hope you found it useful in setting up Jenkins in your project.

Cheers!

--

--

Cedric Damian
Practical Software Testing

QA Automation Engineer || Frontend Developer || Lover of Life