<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Panduka Wijekoon on Medium]]></title>
        <description><![CDATA[Stories by Panduka Wijekoon on Medium]]></description>
        <link>https://medium.com/@pandukawijekoon?source=rss-234000d22dba------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-0pdC2e5sQBRYU8tJWe0FA.png</url>
            <title>Stories by Panduka Wijekoon on Medium</title>
            <link>https://medium.com/@pandukawijekoon?source=rss-234000d22dba------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 05:49:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pandukawijekoon/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Simple Selenium Project]]></title>
            <link>https://pandukawijekoon.medium.com/simple-selenium-project-1be4be993898?source=rss-234000d22dba------2</link>
            <guid isPermaLink="false">https://medium.com/p/1be4be993898</guid>
            <category><![CDATA[page-object-model]]></category>
            <category><![CDATA[selenium-test-automation]]></category>
            <category><![CDATA[selenium-webdriver]]></category>
            <category><![CDATA[pagefactory]]></category>
            <category><![CDATA[selenium]]></category>
            <dc:creator><![CDATA[Panduka Wijekoon]]></dc:creator>
            <pubDate>Thu, 20 Aug 2026 17:18:28 GMT</pubDate>
            <atom:updated>2026-08-20T17:18:28.690Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7Lpa6Ay-0KKQBf-zOV8Vcw.png" /></figure><p>Creating a simple Selenium project using the POM design pattern, TestNG, property file reading, and Extent Test reporting.</p><p><strong>Step 1 -</strong><br>Creating Java Maven project (I’m using Eclipse as the IDE)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yAgxkxzmioYaMw6KyKlBog.png" /><figcaption>Go to File, New -&gt; Maven Project</figcaption></figure><p><strong>Step 2 -</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*h8dCGFPiyJpQzOZM-Zky4Q.png" /><figcaption>Select 1st 2 checkboxes and click on Next button</figcaption></figure><p><strong>Step 3 -</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*ARwLZwIeDJ9jDzCVPAuYPg.png" /><figcaption>Provide Group Id and Artifact Id, then click Finish button</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*UKCN9T8eRef7mGQ-MQmyXQ.png" /><figcaption>The Maven project is created as above with the folder structure</figcaption></figure><p><strong>Step 4 -</strong><br>Change the project java version to the latest version as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yyFIH7803nBZmSPohRQwwg.png" /></figure><p><strong>Step 5 -</strong><br>Add required dependencies for the project in pom.xml</p><pre>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;<br> xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;<br> xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;<br> &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;<br> &lt;groupId&gt;org&lt;/groupId&gt;<br> &lt;artifactId&gt;SeleniumAttptt&lt;/artifactId&gt;<br> &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;<br> &lt;dependencies&gt;<br>  &lt;dependency&gt;<br>   &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;<br>   &lt;artifactId&gt;selenium-java&lt;/artifactId&gt;<br>   &lt;version&gt;4.23.0&lt;/version&gt;<br>  &lt;/dependency&gt;<br>  &lt;dependency&gt;<br>   &lt;groupId&gt;io.github.bonigarcia&lt;/groupId&gt;<br>   &lt;artifactId&gt;webdrivermanager&lt;/artifactId&gt;<br>   &lt;version&gt;5.9.2&lt;/version&gt;<br>  &lt;/dependency&gt;<br>  &lt;dependency&gt;<br>   &lt;groupId&gt;org.testng&lt;/groupId&gt;<br>   &lt;artifactId&gt;testng&lt;/artifactId&gt;<br>   &lt;version&gt;7.7.1&lt;/version&gt;<br>   &lt;scope&gt;test&lt;/scope&gt;<br>  &lt;/dependency&gt;<br>  &lt;dependency&gt;<br>   &lt;groupId&gt;com.aventstack&lt;/groupId&gt;<br>   &lt;artifactId&gt;extentreports&lt;/artifactId&gt;<br>   &lt;version&gt;5.1.1&lt;/version&gt;<br>  &lt;/dependency&gt;<br> &lt;/dependencies&gt;<br>&lt;/project&gt;</pre><p>Refer this URL for more Maven repositories — <a href="https://mvnrepository.com/">https://mvnrepository.com/</a></p><p>Full project folder structure -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*d4L0U0iK-ktJMeiiUCCsZw.png" /></figure><p><strong>Step 6 -</strong><br>Adding the base test class -</p><p>BaseTest.java</p><pre>package utils;<br><br>import org.openqa.selenium.WebDriver;<br>import org.openqa.selenium.chrome.ChromeDriver;<br>import org.testng.ITestResult;<br>import org.testng.annotations.AfterMethod;<br>import org.testng.annotations.AfterTest;<br>import org.testng.annotations.BeforeMethod;<br>import org.testng.annotations.BeforeTest;<br><br>import com.aventstack.extentreports.ExtentReports;<br>import com.aventstack.extentreports.ExtentTest;<br>import com.aventstack.extentreports.reporter.ExtentSparkReporter;<br>import com.aventstack.extentreports.reporter.configuration.Theme;<br><br>import io.github.bonigarcia.wdm.WebDriverManager;<br>import pages.DashboardPage;<br>import pages.LoginPage;<br><br>public class BaseTest {<br><br> protected WebDriver driver;<br> protected LoginPage loginPage;<br> protected DashboardPage dashboardPage;<br> private ExtentReports extent;<br> private ExtentTest test;<br><br> @BeforeTest<br> public void beforeTest() {<br><br>  WebDriverManager.chromedriver().setup();<br>  driver = new ChromeDriver();<br>  driver.manage().window().maximize();<br>  ExtentSparkReporter htmlReporter = new ExtentSparkReporter(<br>    System.getProperty(&quot;user.dir&quot;) + &quot;/test-output/ExtentReport.html&quot;);<br>  htmlReporter.config().setDocumentTitle(&quot;Test Automation Report&quot;);<br>  htmlReporter.config().setReportName(&quot;Functional Test Report&quot;);<br>  htmlReporter.config().setTheme(Theme.STANDARD);<br>  extent = new ExtentReports();<br>  extent.attachReporter(htmlReporter);<br> }<br><br> @AfterTest<br> public void afterTest() {<br>  if (driver != null) {<br>   extent.flush();<br>   driver.quit();<br>  }<br> }<br><br> @BeforeMethod<br> public void beforeMethod(ITestResult result) {<br>  loginPage = new LoginPage(driver);<br>  dashboardPage = new DashboardPage(driver);<br>  test = extent.createTest(result.getMethod().getMethodName());<br> }<br><br> @AfterMethod<br> public void afterMethod(ITestResult result) {<br>  if (result.getStatus() == ITestResult.SUCCESS) {<br>   test.pass(&quot;PASS&quot;);<br>  } else if (result.getStatus() == ITestResult.FAILURE) {<br>   test.fail(result.getThrowable());<br>  } else if (result.getStatus() == ITestResult.SKIP) {<br>   test.pass(&quot;SKIP&quot;);<br>  }<br> }<br><br>}</pre><p><strong>Step 7 -</strong><br>Add a until file for reading values from property file,</p><p>configReader.java</p><pre>package utils;<br><br>import java.io.FileInputStream;<br>import java.util.Properties;<br><br>public class configReader {<br><br> private final static Properties prop = new Properties();<br><br> static {<br>  try {<br>   FileInputStream ip = new FileInputStream(&quot;src/test/resources/config.properties&quot;);<br>   prop.load(ip);<br>  } catch (Exception e) {<br>   e.printStackTrace();<br>  }<br> }<br><br> public static String getValue(String key) {<br>  return prop.getProperty(key);<br> }<br>}</pre><p><strong>Step 8 -</strong><br>Add the property file,</p><p>config.properties</p><pre>URL=https://opensource-demo.orangehrmlive.com/web/index.php/auth/login<br>USERNAME=Admin<br>PASSWORD=admin123</pre><p><strong>Step 9 -</strong><br>Add the test script,</p><p>LoginTest.java</p><pre>package tests;<br><br>import org.testng.Assert;<br>import org.testng.annotations.Test;<br><br>import utils.BaseTest;<br>import utils.configReader;<br><br>public class LoginTest extends BaseTest {<br><br> @Test(priority = 1, description = &quot;Verify login with valid credentials&quot;)<br> public void loginWithValidCredential() {<br><br>  loginPage.navigateToWebSite(configReader.getValue(&quot;URL&quot;));<br>  loginPage.loginWithValidCredentials(configReader.getValue(&quot;USERNAME&quot;), configReader.getValue(&quot;PASSWORD&quot;));<br><br>  String currentUrl = dashboardPage.getCurrentUrl();<br>  Assert.assertEquals(true, currentUrl.contains(&quot;/dashboards&quot;));<br>  <br> }<br>}</pre><p><strong>Step 10 -</strong><br>Add seperate java classes for each page according to the POM design pattern</p><p>DashboardPage.java</p><pre>package pages;<br><br>import org.openqa.selenium.WebDriver;<br><br>public class DashboardPage {<br><br> private WebDriver driver;<br><br> public DashboardPage(WebDriver driver) {<br>  this.driver = driver;<br> }<br><br> public String getCurrentUrl() {<br>  return driver.getCurrentUrl();<br> }<br>}</pre><p>LoginPage.java</p><pre>package pages;<br><br>import java.time.Duration;<br>import java.util.NoSuchElementException;<br><br>import org.openqa.selenium.By;<br>import org.openqa.selenium.WebDriver;<br>import org.openqa.selenium.support.ui.ExpectedConditions;<br>import org.openqa.selenium.support.ui.FluentWait;<br><br>public class LoginPage {<br><br> private WebDriver driver;<br> private FluentWait&lt;WebDriver&gt; wait;<br> private By usernameTxtFld = By.name(&quot;username&quot;);<br> private By passwordTxtFld = By.name(&quot;password&quot;);<br> private By loginBtn = By.xpath(&quot;//*[@id=\&quot;app\&quot;]/div[1]/div/div[1]/div/div[2]/div[2]/form/div[3]/button&quot;);<br><br> public LoginPage(WebDriver driver) {<br>  this.driver = driver;<br>  wait = new FluentWait&lt;WebDriver&gt;(driver)<br>    .withTimeout(Duration.ofSeconds(10))<br>    .pollingEvery(Duration.ofSeconds(1))<br>    .ignoring(NoSuchElementException.class);<br> }<br><br> public void navigateToWebSite(String url) {<br>  driver.get(url);<br> }<br><br> public void loginWithValidCredentials(String username, String password) {<br><br>  wait.until(ExpectedConditions.visibilityOfElementLocated(usernameTxtFld)).sendKeys(username);<br>  driver.findElement(passwordTxtFld).sendKeys(password);<br>  driver.findElement(loginBtn).click();<br> }<br>}</pre><p><strong>Step 11 -</strong><br>Creating the test suite,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*_RFOYQ9JYcldH-LeXz4IhQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*mUzS-k5tr_zaQQEVnCYYRA.png" /></figure><p>testng.xml</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;!DOCTYPE suite SYSTEM &quot;https://testng.org/testng-1.0.dtd&quot;&gt;<br>&lt;suite name=&quot;Suite&quot;&gt;<br>  &lt;test thread-count=&quot;5&quot; name=&quot;Test&quot;&gt;<br>    &lt;classes&gt;<br>      &lt;class name=&quot;tests.LoginTest&quot;/&gt;<br>    &lt;/classes&gt;<br>  &lt;/test&gt; &lt;!-- Test --&gt;<br>&lt;/suite&gt; &lt;!-- Suite --&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1be4be993898" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter UI Testing with Patrol Framework]]></title>
            <link>https://pandukawijekoon.medium.com/flutter-testing-using-patrol-2b0595935514?source=rss-234000d22dba------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b0595935514</guid>
            <category><![CDATA[flutter-automation]]></category>
            <category><![CDATA[patrol]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Panduka Wijekoon]]></dc:creator>
            <pubDate>Sun, 03 Aug 2025 18:12:11 GMT</pubDate>
            <atom:updated>2025-08-03T18:22:37.373Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W7mfhupEkHFy8Fp4T2Ox0g.png" /></figure><p>Patrol is a robust open-source testing framework developed by LeanCode that extends Flutter’s testing capabilities.</p><p>It empowers developers to interact with native platform features such as permission dialogs, notifications, WebViews, and device settings directly from Dart.</p><p>By enabling full end-to-end testing, Patrol makes it possible to test the entire app, including functionality that standard Flutter tests cannot reach.</p><p>In this tutorial, I’ll walk through the basics of integrating the Patrol framework into a simple Flutter app on the Android platform. This is a beginner-friendly guide to help you get started with end-to-end testing using Patrol.</p><p>The minimum requirement for the Patrol framework is,</p><p>Java Version — Minimum required: Java 11, Recommended: Java 17<br>Flutter Version — Minimum required: 3.7.0, Recommended: 3.13.0 or higher.<br>Android SDK version — Minimum required: 21 or higher.</p><p>Let’s start,</p><p><strong>Step 1 -<br></strong>Create a simple Flutter app</p><p>I used Android Studio for creating the Flutter app, but you can use any other IDE of your choice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yKUzNP59qJUwSGPJ4fbHKQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RTvBbO11awmibhyH2VY7kQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*gsWkwWa9pqSFw4vZz0ueKg.png" /></figure><p><strong>Step 2 -<br></strong>Run the Flutter app to ensure that the newly created project builds and launches without issues</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/1*Kl_ElR73qB1ZHaK6cnchXg.png" /></figure><p>For Patrol automation scripting, I’m using VS Code. However, feel free to use any IDE that you’re comfortable with.</p><p><strong>Step 3 -<br></strong>Install Patrol CLI</p><p>Execute below command on the VS Code terminal to installing Patrol CLI.</p><pre>  flutter pub global activate patrol_cli</pre><p><strong>Step 4 -<br></strong>Confirm that everything installed correctly and your development environment is properly set up</p><p>Execute below command on the VS Code terminal to verify the installation.</p><pre>patrol doctor</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*zqammXAqMdO0qUDVEflnsg.png" /></figure><p><strong>Step 5 -<br></strong>Add the patrol dependency in the dev_dependencies section of your pubspec.yaml file</p><p>Execute below command on the VS Code terminal to add the patrol dependency.</p><pre>flutter pub add patrol --dev</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*Uxar_gRsfLhJ1As9B0SwtQ.png" /></figure><p><strong>Step 6 -<br></strong>Create patrol section in your pubspec.yaml</p><pre>patrol:<br>  app_name: My Patrol App<br>  android:<br>    package_name: com.example.patroltest</pre><p>You can rename app_name as you like, and set package_name according to your project’s configuration.</p><p>To find the package_name, open the build.gradle file located in the android/app directory. The package_name is specified as applicationId under the defaultConfig section.</p><p>Now it’s time to integrate Patrol with the Android native layer of your Flutter project.</p><p><strong>Step 7 -<br></strong>Navigate to android/app/src/androidTest/java/com/example/myapp/ in your project directory. If these folders don’t exist, create them manually. Make sure to replace /com/example/myapp/ with the path that matches your app’s package name</p><p>For this project, the correct path is /com/example/patroltest/.</p><p>Create a file named MainActivityTest.java in the specified directory and paste the following code into it.</p><pre>package com.example.myapp; // replace &quot;com.example.myapp&quot; with your app&#39;s package<br><br>import androidx.test.platform.app.InstrumentationRegistry;<br>import org.junit.Test;<br>import org.junit.runner.RunWith;<br>import org.junit.runners.Parameterized;<br>import org.junit.runners.Parameterized.Parameters;<br>import pl.leancode.patrol.PatrolJUnitRunner;<br><br>@RunWith(Parameterized.class)<br>public class MainActivityTest {<br>    @Parameters(name = &quot;{0}&quot;)<br>    public static Object[] testCases() {<br>        PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation();<br>        // replace &quot;MainActivity.class&quot; with &quot;io.flutter.embedding.android.FlutterActivity.class&quot; <br>        // if in AndroidManifest.xml in manifest/application/activity you have<br>        //     android:name=&quot;io.flutter.embedding.android.FlutterActivity&quot;<br>        instrumentation.setUp(MainActivity.class);<br>        instrumentation.waitForPatrolAppService();<br>        return instrumentation.listDartTests();<br>    }<br><br>    public MainActivityTest(String dartTestName) {<br>        this.dartTestName = dartTestName;<br>    }<br><br>    private final String dartTestName;<br><br>    @Test<br>    public void runDartTest() {<br>        PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation();<br>        instrumentation.runDartTest(dartTestName);<br>    }<br>}</pre><p><strong>Step 8 -</strong><br>Navigate to the build.gradle.kts file located in the android/app directory of your project.</p><p>Add the following two lines to the defaultConfig section of the build.gradle.kts file.</p><pre>  testInstrumentationRunner = &quot;pl.leancode.patrol.PatrolJUnitRunner&quot;<br>  testInstrumentationRunnerArguments[&quot;clearPackageData&quot;] = &quot;true&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9TPF3jnkblNKoee7sBEk5A.png" /></figure><p>Add the following section inside the android block of your build.gradle.kts file.</p><pre>  testOptions {<br>    execution = &quot;ANDROIDX_TEST_ORCHESTRATOR&quot;<br>  }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*XH6VPntRyW-N6QOFbJzq-A.png" /></figure><p>Add this line to dependencies section.</p><pre>  androidTestUtil(&quot;androidx.test:orchestrator:1.5.1&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*CPmtVK_nYDdAXHANcaYq9Q.png" /></figure><p><strong>Step 9 -</strong><br>Create a simple integration test</p><p>First, create a folder named integration_test in the root directory of your project.</p><p>Then, paste the following code into a new file called integration_test/ example_test.dart.</p><pre>import &#39;package:flutter_test/flutter_test.dart&#39;;<br>import &#39;package:patrol/patrol.dart&#39;;<br>import &#39;package:patroltest2/main.dart&#39;;<br><br>void main() {<br>  patrolTest(<br>    &#39;counter state is the same after going to home and switching apps&#39;,<br>    framePolicy: LiveTestWidgetsFlutterBindingFramePolicy.fullyLive,<br>    ($) async {<br>      await $.pumpWidgetAndSettle(const MyApp());<br>      await $(#increment_floating_action_button).waitUntilVisible(timeout: Duration(seconds: 30));<br>      await $(#increment_floating_action_button).tap();<br>      await Future.delayed(const Duration(seconds: 5));<br>      await $.pumpAndSettle();<br>      expect($(&#39;1&#39;), findsOneWidget);<br>    },<br>  );<br>}</pre><p>In this script, I passed the MyApp() widget to the pumpWidgetAndSettle() function to launch the Flutter app.</p><p>Then, I wait for the floating Plus button to appear on the screen. Once it&#39;s visible, I tap on it, wait for 5 seconds, and then verify that the counter has incremented to &#39;1&#39;.</p><p><strong>Step 10 -<br></strong>In the lib/main.dart file, add a unique key to the floating Plus button widget to enable reliable identification during testing</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*xmVpMNJSZB5yQ-A6mETG3A.png" /></figure><p><strong>Step 11 -<br></strong>Run the test script on a connected Android device to verify that everything is working correctly</p><p>Execute below command on the VS Code terminal to run the test script.</p><pre>patrol test -t integration_test/example_test.dart</pre><p>You should see a test summary displaying the total number of test cases, along with how many passed and how many failed, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RVmK4EjnZ7fmzVHYoIdmKg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b0595935514" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[K6 performance script integrates with K6 Cloud]]></title>
            <link>https://pandukawijekoon.medium.com/k6-performance-script-integrates-with-k6-cloud-f8e13e57de31?source=rss-234000d22dba------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8e13e57de31</guid>
            <category><![CDATA[performance-testing]]></category>
            <category><![CDATA[grafana-cloud]]></category>
            <category><![CDATA[k6]]></category>
            <dc:creator><![CDATA[Panduka Wijekoon]]></dc:creator>
            <pubDate>Wed, 10 Jul 2024 16:58:23 GMT</pubDate>
            <atom:updated>2024-07-10T17:20:29.084Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PUieSqjQHCtx-QJLzBp8zw.jpeg" /></figure><p>In our previous article (<a href="https://pandukawijekoon.medium.com/api-performance-testing-using-k6-c662b91dd4a6">https://pandukawijekoon.medium.com/api-performance-testing-using-k6-c662b91dd4a6</a>), I discussed how to write a <strong>K6 </strong>performance script for testing <strong>API performance</strong>. In this article, I discuss how to integrate the <strong>K6 performance test script</strong> with the <strong>K6 Cloud</strong>.</p><p><strong>K6 Cloud</strong> now supports integration with <strong>Grafana</strong>. <strong>Grafana Cloud k6</strong>, a unified platform introduced by <strong>Grafana Labs</strong>, integrates the <strong>K6 performance testing</strong> experience directly into <strong>Grafana Cloud</strong>. This allows users to visualize and analyse test results in real-time using <strong>Grafana dashboards</strong>.</p><p>Let’s begin,</p><p><strong>Step 1 -</strong><br>Create an account on <strong>Grafana Cloud</strong></p><p>URL — <a href="https://grafana.com/auth/sign-up/create-user?pg=login">https://grafana.com/auth/sign-up/create-user?pg=login</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P-CdwL0k6ei8tpwEIcQWKw.png" /></figure><p><strong>Step 2 -</strong><br>Login to the <strong>Grafana Cloud</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U3CHMI62uefFfj8Ae3XE3g.png" /></figure><p><strong>Step 3 -</strong><br>Launch your Grafana Cloud by clicking the ‘<strong>Launch</strong>’ button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3c_VUZP4oz8IhU4XXYknWQ.png" /></figure><p><strong>Step 4 -</strong><br>Navigate to the <strong>K6 </strong>section by clicking the ‘<strong>Start Testing</strong>’ button</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hEpkQFesK5Ge1yFaX7yeuA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dXW1X-6u1u2fYbI2xQpoLg.png" /></figure><p><strong>Step 5 -</strong><br>Create a new project by clicking the ‘<strong>Create new project</strong>’ button under the ‘<strong>Projects</strong>’ section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fg89xp5kL6zHqIY4H34XCQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vijGnh1zqXnTNIrpGItpaQ.png" /></figure><p>You have to provide a <strong>unique name</strong> for the project and other information mentioned below as per your requirements.</p><ol><li><strong>Max VUh per month</strong> — The maximum number of concurrent users multiplied by the number of hours per month.</li><li><strong>Max VUs per test</strong> — The maximum number of concurrent users per test.</li><li><strong>Max duration per test — </strong>The maximum test execution duration per test.</li></ol><p>I provided the values mentioned below in the image as per my requirement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*q-rMjf7qrDQxEtZMWvfPqA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0DCgPZkiHSlMQeNklM6aug.png" /></figure><p><strong>Step 6 -<br></strong>Click on the ‘<strong>Create new test</strong>’ button to connect your test script with the <strong>K6 Cloud project</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P3gCQha1cGd2NzYu7iVvhQ.png" /></figure><p>Since we have already installed K6 locally, we can skip the ‘<strong>Install k6’</strong> step and continue from the ‘<strong>Authenticate’ </strong>step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4S8W2BJs7pdSaY9m08bq5w.png" /></figure><p>Execute the above command in your project’s terminal. By doing so, you can log in to the <strong>K6 Cloud</strong> through your project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*23WANNgdr9Jr8s_MQ_7Pbg.png" /></figure><p>Implement the ‘<strong>Create a script’</strong> step to connect your <strong>K6 test script</strong> with the <strong>K6 cloud project</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kd9O-QjAA662gUahn8hNEA.png" /></figure><p>Instead of copying the above mentioned JSON object ‘<strong>cloud</strong>’, paste the below mentioned object in your test script’s <strong>options </strong>section.</p><p>Replace the ‘<strong>projectID’ </strong>value with the created <strong>K6 cloud project id</strong>. You can rename the ‘<strong>name’ </strong>value as your wish.</p><pre>    ext: {<br>        loadimpact: {<br>            // Project: K6_CRUD<br>            projectID: 3704126,<br>            // Test runs with the same name groups test runs together.<br>            name: &#39;Test (09/07/2024-23:08:22)&#39;<br>        }<br>    }</pre><p>Here is an example,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wIQCoOn4woxcetiUAmPNVw.png" /></figure><p>Then, you can run the test by executing the ‘<strong>Run a test</strong>’ step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Apld59bgpsKosNi-gfIcng.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lky3Il5TC1iZeUhG_1nlfA.png" /></figure><p>While the test script is running, you can <strong>visualize </strong>and <strong>analyse test results</strong> in <strong>real-time</strong> on the <strong>K6 Cloud dashboard</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-u5lIDtfXBTJeoJPGsk7Kw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M14P4267CPr6lLLRT3Ww9g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8e13e57de31" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[API performance testing using K6]]></title>
            <link>https://pandukawijekoon.medium.com/api-performance-testing-using-k6-c662b91dd4a6?source=rss-234000d22dba------2</link>
            <guid isPermaLink="false">https://medium.com/p/c662b91dd4a6</guid>
            <category><![CDATA[k6]]></category>
            <category><![CDATA[api-performance-testing]]></category>
            <category><![CDATA[performance]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Panduka Wijekoon]]></dc:creator>
            <pubDate>Mon, 24 Jun 2024 17:49:17 GMT</pubDate>
            <atom:updated>2024-06-24T17:49:17.336Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, I’m discussing how to write a performance script for testing APIs using K6. K6 can be scripted using JavaScript and TypeScript, but in this project, I’m using JavaScript.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SDky8VMhiQKFgs98iPn_Bw.png" /></figure><p><strong>Step 1 -</strong><br>Downloading K6.</p><p>Use this link to download the K6 as per your OS <a href="https://k6.io/docs/get-started/installation/">https://k6.io/docs/get-started/installation/</a>.</p><p>Since I have a Windows OS, I’m using K6 official installer. You can choose other options as your wish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0KyUYDoyY74V1tttChpthQ.png" /></figure><p><strong>Step 2 -</strong><br>Installing K6.</p><p>Click on the downloaded file and go through the setup wizard by clicking ‘Next’ to complete the installation.</p><p>To ensure the K6 installation, open the command prompt and execute the ‘k6’ command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fMtO75kAz9QmKwBPWuvUTg.png" /></figure><p><strong>Step 3 — </strong><br>Create a repository on GitHub for the K6 project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5PpBQ7wyeDqG_Hq0WlWcww.png" /></figure><p><strong>Step 4 - </strong><br>Clone the repository to a local location</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V9lISqjKxW1nWQfhz-DrTg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uZkpJnu6uzhX-MsiEBpy6g.png" /></figure><p><strong>Step 5 -</strong><br>Create the required Get/Post API request.</p><p>I’m using <a href="https://designer.mocky.io/">https://designer.mocky.io/</a> website to create the required API request. We can use this API as a Get request or a Post request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DLnSeI9sTMIZwFKfQ7IM-g.png" /></figure><p>After completing the API creation, you can copy the URL from here,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ckfemZe7ZQtpF5jqf1sjOw.png" /></figure><p><strong>Step 6 -</strong><br>Create a JavaScript file named “get_api.js” and write the code below.</p><pre>import http from &#39;k6/http&#39;<br>import { check } from &#39;k6&#39;<br><br>export let options = {<br>    vus: 10,<br>    duration: &#39;10s&#39;,<br>    thresholds: {<br>        &#39;checks&#39;: [&#39;rate&gt;0.95&#39;]<br>    }<br>}<br><br>export default function () {<br><br>    let url = &#39;https://run.mocky.io/v3/47565135-e942-4c4d-9818-6e4812045f39&#39;<br><br>    let headerParams = {<br>        headers: {<br>            &#39;Content-Type&#39;: &#39;application/json&#39;<br>        }<br>    }<br><br>    const response = http.get(url, headerParams)<br><br>    check(response, {<br>        &#39;is status 200&#39;: (r) =&gt; r.status === 200,<br>        &#39;is message success&#39;: (res) =&gt; JSON.parse(res.body).message == &quot;hello world&quot;<br>    })<br><br>    let body = JSON.parse(response.body)<br>    console.log(&#39;body is &#39;, JSON.stringify(body))<br>    console.log(&#39;message : &#39;, body.message)<br>    console.log(&#39;code : &#39;, body.code)<br><br>}</pre><p>In this script, I used the <strong>Get API URL</strong> created in the previous step as the calling API. <br>In that API request, I have mentioned that the content type of the request as ‘<strong>application/json</strong>’.<br>By using <strong>get </strong>function of the <strong>http</strong>, I’m calling the API and storing the API response in <strong>response </strong>variable.</p><p>I’m using <strong>checks </strong>to validate that the <strong>status code</strong> is <strong>200 </strong>and the value of the <strong>message </strong>field in <strong>API response </strong>is equal to “<strong>hello world</strong>” <strong>.</strong></p><p>In the <strong>options </strong>section, we can specify the <strong>virtual users (vus)</strong> and the execution <strong>duration </strong>that we plan implement. For this test, I’m using <strong>10 virtual users</strong> and the test runs for <strong>10s</strong>.</p><p>I’m using <strong>thresholds </strong>to determine whether the test passes or fails based on the <strong>success rate of the checks. </strong>Here, the <strong>pass rate of the checks</strong> should be <strong>above 95%</strong> for the test to pass. The <strong>thresholds </strong>works as <strong>assertions </strong>in <strong>K6</strong>.</p><p>Finally I printed the values of the response body. To do that, first we have to convert the API response into <strong>JSON </strong>object since the response is received as a <strong>String</strong>.</p><p><strong>Step 7-</strong><br>Run the “get_api.js” script</p><p>In your terminal, execute the following K6 command to run the script.</p><pre>k6 run get_api.js </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WC9cMdYgveY7MgwsMmFcJA.png" /></figure><p>After the test execution is completed, all the matrics are listed in the terminal, including max VUs, duration, iterations, iteration durations, checks status, etc.</p><p><strong>Step 8-</strong><br>Create a JavaScript file named “post_api.js” and write the code below.</p><pre>import http from &#39;k6/http&#39;<br>import { check } from &#39;k6&#39;<br><br>export let options = {<br>    vus: 10,<br>    duration: &#39;10s&#39;,<br>    thresholds: {<br>        &#39;checks&#39;: [&#39;rate&gt;0.95&#39;]<br>    }<br>}<br><br>export default function () {<br><br>    let url = &#39;https://run.mocky.io/v3/47565135-e942-4c4d-9818-6e4812045f39&#39;<br><br>    let headerParams = {<br>        headers: {<br>            &#39;Content-Type&#39;: &#39;application/json&#39;<br>        }<br>    }<br><br>    let payload = JSON.stringify({<br>        email: &quot;test@gmail.com&quot;,<br>        password: &quot;1234@#$&quot;<br>    })<br><br>    const response = http.post(url, payload, headerParams)<br><br>    check(response, {<br>        &#39;is status 200&#39;: (r) =&gt; r.status === 200,<br>        &#39;is message success&#39;: (res) =&gt; JSON.parse(res.body).message == &quot;hello world&quot;<br>    })<br><br>    let body = JSON.parse(response.body)<br>    console.log(&#39;body is &#39;, JSON.stringify(body))<br>    console.log(&#39;message : &#39;, body.message)<br>    console.log(&#39;code : &#39;, body.code)<br><br>}</pre><p>This <strong>Post API script</strong> is almost similar to the <strong>Get API script</strong> that we discussed previously. The only difference is that, I have added a <strong>payload </strong>for the <strong>Post request</strong>.</p><p>Here, I have created a <strong>JSON object</strong> containing <strong>email </strong>and <strong>password </strong>fields. Then, I have converted the <strong>JSON </strong>object into a <strong>String </strong>the using <strong>stringify </strong>function. If we don’t convert the<strong> payload object</strong> into a <strong>String</strong>, the <strong>Post request</strong> will not work.</p><p><strong>Step 9 -</strong><br>Run the “post_api.js” script</p><p>In your terminal, execute the following K6 command to run the script.</p><pre>k6 run post_api.js</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tRzlISPxc_JA3UCLjq5upw.png" /></figure><p>Similar to the <strong>get_api.js</strong> script, after the <strong>post_api.js</strong> test execution is completed, all the metrics are listed in the terminal including, max VUs, duration, iterations, iteration durations, checks status, etc.</p><p><strong>Step 10 - </strong><br>Commit the changes to the GitHub repository</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HuqJDzb-VxCLltUoz3byJw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c662b91dd4a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a simple cypress project with TypeScript from scratch]]></title>
            <link>https://pandukawijekoon.medium.com/creating-a-simple-cypress-project-with-typescript-from-scratch-b4581e336bf9?source=rss-234000d22dba------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4581e336bf9</guid>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[cypress-automation]]></category>
            <category><![CDATA[cypress]]></category>
            <dc:creator><![CDATA[Panduka Wijekoon]]></dc:creator>
            <pubDate>Wed, 20 Mar 2024 18:08:24 GMT</pubDate>
            <atom:updated>2024-03-20T18:08:24.075Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WgQweXEEE5-JYcTY9DD77A.jpeg" /></figure><p>In this article, I’m discussing how to create a simple Cypress project with TypeScript from scratch to demonstrate executing an automation test suite on a demo website. This allows users to view the test results and make decisions based on the passed and failed test cases.</p><p>Let’s begin.</p><p>When it comes to Cypress, it is a JavaScript/TypeScript-based automation framework primarily designed for testing web applications in web browsers. Cypress can also be used for API testing.</p><p>Cypress is open source, and it is free to use.</p><p>By default, when a Cypress project is created, it is set up in JavaScript. We need to modify some configurations in the code to switch it to TypeScript.</p><p><strong>Step 1 -<br></strong>Install Node.js on your computer.</p><p>Use this link to download the Node.js <a href="https://nodejs.org/en/download"><strong>https://nodejs.org/en/download</strong></a></p><p><strong>Step 2 -</strong><br>Create a folder in any of your driver. I’m creating a folder named “<strong>Projects</strong>” in my “<strong>D</strong>” driver.</p><p><strong>Step 3 -</strong><br>Create an another folder for your Cypress project. I’m creating a folder named “<strong>cypress-test-project</strong>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*zBkCjMUOkG1_lBKBmk1B7Q.png" /></figure><p><strong>Step 4 -</strong><br>Open the folder from <strong>Visual Studio Code</strong>. If you have any other IDE, use that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mlOBk9lf7IhYZJ6v3K7rKQ.png" /></figure><p><strong>Step 5 -</strong><br>Open a new terminal in the <strong>VS Code</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zM-JmH5R_CWjzR5Xz54g_g.png" /></figure><p><strong>Step 6 -</strong><br>Execute the below command in the terminal to create “<strong>package.json</strong>” file.</p><p><strong>“npm init -y”</strong></p><p>By executing this command, a <strong>json </strong>file named “<strong>package.json</strong>” file is created. This file contains descriptive and functional metadata about a project, such as a name, version, and dependencies.</p><p>By using “-<strong>y</strong>” in the command, we could be able to execute the command with default values. The default values are saved in “<strong>package.json</strong>” file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pAOf4qa1u5GGtQGvW8Qehg.png" /></figure><p><strong>Step 7 -</strong><br>Install the Cypress by executing below command.</p><pre>npm install cypress</pre><p>After the installation, Cypress dependency is placed under the “<strong>dependencies</strong>” section with version in “<strong>package.json</strong>” file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LL8HYnpIRjQ_X-k2lV2aAQ.png" /></figure><p><strong>Step 8 -</strong><br>Install the TypeScript by running the below command</p><pre>npm install typescript</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yxYvhR2Zf267IOLlSL_aIw.png" /></figure><p><strong>Step 9 -</strong><br>Execute below command to create TypeScript configuration file called “<strong>tsconfig.json</strong>”.</p><pre>npx tsc --init --types cypress --lib dom,es6</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*COhW1XUGfNc-4u5omQ5s6A.png" /></figure><p><strong>Step 10 -<br></strong>Execute below command to open the Cypress.</p><pre>npx cypress open</pre><p>After the command execution, a window is popping up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ifLtc8W8xYAxqOScxY1-zQ.png" /></figure><p><strong>Step 11 -</strong><br>Select “<strong>E2E Testing</strong>” option</p><p>Since we are discussing about the E2E testing, I’m choosing “<strong>E2E Testing</strong>” option instead of “<strong>Component Testing”</strong>.</p><p>Then you are navigating to below window. In here, It mentioned the files and folders which are going to create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U_ypCe35Ikrv-noMPvk-9g.png" /></figure><p><strong>Step 12 -<br></strong>Click on “<strong>Continue</strong>” button.</p><p>Then you are navigating to the below screen and you are able to select a browser to run your test scripts. I choose “<strong>Chrome</strong>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i2NNJ2gZqvlaZJ8prAU91Q.png" /></figure><p><strong>Step 13 -<br></strong>Then click the button “<strong>Start E2E Testing in Chrome”</strong>.</p><p>Now the “<strong>Chrome</strong>” browser opens and you are able to create new sample test script by clicking on “<strong>Create new spec</strong>” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*COIC166Cd3WZcg2PvX_RAA.png" /></figure><p><strong>Step 14 - <br></strong>Then click “<strong>Create spec</strong>” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9oENlHRvNPvHhy4ETEWGiQ.png" /></figure><p>Then run the spec by clicking the “<strong>Okay, run the spec</strong>” button. Now the script is running on the browser successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fQgXng_JUaNRBNR0R3Uv8w.png" /></figure><p>If you go to your project folder, there are few new files and folder were created as mentioned in the <strong>Step 11</strong>.</p><p>Now you can write your test scripts inside the “<strong>e2e</strong>” folder with TypeScript.</p><p>For an example I wrote a sample test script to verify the login feature of a website in the “<strong>spec.cy.ts</strong>” file.</p><pre>describe(&#39;Verify the login feature of the website&#39;, () =&gt; {<br><br>  it(&#39;Navigate and login to the website&#39;, () =&gt; {<br>    cy.visit(&#39;https://opensource-demo.orangehrmlive.com&#39;)<br>    cy.get(&#39;:nth-child(2) &gt; .oxd-input-group &gt; :nth-child(2) &gt; .oxd-input&#39;).type(&quot;Admin&quot;)<br>    cy.get(&#39;:nth-child(3) &gt; .oxd-input-group &gt; :nth-child(2) &gt; .oxd-input&#39;).type(&quot;admin123&quot;)<br>    cy.get(&#39;.oxd-button&#39;).click()<br>  })<br><br>})</pre><p>Then open the cypress using below command and then choose the browser and spec file to run the test script.</p><pre>npx cypress open</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cAzBSh4JMaamLyEpjniPuQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4581e336bf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scheduling workflows in CircleCI]]></title>
            <link>https://pandukawijekoon.medium.com/scheduling-workflows-in-circleci-3920eb25e9a2?source=rss-234000d22dba------2</link>
            <guid isPermaLink="false">https://medium.com/p/3920eb25e9a2</guid>
            <category><![CDATA[cron]]></category>
            <category><![CDATA[pipeline]]></category>
            <category><![CDATA[circleci]]></category>
            <category><![CDATA[cypress]]></category>
            <dc:creator><![CDATA[Panduka Wijekoon]]></dc:creator>
            <pubDate>Sat, 09 Mar 2024 18:35:27 GMT</pubDate>
            <atom:updated>2024-04-06T16:53:54.601Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C2RTyH0Rh2p9P78WgYCF7A.png" /></figure><p>In this article, we are discussing about how to schedule a CircleCI workflow so that the workflow can be triggered on any scheduled time such as hourly, daily or weekly without manual user interference.</p><p>For this demonstration, I’m using Cypress test automation project. You can refer below mentioned article and get an idea about how to configure a Cypress test project with CircleCI pipeline.</p><p><a href="https://medium.com/@panduka1996/cypress-project-integrates-with-circleci-pipeline-48be852f9312">https://medium.com/@panduka1996/cypress-project-integrates-with-circleci-pipeline-48be852f9312</a></p><p><strong>Creating Jobs</strong></p><p>First we need to create the required jobs. In my example I have create 2 sample jobs called “<strong>Testing ”</strong>and “<strong>Deploy”</strong>. You can name the jobs as your wish.</p><pre>jobs:<br>  Testing:<br>    docker:<br>      - image: cypress/base:14.16.0<br>    parallelism: 2<br>    resource_class: small<br>    steps:<br>      - checkout<br>      - run: <br>          name: module install<br>          command: npm install<br>      - run:<br>          name: Running the test<br>          command: npx cypress run<br>  Deploy:<br>    docker:<br>      - image: cypress/base:14.16.0<br>    resource_class: small<br>    steps:<br>      - run: <br>          name: Deploy the build<br>          command: echo &#39;The build is deployed&#39;</pre><p><strong>“Testing ” Job</strong></p><p>In this job, I have use the <strong>docker image</strong> as “<strong>cypress/base:14.16.0”</strong>. So the cypress commands which are using in here can be executed on this environment.</p><p>Then I have assigned “<strong>2 ”</strong>machines to parallelly execute the test suite. You can give any number as your requirement.</p><p>Then I have assigned the <strong>resource class </strong>as “<strong>small”</strong>. You can choose the resource class as per your CPU and RAM requirement. These are the options you have.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*nL-N_pbpfguAHFZeQoZ_nw.png" /></figure><p>Then finally you need to specify the steps that needs to be executed to run your test scripts.</p><p>In the <strong>1st step</strong>, we are cloning the source code into the CircleCI from the repository.<br>In the <strong>2nd step</strong>, the <strong><em>“npm install”</em> </strong>command is executed to install the node packages since this is a cypress project.<br>In the <strong>3rd step</strong>, the <strong><em>“npx cypress run”</em></strong> command is executed to run all the test scripts in the test project.</p><p><strong>“Deploy ” Job</strong></p><p>This is a sample job that I have created just to demonstrate the deployment after the “<strong>Testing” </strong>job gets completed successfully.</p><p>So in this job, I have configured the same specifications as the “<strong>Testing</strong>” job like docker image and resource class and then as the steps, I just print the text <strong>‘The build is deployed’.</strong></p><p><strong>Creating workflows</strong></p><p>After the Job creation, we have to create the workflows. In my example I have created 2 sample workflows called “<strong>Testing-Workflow ”</strong>and “<strong>Nightly-Testing-Workflow”.</strong></p><pre>workflows:<br>  Testing-Workflow:<br>    jobs:<br>      - Testing<br>      - Deploy:<br>          requires:<br>            - Testing<br>  Nightly-Testing-Workflow:<br>    triggers:<br>      - schedule:<br>          cron: &quot;0 0 * * *&quot;<br>          filters:<br>            branches:<br>              only:<br>                - master<br>    jobs:<br>      - Testing<br>      - Deploy:<br>          requires:<br>            - Testing</pre><p><strong>“Testing-Workflow</strong>” <strong>workflow</strong></p><p>The <strong>“Testing-Workflow</strong>” workflow is executing when we commit a code change to the repository or manually executes the pipeline from the CircleCI.</p><p>In this workflow, there are 2 jobs are executing. The “<strong>Testing</strong>” job is executing at 1st and if the “<strong>Testing</strong>” job executes successfully then the “<strong>Deploy</strong>” job is executing. If the “Testing” job fails then the “<strong>Deploy</strong>” job is not executing.</p><p><strong>“Nightly</strong>-<strong>Testing-Workflow</strong>” <strong>workflow</strong></p><p>The <strong>Nightly-Testing-Workflow</strong> is executing when the scheduler triggers the workflow.</p><p>In this workflow, we have configured a trigger and schedule to execute the workflow on specific time &amp; date using the <strong>Cron </strong>job. In this example I have scheduled this workflow to execute on 12.00 AM (UTC time) everyday.</p><p>You can create your Cron job using this site — <a href="https://crontab.cronhub.io/"><strong>https://crontab.cronhub.io/</strong></a></p><p>Also I have specified that only the source code on the master branch in the repository should be executed.</p><p>In this workflow also, there are 2 jobs are executing. The “Testing” job is executing at 1st and if the “Testing” job executes successfully then the “Deploy” job is executing. If the “Testing” job fails then the “Deploy” job is not executing.</p><p>Here is the full configuration file</p><pre>version: 2.1<br>jobs:<br>  Testing:<br>    docker:<br>      - image: cypress/base:14.16.0<br>    parallelism: 2<br>    resource_class: small<br>    steps:<br>      - checkout<br>      - run: <br>          name: module install<br>          command: npm i<br>      - run:<br>          name: Running the test<br>          command: npm run test:cli<br>  Deploy:<br>    docker:<br>      - image: cypress/base:14.16.0<br>    resource_class: small<br>    steps:<br>      - run: <br>          name: Deploy the build<br>          command: echo &#39;The build is deployed&#39;<br>workflows:<br>  Testing-Workflow:<br>    jobs:<br>      - Testing<br>      - Deploy:<br>          requires:<br>            - Testing<br>  Nightly-Testing-Workflow:<br>    triggers:<br>      - schedule:<br>          cron: &quot;0 0 * * *&quot;<br>          filters:<br>            branches:<br>              only:<br>                - master<br>    jobs:<br>      - Testing<br>      - Deploy:<br>          requires:<br>            - Testing</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3920eb25e9a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cypress project integrates with Cypress Dashboard]]></title>
            <link>https://pandukawijekoon.medium.com/cypress-project-integrates-with-cypress-dashboard-27decba710f5?source=rss-234000d22dba------2</link>
            <guid isPermaLink="false">https://medium.com/p/27decba710f5</guid>
            <category><![CDATA[circleci]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[cypress-dashboard]]></category>
            <dc:creator><![CDATA[Panduka Wijekoon]]></dc:creator>
            <pubDate>Sun, 03 Mar 2024 14:51:25 GMT</pubDate>
            <atom:updated>2024-03-22T17:55:04.573Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_qp5vZx3NrFE079HCGy3jA.png" /></figure><p>In this article, I am discussing how to integrate a Cypress project with Cypress Dashboard. The Cypress Dashboard helps to view the test results, including passed, failed, and skipped test cases, as well as the stack trace and screenshots of the failed test cases.</p><p>Let’s start,</p><p><strong>Step 1 -<br></strong>Create an account in Cypress Dashboard using this URL.<br><a href="https://cloud.cypress.io/signup"><strong>https://cloud.cypress.io/signup</strong></a></p><p>You can signup with your GitHub account as well.</p><p><strong>Step 2 -</strong><br>Login to the Cypress Dashboard.<br><a href="https://cloud.cypress.io/login"><strong>https://cloud.cypress.io/login</strong></a></p><p>You are navigating to this dashboard with empty projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wjDevXTquSH-hOq9gFO2Vg.png" /></figure><p><strong>Step 3 -<br></strong>Create a new project by clicking on the <strong>“New project” </strong>button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tv-pBGu1D-UI8_5Tf-aw9g.png" /></figure><p><strong>Step 4 -<br></strong>Give your project a name and choose the project access. (I choose <strong>“Private”</strong>).</p><p>Then Click on the <strong>“Create project”</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*1e1mYXQxs4-H4xHUX14geg.png" /></figure><p><strong>Step 5 -<br></strong>Now, you are navigating to below Project setup page.</p><p>In here, you are able to see the “<strong>projectId</strong>” value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*fJd5UN2PcuhwmFxXysFmOg.png" /></figure><p><strong>Step 6 -<br></strong>Then, add above mentioned “<strong>projectId </strong>” value into the “<strong>cypress.config.ts</strong>” file in your Cypress project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*55fURREFlTzF7dG6g-TKvA.png" /></figure><p><strong>Step 7 -<br></strong>Click “<strong>Next</strong>” button and continue to the next step.</p><p>Now, you are navigating to the CI tool selection page. Based on your CI (Continues Integration) tool, you can choose one. I choose <strong>CircleCI</strong>.</p><p>Then continue. Now you are navigating to below page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*JGXLVRVK4bqJs2AIjTOHtg.png" /></figure><p><strong>Step 8 -</strong><br>As mentioned in the above image, add the command into the “<strong>package.json</strong>” file in your Cypress project.</p><p>“<strong>npx cypress run — record — key {Generated key}”</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*whzhZhJ-EHm0tury-nWC3w.png" /></figure><p>Then, run your project locally in headless mode using below command.</p><p><strong>“npm run test:cli”</strong></p><p>or run the project using CI tool.</p><p>After the test execution, you are able to see your project on the Cypress Dashboard.</p><p>By clicking on the project, you are able to see the detailed view of the test execution including failed test cases, passed test cases, flaky test cases and etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S3VoeQZyt0-pSSvHNMYQTg.png" /></figure><p><strong>Step 9 -</strong><br>Currently we have added the generated dashboard key in the “<strong>package.json</strong>” file. That is not a good practice since that is a security concern.</p><p>So if you are using any CI tool such as CircleCI, GitHub Actions, Azure and etc, you can add the secret key into you CI tool project environment variable as mentioned in the <strong>Step 7</strong>.</p><p><strong>Step 10 -</strong><br>First, navigate to your project settings in CI tool (In my case CircleCI, since I’m using CircleCI as the CI tool).</p><p>Then, go to “<strong>Environment Variable</strong>” section and add the secret key as a environment variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LaBLk3meo2t-m_KUU7DQVQ.png" /></figure><p><strong>Step 11 -</strong><br>After adding the secret key into the CI environment variable, you can remove the key from the command in “<strong>Package.json</strong>” file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ks1qd5jH0WgAfs2kV0y_A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27decba710f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cypress project integrates with CircleCI pipeline]]></title>
            <link>https://pandukawijekoon.medium.com/cypress-project-integrates-with-circleci-pipeline-48be852f9312?source=rss-234000d22dba------2</link>
            <guid isPermaLink="false">https://medium.com/p/48be852f9312</guid>
            <category><![CDATA[cypress-testing]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[circleci]]></category>
            <dc:creator><![CDATA[Panduka Wijekoon]]></dc:creator>
            <pubDate>Fri, 23 Feb 2024 09:20:40 GMT</pubDate>
            <atom:updated>2024-02-23T09:20:40.056Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*prJWEBUAysMU-e6UazwPMw.jpeg" /></figure><p>In this article we are discussing about how to integrate Cypress project with CircleCI pipeline. When committing any code change to the repository, the CircleCI pipeline should trigger and execute the test cases and finally you are able to see the test results.</p><p>Let’s start …</p><p><strong>Step 1</strong><br>Create a <strong>CircleCI </strong>account using <strong>GitHub </strong>or <strong>Bitbucket</strong>. I choose GitHub.</p><p><strong>Step 2</strong><br>Add projects (Repositories) from your GitHub into the CircleCI.<br>Then your projects are listed on the CircleCI <strong><em>“Projects”</em></strong> section. (Your Cypress project should be also listed in here)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mV95p2GF1XadlTaVDQsnHw.png" /></figure><p><strong>Step 3</strong><br>Select you Cypress project and click <strong><em>“Set Up Project” </em></strong>button.<br>Then you are navigating to this window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*JV1nlqJv08zAn3IKbPJnWQ.png" /></figure><p><strong>Step 4</strong><br>Selecting <strong><em>“Fast”</em></strong> option.<br>Then you are navigating to below screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bK8cC_A-JHO6lUhAAsYsMQ.png" /></figure><p>Then select <strong><em>“Hello World”</em></strong> option and continue. (The “Hello World” option create a simple config file)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WpZDIPHq1D-MIxkugutR6A.png" /></figure><p><strong>Step 5</strong><br>Click on <strong><em>“Use Existing Config” </em></strong>button.<br>Then you are navigating to below screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*RbS4Me5V2Mf4kh5tis6wIQ.png" /></figure><p><strong>Step 6</strong><br>If your project doesn&#39;t have a <strong><em>“config.yml”</em></strong> file then you have to create a <strong>“.circleci”</strong> folder in the project root directory and inside that folder create a YAML file named <strong><em>“config.yml”</em></strong>.</p><p>Then add below mentioned configurations into the “<strong><em>config.yml</em></strong>” file</p><pre>version: 2.1<br>jobs:<br>  Testing:<br>    docker:<br>      - image: cypress/base:14.16.0<br>    parallelism: 2<br>    resource_class: small<br>    steps:<br>      - checkout<br>      - run: <br>          name: module install<br>          command: npm i<br>      - run:<br>          name: Running the test<br>          command: npx cypress run<br>workflows:<br>  Testing-Workflow:<br>    jobs:<br>      - Testing</pre><p>Then commit the changes to the repository.</p><p><strong>Step 7</strong><br>Then click on the <strong><em>“Start Building”</em></strong> button in this window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*RbS4Me5V2Mf4kh5tis6wIQ.png" /></figure><p>Then your CircleCI pipeline is starting to execute. You are able to see the pipeline execution process on the CircleCI “<strong><em>Dashboard </em></strong>” section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jTArDMD91V_EAlvAFmF_zw.png" /></figure><p>After the pipeline execution, you are able to see the test results by clicking on the executed pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sg2ZXKz1LG_odGrqMJUy2w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48be852f9312" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cypress project integrates with Jenkins pipeline]]></title>
            <link>https://pandukawijekoon.medium.com/cypress-integrates-with-jenkins-windows-5e35fc22cc7a?source=rss-234000d22dba------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e35fc22cc7a</guid>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[cypress-testing]]></category>
            <category><![CDATA[jenkins]]></category>
            <dc:creator><![CDATA[Panduka Wijekoon]]></dc:creator>
            <pubDate>Thu, 22 Feb 2024 19:58:43 GMT</pubDate>
            <atom:updated>2024-03-13T14:36:43.388Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RNZiaQ0f9w_DzUzpkietUQ.jpeg" /></figure><p>In this article, I’m discussing how to configure a Cypress project with a Jenkins pipeline. The Jenkins pipeline triggers and initiates the execution of all test cases in the automation project as soon as a code change is committed to the repository.</p><p>So let’s start,</p><p><strong>Step 1<br></strong>Download the Jenkins. Download the LTS release from this website. <a href="https://www.jenkins.io/download/">https://www.jenkins.io/download/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*42HYDX6EovVbxMykYINbTQ.png" /></figure><p><strong>Step 2</strong> <br>Place the war file into any location on your system</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j8NfLtvyKe42UIbPEsbbQw.png" /></figure><p><strong>Step 3</strong><br>Navigate to the war file location and open the Command Prompt</p><p><strong>Step 4</strong><br>Execute the command <strong><em>“java -jar jenkins.war”</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*KOGBTIb-ShTmGfXTjDyhaQ.png" /></figure><p>When you run the Jenkins for the first time, it gives an admin password in the terminal. <br>You can also access the admin password in the file <strong><em>“initialAdminPassword”</em></strong> on this location.</p><p><strong><em>“C:/Users/{username}/.jenkins/secrets”</em></strong></p><p><strong>Step 5</strong><br>The Jenkins is running on localhost port 8080. So, open a browser and browse this URL</p><p><a href="http://localhost:8080/"><strong><em>“http://localhost:8080/</em></strong></a><strong><em>”</em></strong></p><p><strong>Step 6</strong><br>You must give the admin password here</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*nKUoVMAhpi6M84l_qiOpdA.png" /></figure><p><strong>Step 7<br></strong>Then you have to select <strong><em>“Install suggested plugins”</em></strong> or <strong><em>“Select plugins to install” </em></strong>option. You can choose any option. I choose <strong><em>“Select plugins to install”</em></strong> option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*bRuRldtIhKqXci_R9rE6hQ.png" /></figure><p><strong>Step 8</strong> <br>In here, you can install all the plugins or suggested plugins or you can continue without install any plugin by clicking on the <strong><em>“None”</em></strong> button and then continued from here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*IvyWPqdbOP13lQ9lABPrlA.png" /></figure><p><strong>Step 9</strong> <br>In here, you can create new user, or you can continue as admin. I choose to continue as admin</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*3j6-mRnPOH-CtVdjRa5fKA.png" /></figure><p><strong>Step 10<br></strong>Finally, you can start using Jenkins</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dgAOE0nPsNvrZygxvinEiA.png" /></figure><p><strong>Step 11<br></strong>Change the Jenkins home directory to different partition to get more space for the plugins.</p><p>Check the current home directory by navigating to <strong><em>“Manage Jenkins”</em></strong> tab in Jenkins dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o2xc8F9KT7bRBoETXfXQKQ.png" /></figure><p><strong>Step 12</strong> <br>Navigate to <strong><em>“System”</em></strong> section under <strong><em>“System Configuration”</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*639dm0eVWSPfMg-v0kLNUA.png" /></figure><p>Finally, you can see the home directory. This is the default directory location.</p><p><strong><em>“C:\Users\{username}\.jenkins”</em></strong></p><p><strong>Step 13<br></strong>Create a new folder named <strong><em>“JenkinsHome” </em></strong>in the folder where the <strong><em>“jenskin.war”</em></strong> file was saved and then copy and paste all the files inside the old Jenkins home directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LuzaL9gABpc8LXMIm7YzOw.png" /></figure><p><strong>Step 13<br></strong>Change the environment variable of the <strong><em>JENKINS_HOME </em></strong>to new home directory. In case if you don’t find this variable in your system variables, then create one and give the new home directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YxyiA7772rK6sZ1tiwfdNg.png" /></figure><p><strong>Step 14<br></strong>Restart the Jenkins to see the home directory updated in Jenkins configurations. (Stop the server and then start Jenkins again)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*x0Cgf_t1bM49aC-vcFXmgQ.png" /></figure><p><strong>Step 15<br></strong>Install “<strong><em>Pipeline</em></strong>”, “<strong><em>Git</em></strong>” and “<strong><em>NodeJs </em></strong>” plugins in Jenkins.</p><p>Navigate to “<strong><em>plugin </em></strong>” section in “<strong><em>Manage Jenkins</em></strong>” tab and then search “<strong>Pipeline</strong>”, “<strong><em>Git </em></strong>” and “<strong><em>NodeJs</em></strong>” plugins and then install those.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ki7WUw7lVCb5GI2as1y3GQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IHbEGS_fsRyQV36YLRT1bg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2oDUMLLsi8VPwVlyQicswA.png" /></figure><p><strong>Step 16<br></strong>After the installation, we need to add the “<strong><em>NodeJs</em></strong>” to Jenkins tool configurations.</p><p>Navigate to the “<strong><em>Tools</em></strong>” section in “<strong><em>Manage Jenkins”</em></strong> tab and find the “<strong><em>NodeJs” </em></strong>section. Then add below mentioned details including “<strong><em>NodeJs Name</em></strong>”, “<strong><em>Version</em></strong>”, “<strong><em>Global npm packages to install</em></strong>” and “<strong><em>Global npm packages refresh hours</em></strong>”. (Choose cypress compatible “<strong><em>NodeJs</em></strong>”version. I choose “<strong><em>14.20.1</em></strong>”)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*XAHCfdxZGonE_enCyKWP3Q.png" /></figure><p>Then apply and save the changes.</p><p><strong>Step 17 </strong><br>Now create a Jenkins pipeline. Give a name for the project and select <strong><em>“Pipeline”</em></strong> option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*Mbogh4PHKSgpcX1BrltlNA.png" /></figure><p><strong>Step 18<br></strong>You can see these options in the Jenkins Pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d9WNOe_mtLUCRz-b5EQ0YQ.png" /></figure><p><strong>Step 19</strong> <br>Navigate to “<strong><em>Build Triggers</em></strong>” section and select “<strong><em>Poll SCM</em></strong>” and provide below mentioned Cron syntax. We are setting a polling time to check whether the our cypress project repository is updated with new commit. As soon as the commit happens, the pipeline is triggered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3nC5LMJbAhWFF33BLe3-JA.png" /></figure><p><strong>Step 20</strong> <br>In your cypress project, create a file called <strong><em>“Jenkinsfile”</em></strong> and add below pipeline script. (nodejs name should be match with the nodejs name that we configured in Jenkins tool)</p><pre>pipeline {<br>    agent any<br>    tools {nodejs &quot;Node14&quot;}<br><br><br>   environment {<br>       CHROME_BIN = &#39;/bin/google-chrome&#39;<br>      <br>   }<br>    stages {<br>        stage(&#39;Dependacy Install&#39;) {<br>            steps {<br>                bat &#39;npm i&#39;<br>            }<br>        }<br>        stage(&#39;Running Test Script&#39;) {<br>            steps {<br>                bat &#39;npm run test:cli&#39;<br>            }<br>        }<br>    }   <br>}</pre><p><strong>Step 21 <br></strong>Navigate to the “<strong><em>package.json</em></strong>” file in your cypress project and add below mentioned custom command in <strong><em>“scripts”</em></strong> section</p><p><strong><em>“test:cli”: “npx cypress run”</em></strong></p><p>This command executes all the test cases in your cypress project on headless mode.</p><p><strong>Step 22<br></strong>Navigate to “<strong><em>Pipeline</em></strong>” section in the created Jenkins pipeline configuration and select <strong><em>“Pipeline script from SCM”</em></strong> option.</p><p>Then select Git as SCM (if you are using source control manager as GIT) and then provide the “<strong><em>Repository URL</em></strong>”, <strong><em>Git credentials</em></strong> if the repository is private, working branch and Jenkins file name (Create in <strong>Step 20</strong>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rIxcSWW01HRrNeWHaz5fUQ.png" /></figure><p>Then apply and save the changes in the pipeline configuration.</p><p><strong>Step 23<br></strong>To test the Jenkins pipeline, try to commit any change to the repository.</p><p>The Jenkins pipeline should start and execute the test cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wu-LJi1ItfdZ3rdMEdnskg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e35fc22cc7a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>