<?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[Automation with Love - Medium]]></title>
        <description><![CDATA[For those who are interested in automating the stuffs, CI/CD pipeline, automation test.. - Medium]]></description>
        <link>https://medium.com/automation-with-donald?source=rss----269efa07d359---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Automation with Love - Medium</title>
            <link>https://medium.com/automation-with-donald?source=rss----269efa07d359---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 00:02:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/automation-with-donald" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Component testing for React Vite application using Cypress]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/automation-with-donald/component-testing-for-react-vite-application-using-cypress-81e11163d901?source=rss----269efa07d359---4"><img src="https://cdn-images-1.medium.com/max/2600/0*TEmYm9M8rLiU-iRw" width="2957"></a></p><p class="medium-feed-snippet">If you&#x2019;re working as an automation tester long enough, you would have experience the frustration when fixing an end-to-end tests with many&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/automation-with-donald/component-testing-for-react-vite-application-using-cypress-81e11163d901?source=rss----269efa07d359---4">Continue reading on Automation with Love »</a></p></div>]]></description>
            <link>https://medium.com/automation-with-donald/component-testing-for-react-vite-application-using-cypress-81e11163d901?source=rss----269efa07d359---4</link>
            <guid isPermaLink="false">https://medium.com/p/81e11163d901</guid>
            <category><![CDATA[vitejs]]></category>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[component-testing]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Donald Le]]></dc:creator>
            <pubDate>Fri, 23 May 2025 02:13:21 GMT</pubDate>
            <atom:updated>2025-05-23T02:13:21.837Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Deploy a web app with Docker and Nginx]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/automation-with-donald/deploy-a-web-app-with-docker-and-nginx-65d9be7e174c?source=rss----269efa07d359---4"><img src="https://cdn-images-1.medium.com/max/2244/0*GyfRVm3TgHEpKtVn" width="2244"></a></p><p class="medium-feed-snippet">Nginx is a web server that can act as a reverse proxy, load balancer, or HTTPcache. By using Nginx, your application can handle a higher&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/automation-with-donald/deploy-a-web-app-with-docker-and-nginx-65d9be7e174c?source=rss----269efa07d359---4">Continue reading on Automation with Love »</a></p></div>]]></description>
            <link>https://medium.com/automation-with-donald/deploy-a-web-app-with-docker-and-nginx-65d9be7e174c?source=rss----269efa07d359---4</link>
            <guid isPermaLink="false">https://medium.com/p/65d9be7e174c</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Donald Le]]></dc:creator>
            <pubDate>Tue, 16 Jan 2024 09:34:48 GMT</pubDate>
            <atom:updated>2024-01-16T09:34:47.999Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to modularize your k6 tests]]></title>
            <link>https://medium.com/automation-with-donald/how-to-modularize-your-k6-tests-1837f7e394cc?source=rss----269efa07d359---4</link>
            <guid isPermaLink="false">https://medium.com/p/1837f7e394cc</guid>
            <category><![CDATA[performance-test]]></category>
            <category><![CDATA[code-structure]]></category>
            <category><![CDATA[k6]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[modular]]></category>
            <dc:creator><![CDATA[Donald Le]]></dc:creator>
            <pubDate>Tue, 09 Jan 2024 07:28:49 GMT</pubDate>
            <atom:updated>2024-01-09T07:28:49.300Z</atom:updated>
            <content:encoded><![CDATA[<h4>When it comes to software development, structuring your code in modules allow you to easily maintain and update the code when needed. As your load testing scenarios get more complicated and grow, you need to modularize your k6 tests so that you can reuse the code, as well as allowing the tests to be readable to other testers and developers.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vwpksSVPTe4i1oz5RdltwQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@wwarby?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">William Warby</a> on <a href="https://unsplash.com/photos/a-group-of-icebergs-floating-on-top-of-a-body-of-water-RGvhtjx_Oqg?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>If you have experience working with functional testing, such as end-to-end testing for web application using Selenium or Cypress, or with API testing using RestAssured in Java, you need to treat your test code the same way as application code. That means you need to structure your test code so that you can easily add new tests or modify the existing one when needed. That way, you can maintain the tests better and do not go to the point when you want to get rid of all your tests and build the new test project instead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iW8DeeB8sdD17eV34WPPWQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@laviperchik?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Lavi Perchik</a> on <a href="https://unsplash.com/photos/a-computer-screen-with-a-bunch-of-text-on-it-fSqYwKWzwhk?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>The same goes for the performance testing using k6. To make your load tests to be maintainable, you need to modularize your test scenarios. k6 supports a number of methods to modularize your test components, from scenarios, thresholds, to the logic. Actually, the k6 team already provided a getting started tutorial with example for how to <a href="https://grafana.com/docs/k6/latest/examples/get-started-with-k6/reuse-and-re-run-tests/">reuse and re-run tests by implementing the tests into modules</a>.</p><p>In this article, I would like to share my approach when it comes to making the k6 tests to be modularized.</p><h3>Thresholds</h3><p>In the k6 testing, we usually need to verify whether our load test is passed or failed, based on certain requirement. Below is an example of making the thresholds to be reusable by creating a Javascript function with k6 supported methods:</p><pre>export function threshold(scenarioName, expected_http_req_failed_rate, expected_http_req_duration_time){<br><br>    switch (scenarioName)<br>    {<br>        case &quot;constantUsers&quot;:<br>            return      {<br>                http_req_failed: [{ threshold: expected_http_req_failed_rate}],<br>                http_req_duration: [expected_http_req_duration_time],<br>              }<br>        case &quot;checkNumberOfCCUs&quot;:<br>            return {<br>                http_req_failed: [{ threshold: expected_http_req_failed_rate, abortOnFail: true }],<br>              }<br>        default:<br>            return {<br>                http_req_failed: [{ threshold: expected_http_req_failed_rate}],<br>                http_req_duration: [expected_http_req_duration_time],<br>              }<br>    }<br><br>}</pre><p>This function takes scenarioName as a parameter so that you can apply different scenarios for your threshold. Currently, you can have different types of thresholds checking for 2 scenarios: constantUsers and checkNumberOfCCUs .</p><h3>Scenarios</h3><p>Scenarios definition are the most common part of your tests that you want to make it modularized so that you can run the same tests with different scenarios. One quick way to make your scenario definition maintainable is to creating a function for it. For example with this one below:</p><pre>export function scenarios(scenarioName){<br>    switch (scenarioName)<br>    {<br>        case &quot;constantUsers&quot;:<br>            return      {<br>                constantVirtualUsers: {<br>                   executor: &#39;constant-vus&#39;,<br>                   vus: 5,<br>                   duration: &#39;1800s&#39;,<br>                 },<br>                }<br>        case &quot;checkNumberOfCCUs&quot;:<br>            return {<br>                breaking: {<br>                    executor: &quot;ramping-vus&quot;,<br>                    stages: [<br>                      { duration: &quot;10s&quot;, target: 2 },<br>                      { duration: &quot;150s&quot;, target: 5 },<br>                      { duration: &quot;150s&quot;, target: 10 },<br>                      { duration: &quot;150s&quot;, target: 15 },<br>                      { duration: &quot;150s&quot;, target: 20 },<br>                      { duration: &quot;150s&quot;, target: 25 },<br>                      { duration: &quot;150s&quot;, target: 30 },<br>                      { duration: &quot;150s&quot;, target: 35 },<br>                      { duration: &quot;150s&quot;, target: 40 },<br>                      { duration: &quot;150s&quot;, target: 45 },<br>                      { duration: &quot;150s&quot;, target: 50 },<br>                      { duration: &quot;150s&quot;, target: 55 },<br>                      { duration: &quot;150s&quot;, target: 60 },<br>                      { duration: &quot;150s&quot;, target: 65 },<br>                      { duration: &quot;150s&quot;, target: 70 },<br>                      { duration: &quot;150s&quot;, target: 75 },<br>                      { duration: &quot;150s&quot;, target: 80 },<br>                      { duration: &quot;150s&quot;, target: 85 },<br>                      { duration: &quot;150s&quot;, target: 90 },<br>                    ],<br>                  },<br>            }<br>        default:<br>            return {<br>                constantVirtualUsers: {<br>                    executor: &#39;constant-vus&#39;,<br>                    vus: 5,<br>                    duration: &#39;1800s&#39;,<br>                  },<br>            }<br>    }<br><br>};</pre><p>By using this scenario function in your tests, you can apply different types of scenarios for your same test code, just by providing the scenarioName for your test, whether it is constantUsers or checkNumberOfCCUs. If the scenario name is not provided, the default scenario will be applied instead.</p><h3>Request Functions</h3><p>When applying the load testing with k6, you often need to deal with a number of API requests in your tests. To easily reuse the API requests, you need to create functions for every API, and put those functions into appropriate files that match their purposes. For example, below is the function for the authentication API:</p><pre>export async function authentication(dataEnv, userLength){<br>  const randomUser = randomNumber(0, userLength-1);<br>  let POST_BODY = {<br>      grant_type: &#39;password&#39;,<br>      username: dataEnv.qa[randomUser].username,<br>      password: dataEnv.qa[randomUser].password,<br>      audience: dataEnv.authO.auth0Audience,<br>      scope: &#39;openid profile email&#39;,<br>      client_id: dataEnv.authO.auth0ClientId,<br>      client_secret: dataEnv.authO.clientSecret,<br>  };<br><br>  let url = dataEnv.authO.auth0URL;<br>  let res = http.asyncRequest(&#39;POST&#39;, url, JSON.stringify(POST_BODY), {<br>    headers: { &#39;Content-Type&#39;: &#39;application/json&#39; },<br>  });<br>  return res;<br>}</pre><h3>Test Data</h3><p>Structing your test data in a way so that you can reuse it for different types of environment for your test is very important because you do not want to create different tests only because you want to execute the tests for another environment.</p><p>For example, you can store your test data in a Javascript variable with Json content for multiple environment as below:</p><pre>export let obData = {<br>  &quot;dev&quot;:{<br>    &quot;client1&quot;:{<br>      &quot;a&quot;: null,<br>      &quot;b&quot;: &quot;12&quot;,<br>      &quot;c&quot;: &quot;12&quot;,<br>    }<br>  },<br>  &quot;test&quot;:{<br>    &quot;client1&quot;:{<br>      &quot;a&quot;: null,<br>      &quot;b&quot;: &quot;13&quot;,<br>      &quot;c&quot;: &quot;13&quot;,<br>    }<br>  },<br>};</pre><p>Then you can use it in your test file for different environment test execution.</p><pre>    let response = await createOb(dataEnv,tenant, obData, dataEnv.qa[1].apiKey);</pre><h3>Common Utilities</h3><p>When doing the tests, there are common utility functions that you usually need to work with over and over again, such as random number generator function. Those common functions should be put in the common utility file so that you can reuse them in your tests.</p><p>For example below is a common function for generating random number:</p><pre>export function randomNumber(min, max) {<br>    min = Math.ceil(min);<br>    max = Math.floor(max);<br>    return Math.floor(Math.random() * (max - min + 1)) + min;<br>  }</pre><h3>Conclusion</h3><p>Making the k6 tests modularized allow you to maintain the test project better and more efficiently. Through the article, I mentioned 5 components that you should modularize that are thresholds, scenarios, requests, test data, and common utilities.</p><p>If you would like to learn more about the best practices of using k6, check out the <a href="https://k6.io/docs/">k6 official documentation</a> page.</p><p>Happy k6 testing guys~~~</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1837f7e394cc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/automation-with-donald/how-to-modularize-your-k6-tests-1837f7e394cc">How to modularize your k6 tests</a> was originally published in <a href="https://medium.com/automation-with-donald">Automation with Love</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Synthetic testing a Next.js app using Grafana k6 cloud]]></title>
            <link>https://medium.com/automation-with-donald/synthetic-testing-a-next-js-app-using-grafana-k6-cloud-4cb263307ee0?source=rss----269efa07d359---4</link>
            <guid isPermaLink="false">https://medium.com/p/4cb263307ee0</guid>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[k6]]></category>
            <category><![CDATA[synthetic-test]]></category>
            <category><![CDATA[performance-testing]]></category>
            <dc:creator><![CDATA[Donald Le]]></dc:creator>
            <pubDate>Sun, 26 Nov 2023 01:47:57 GMT</pubDate>
            <atom:updated>2023-11-26T01:47:57.234Z</atom:updated>
            <content:encoded><![CDATA[<h4>Synthetic testing ensures your application performance meets the expected requirements for typical user journeys. You wouldn’t want to find out your application performance problems reported by your users, would you?</h4><h3>What is Synthetic Testing</h3><p>Synthetic testing is a testing type to check how a particular end-user journey would perform in the production environment by simulating it in a test or any pre-production environment. By doing synthetic testing, you can prevent performance issue happening in production environment.</p><h3>The demo application</h3><p>To understand how to apply synthetic testing for an application, let’s try to do it with a demo application.</p><p>The demo application is an app that allows you to prepare for your job interview by taking sample questions. Then you will get feedback from an AI backend service so that you can improve your answers next time. This app is provided as a template by Vercel (Next.js) so that you can learn how to deploy Next.js application with Vercel.</p><p>Navigate to my deployed <a href="https://liftoff-rho-ten.vercel.app/">Liftoff</a> application to understand how the app works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lVh7nVhzUNeAfxOLbfK9EA.png" /><figcaption>Liftoff interview application</figcaption></figure><h3>The demo scenario</h3><p>Let’s try to synthetic test a scenario like below:</p><p>User clicks on “Try it out” button → click on “Technical” interview option → “Continue” → choose “John” interviewer → “Continue”.</p><h3>Create a Performance Test project on Grafana Cloud</h3><p><a href="https://grafana.com/products/cloud/k6/">Grafana Cloud</a> offers a free plan for using k6 on the cloud so that you can get started using k6 for your project right away, instead of installing k6 and setting up the timeseries database in your local environment.</p><p>To start testing using Grafana performance testing, you need to create your project first. Go to Grafana Cloud, login to the platform and click on the “Create new project” button at the “Performance testing” page to do so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QY1Lb0B1UGa7kcdg25qiEQ.png" /><figcaption>Create a performance testing project in Grafana cloud</figcaption></figure><h3>Recording a script</h3><p>You can manually write the script above using k6. However, if you want to quickly test the scenario or you do not know how to write the k6 script yourself yet, you can use the k6 recorder extension in Chrome or Firefox. Checkout this <a href="https://k6.io/docs/test-authoring/create-tests-from-recordings/using-the-browser-recorder/">documentation page</a> for how to install and use the k6 browser extension.</p><p>Then open your installed k6 extension and click on “Start recording” button and perform the scenario described above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*OhYStvW0ycfnxWdQYomPaA.png" /><figcaption>Browser extension for recording k6 scenario</figcaption></figure><p>After you finished your scenario, click on “Stop recording” button. The extension will try to navigate to your Grafana performance testing tab and fill out the scenario script. The script would look like below:</p><pre>// Creator: Grafana k6 Browser Recorder 1.0.1<br><br>import { sleep, group } from &#39;k6&#39;<br>import http from &#39;k6/http&#39;<br><br>export const options = { vus: 10, duration: &#39;5m&#39; }<br><br>export default function main() {<br>  let response<br><br>  group(&#39;page_2 - https://liftoff-rho-ten.vercel.app/demo&#39;, function () {<br>    response = http.get(&#39;https://liftoff-rho-ten.vercel.app/demo&#39;, {<br>      headers: {<br>        &#39;upgrade-insecure-requests&#39;: &#39;1&#39;,<br>        &#39;sec-ch-ua&#39;: &#39;&quot;Google Chrome&quot;;v=&quot;119&quot;, &quot;Chromium&quot;;v=&quot;119&quot;, &quot;Not?A_Brand&quot;;v=&quot;24&quot;&#39;,<br>        &#39;sec-ch-ua-mobile&#39;: &#39;?0&#39;,<br>        &#39;sec-ch-ua-platform&#39;: &#39;&quot;Windows&quot;&#39;,<br>      },<br>    })<br>    sleep(15.6)<br>    response = http.get(&#39;https://liftoff-public.s3.amazonaws.com/JohnTechnical.mp4&#39;, {<br>      headers: {<br>        &#39;accept-encoding&#39;: &#39;identity;q=1, *;q=0&#39;,<br>        range: &#39;bytes=1540096-&#39;,<br>        &#39;sec-ch-ua&#39;: &#39;&quot;Google Chrome&quot;;v=&quot;119&quot;, &quot;Chromium&quot;;v=&quot;119&quot;, &quot;Not?A_Brand&quot;;v=&quot;24&quot;&#39;,<br>        &#39;sec-ch-ua-mobile&#39;: &#39;?0&#39;,<br>        &#39;sec-ch-ua-platform&#39;: &#39;&quot;Windows&quot;&#39;,<br>      },<br>    })<br>  })<br>}</pre><p>Inside this script, you have the user behavior scenario and how you want k6 to simulate the users.</p><p>The export default function block tells k6 to send request to the “https://liftoff-rho-ten.vercel.app/demo” API first, then wait for 15.6 second to simulate the user think time. Then make another API request to “https://liftoff-public.s3.amazonaws.com/JohnTechnical.mp4” API.</p><pre>export default function main() {<br>  let response<br><br>  group(&#39;page_2 - https://liftoff-rho-ten.vercel.app/demo&#39;, function () {<br>    response = http.get(&#39;https://liftoff-rho-ten.vercel.app/demo&#39;, {<br>      headers: {<br>        &#39;upgrade-insecure-requests&#39;: &#39;1&#39;,<br>        &#39;sec-ch-ua&#39;: &#39;&quot;Google Chrome&quot;;v=&quot;119&quot;, &quot;Chromium&quot;;v=&quot;119&quot;, &quot;Not?A_Brand&quot;;v=&quot;24&quot;&#39;,<br>        &#39;sec-ch-ua-mobile&#39;: &#39;?0&#39;,<br>        &#39;sec-ch-ua-platform&#39;: &#39;&quot;Windows&quot;&#39;,<br>      },<br>    })<br>    sleep(15.6)<br>    response = http.get(&#39;https://liftoff-public.s3.amazonaws.com/JohnTechnical.mp4&#39;, {<br>      headers: {<br>        &#39;accept-encoding&#39;: &#39;identity;q=1, *;q=0&#39;,<br>        range: &#39;bytes=1540096-&#39;,<br>        &#39;sec-ch-ua&#39;: &#39;&quot;Google Chrome&quot;;v=&quot;119&quot;, &quot;Chromium&quot;;v=&quot;119&quot;, &quot;Not?A_Brand&quot;;v=&quot;24&quot;&#39;,<br>        &#39;sec-ch-ua-mobile&#39;: &#39;?0&#39;,<br>        &#39;sec-ch-ua-platform&#39;: &#39;&quot;Windows&quot;&#39;,<br>      },<br>    })<br>  })<br>}</pre><p>The export const options tells k6 to use 10 virtual users for 5 minutes. Each virtual user will execute the default option above. After finish that, the virtual user will execute another iteration of the scenario till the testing time ends.</p><h3>Run the test on Grafana k6 cloud</h3><p>After running the test on Grafana k6 cloud, you can see the analysis result from Grafana Cloud with information about HTTP response time, HTTP request rate, or HTTP failure rate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mv1qN5ST5ULg-KEVfhD1gg.png" /><figcaption>Analysis result of the k6 test on Grafana cloud</figcaption></figure><p>Using the analysis result information, you now can check how your application perform with typical end-user journeys so that you can improve your application performance if there are any issues occurring.</p><h3>Conclusion</h3><p>Through the article, you can see how quick and easy it is to start synthetic testing for your application using k6. If you want to learn more about how to use k6 to apply performance testing for your application, checkout the <a href="https://k6.io/docs/">k6 documentation</a> page for details.</p><p>~~Happy testing, guys~~</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cb263307ee0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/automation-with-donald/synthetic-testing-a-next-js-app-using-grafana-k6-cloud-4cb263307ee0">Synthetic testing a Next.js app using Grafana k6 cloud</a> was originally published in <a href="https://medium.com/automation-with-donald">Automation with Love</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Intercept API requests using Playwright]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/automation-with-donald/intercept-api-requests-using-playwright-8c24e191294b?source=rss----269efa07d359---4"><img src="https://cdn-images-1.medium.com/max/2600/0*B98PkjLVAbyS0DXN" width="6749"></a></p><p class="medium-feed-snippet">Playwright is a great browser testing framework with a lot of modern features such as auto-wait, and parallel testing. One of its most&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/automation-with-donald/intercept-api-requests-using-playwright-8c24e191294b?source=rss----269efa07d359---4">Continue reading on Automation with Love »</a></p></div>]]></description>
            <link>https://medium.com/automation-with-donald/intercept-api-requests-using-playwright-8c24e191294b?source=rss----269efa07d359---4</link>
            <guid isPermaLink="false">https://medium.com/p/8c24e191294b</guid>
            <category><![CDATA[end-to-end-testing]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[api-management]]></category>
            <category><![CDATA[playwrights]]></category>
            <dc:creator><![CDATA[Donald Le]]></dc:creator>
            <pubDate>Sun, 20 Aug 2023 08:55:30 GMT</pubDate>
            <atom:updated>2023-08-20T08:55:30.626Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Intercepting API requests using Cypress]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/automation-with-donald/intercepting-api-requests-using-cypress-59855490afcb?source=rss----269efa07d359---4"><img src="https://cdn-images-1.medium.com/max/2600/0*nrz1_5BP5HDLb8X8" width="4160"></a></p><p class="medium-feed-snippet">When implementing automation testing for your web applications, sometimes you want to test for edge cases, such as checking how your&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/automation-with-donald/intercepting-api-requests-using-cypress-59855490afcb?source=rss----269efa07d359---4">Continue reading on Automation with Love »</a></p></div>]]></description>
            <link>https://medium.com/automation-with-donald/intercepting-api-requests-using-cypress-59855490afcb?source=rss----269efa07d359---4</link>
            <guid isPermaLink="false">https://medium.com/p/59855490afcb</guid>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[intercepts]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[end-to-end-testing]]></category>
            <dc:creator><![CDATA[Donald Le]]></dc:creator>
            <pubDate>Sun, 20 Aug 2023 07:16:48 GMT</pubDate>
            <atom:updated>2023-08-20T07:16:48.726Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Crafting your automation skill with a real-world application usingPlaywright]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/automation-with-donald/crafting-your-automation-skill-with-a-real-world-application-usingplaywright-6742d98a7a47?source=rss----269efa07d359---4"><img src="https://cdn-images-1.medium.com/max/2600/0*BvnYLzNp_EGm21Za" width="2902"></a></p><p class="medium-feed-snippet">Playwright is an excellent automation testing tool that supports parallel testing out of the box, not to mention the modern features such&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/automation-with-donald/crafting-your-automation-skill-with-a-real-world-application-usingplaywright-6742d98a7a47?source=rss----269efa07d359---4">Continue reading on Automation with Love »</a></p></div>]]></description>
            <link>https://medium.com/automation-with-donald/crafting-your-automation-skill-with-a-real-world-application-usingplaywright-6742d98a7a47?source=rss----269efa07d359---4</link>
            <guid isPermaLink="false">https://medium.com/p/6742d98a7a47</guid>
            <category><![CDATA[playwrights]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Donald Le]]></dc:creator>
            <pubDate>Sun, 20 Aug 2023 04:33:49 GMT</pubDate>
            <atom:updated>2023-08-19T08:22:28.675Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Cypress await async, finally]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/automation-with-donald/cypress-await-async-finally-9b93479c216f?source=rss----269efa07d359---4"><img src="https://cdn-images-1.medium.com/max/2600/0*_KzguZaq8dD9ktnm" width="3648"></a></p><p class="medium-feed-snippet">Recently Gleb Bahmutov created a plugin that allows Cypress test to have async await syntax support so that you don&#x2019;t have to always put&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/automation-with-donald/cypress-await-async-finally-9b93479c216f?source=rss----269efa07d359---4">Continue reading on Automation with Love »</a></p></div>]]></description>
            <link>https://medium.com/automation-with-donald/cypress-await-async-finally-9b93479c216f?source=rss----269efa07d359---4</link>
            <guid isPermaLink="false">https://medium.com/p/9b93479c216f</guid>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[asyncawait]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[end-to-end-testing]]></category>
            <category><![CDATA[cypress]]></category>
            <dc:creator><![CDATA[Donald Le]]></dc:creator>
            <pubDate>Sun, 20 Aug 2023 04:33:10 GMT</pubDate>
            <atom:updated>2023-08-20T04:33:10.789Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Integrate k6-browser with LambdaTest]]></title>
            <link>https://medium.com/automation-with-donald/integrate-k6-browser-with-lambdatest-8ee11175cfe9?source=rss----269efa07d359---4</link>
            <guid isPermaLink="false">https://medium.com/p/8ee11175cfe9</guid>
            <category><![CDATA[browser-testing]]></category>
            <category><![CDATA[k6]]></category>
            <category><![CDATA[playwright-test]]></category>
            <category><![CDATA[performance-testing]]></category>
            <category><![CDATA[lambdatest]]></category>
            <dc:creator><![CDATA[Donald Le]]></dc:creator>
            <pubDate>Thu, 10 Aug 2023 23:19:31 GMT</pubDate>
            <atom:updated>2023-08-10T23:18:21.445Z</atom:updated>
            <content:encoded><![CDATA[<h4>No more setting up Selenium to run concurrently with the load testing tool to understand user experience when the application is under heavy load; you have k6 now.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iEUZlHasxi7ZaUtS" /><figcaption>Photo by <a href="https://unsplash.com/@frostroomhead?utm_source=medium&amp;utm_medium=referral">Rodion Kutsaiev</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>k6 is one of the first performance testing tools supporting protocol and browser-based testing. You can now run the performance test for your web application through the web browser, just like normal users would do. Sometimes you want to run the test in a device farm, such as saving the local machine’s resources to do other tasks, or you don’t have the operating system the tests require.</p><p>Understanding those needs, k6 recently implemented new features allowing you to integrate k6-browser with LambdaTest to trigger your performance testing for your web application on any device you want. In this article, let’s see how you could do it with k6-browser</p><h3>The demo application</h3><p>You will run the k6-browser test on <a href="https://twilio-music-info-app-ha8m.vercel.app/">an application showing my top ten favorite artists and songs on Spotify</a>. :D</p><p>This application was built using Next.js for the front end and Spotify API to collect favorite artists and favorite songs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ieuIIUq398vk_qmOTQA9fA.png" /></figure><h3>The test scripts</h3><p>Create a new file named spotifyDashboard-k6.js with the following code in it:</p><pre>import { chromium } from &#39;k6/experimental/browser&#39;;<br>import { expect } from &#39;https://jslib.k6.io/k6chaijs/4.3.4.3/index.js&#39;<br><br><br>export default async function () {<br>    const capabilities = {<br>        &#39;browserName&#39;: &#39;Chrome&#39;,<br>        &#39;browserVersion&#39;: &#39;108&#39;,<br>        &#39;LT:Options&#39;: {<br>          &#39;platform&#39;: &#39;Windows 8&#39;,<br>          &#39;build&#39;: &#39;K6 Build&#39;,<br>          &#39;name&#39;: &#39;K6 Spotify Dashboard Test&#39;,<br>          &#39;user&#39;: __ENV.LT_USERNAME,<br>          &#39;accessKey&#39;: __ENV.LT_ACCESS_KEY,<br>          &#39;network&#39;: true,<br>          &#39;video&#39;: true,<br>          &#39;console&#39;: true,<br>          &#39;tunnel&#39;: false, <br>          &#39;tunnelName&#39;: &#39;&#39;,<br>          &#39;geoLocation&#39;: &#39;None&#39; <br>        }<br>      }<br>    <br>    const wsURL = `wss://cdp.lambdatest.com/k6?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`<br>    const browser = chromium.connect(wsURL)<br>    const page = browser.newPage()<br><br>    await page.goto(&#39;https://twilio-music-info-app-ha8m.vercel.app/&#39;);<br>    page.screenshot({ path: &#39;screenshots/browserTestScreenshot.png&#39; });<br><br>    const songElements = await page.$$(&#39;a[class*=&quot;bg-gray-100 hover&quot;]&#39;);<br>    const artistElements = await page.$$(&#39;a[class*=&quot;flex items-center gap-5 p-4 overflow-hidden bg-gray-100 border-b&quot;]&#39;);<br><br>    expect(songElements.length).to.equal(10),<br><br>    expect(artistElements.length).to.equal(10),<br><br>    page.close()<br>    browser.close();<br>}</pre><p>In this scenario, you only use one virtual user with one iteration only because we are focusing on how to run the k6-browser test in LambdaTest. When you do not include the export const options variable in the test file, k6 will use only one virtual user with one iteration by default.</p><p>The capabilities the variable defines the browser and the machine that the test will be executed on LambdaTest. You’re telling LambdaTest to run the test using Windows 8 machine and Chrome version 108.</p><p>The wsURL variable defines the WebSocket address to connect to LambdaTest browser based on the encoded capabilities value.</p><p>To connect with the Chrome browser in LambdaTest, you use chromium.connect(wsURL) .</p><pre>await page.goto(&#39;https://twilio-music-info-app-ha8m.vercel.app/&#39;);<br>    page.screenshot({ path: &#39;screenshots/browserTestScreenshot.png&#39; });<br><br>    const songElements = await page.$$(&#39;a[class*=&quot;bg-gray-100 hover&quot;]&#39;);<br>    const artistElements = await page.$$(&#39;a[class*=&quot;flex items-center gap-5 p-4 overflow-hidden bg-gray-100 border-b&quot;]&#39;);<br><br>    expect(songElements.length).to.equal(10),<br><br>    expect(artistElements.length).to.equal(10),</pre><p>In this block of code, you tell the k6-browser to navigate to the Spotify music app URL to verify if the number of songs and the number of artists are equal to ten. To get all web elements that match a specific CSS collector, you’re using page.$$(&#39;css-Selector&#39;) method.</p><p><strong>Note: </strong>Currently, if you’re using page.locator to locate an element, the k6-browser will only return one element that matches the locator, so you cannot get the correct song and artist number. That’s why you’re using page.$$() the method here, even though k6 recommends you <a href="https://k6.io/docs/javascript-api/k6-experimental/browser/page/page-$/">use </a><a href="https://k6.io/docs/javascript-api/k6-experimental/browser/page/page-$/">page.locator</a> it to locate elements instead.</p><h3>Run the test</h3><p>To run the test, you need to export the information for your LambdaTest username and its access key.</p><pre>export LT_USERNAME=your-user-name<br>export LT_ACCESS_KEY=your-access-key</pre><p>Then run the following command:</p><pre>K6_BROWSER_ENABLED=true k6 run spotifyDashboard-k6.js</pre><p>You should see the similar result in the console as below:</p><pre> ✓ expected ${this} to equal 10<br><br>     checks.................................: 100.00% ✓ 2         ✗ 0  <br>     data_received..........................: 1.1 MB  535 kB/s<br>     data_sent..............................: 15 kB   6.9 kB/s<br>     http_req_connecting....................: avg=3.18ms   min=0s       med=0s       max=118ms    p(90)=0s       p(95)=0s      <br>     http_req_duration......................: avg=162.08ms min=33.26ms  med=100.23ms max=449.34ms p(90)=348.07ms p(95)=353.14ms<br>     http_req_receiving.....................: avg=138.24ms min=0s       med=89ms     max=425ms    p(90)=303.59ms p(95)=319.19ms<br>     http_req_sending.......................: avg=324.32µs min=0s       med=0s       max=2ms      p(90)=1ms      p(95)=1ms     <br>     http_req_tls_handshaking...............: avg=2.16ms   min=0s       med=0s       max=80ms     p(90)=0s       p(95)=0s      <br>     http_reqs..............................: 37      17.501859/s<br>     iteration_duration.....................: avg=2.11s    min=2.11s    med=2.11s    max=2.11s    p(90)=2.11s    p(95)=2.11s   <br>     iterations.............................: 1       0.473023/s<br>     vus....................................: 1       min=1       max=1<br>     vus_max................................: 1       min=1       max=1<br>     webvital_first_contentful_paint........: avg=615.59ms min=615.59ms med=615.59ms max=615.59ms p(90)=615.59ms p(95)=615.59ms<br>     webvital_first_contentful_paint_good...: 1       0.473023/s<br>     webvital_time_to_first_byte............: avg=194.19ms min=194.19ms med=194.19ms max=194.19ms p(90)=194.19ms p(95)=194.19ms<br>     webvital_time_to_first_byte_good.......: 1       0.473023/s<br><br><br>running (00m02.1s), 0/1 VUs, 1 complete and 0 interrupted iterations<br>default ✓ [======================================] 1 VUs  00m02.1s/10m0s  1/1 iters, 1 per VU</pre><p>Going to the LambdaTest dashboard, you can see the video recording of executing the test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6bKmuRL-NPQa8ullQEMf7A.png" /></figure><h3>Understanding the metrics</h3><p>k6-browser adopts the <a href="https://github.com/GoogleChrome/web-vitals">Google best practices for vital metrics</a> to understand three important aspects of user experience:</p><ul><li>Loading Performance</li><li>Interactivity</li><li>Visual Stability</li></ul><p>In the console report, you can see the recorded performance metrics for your application. Besides default metrics like http_reqs or data_sent that you have when running tests for HTTP requests, you now have custom metrics for the UI web application performance:</p><pre>webvital_first_contentful_paint........: avg=615.59ms min=615.59ms med=615.59ms max=615.59ms p(90)=615.59ms p(95)=615.59ms<br>webvital_first_contentful_paint_good...: 1       0.473023/s<br>webvital_time_to_first_byte............: avg=194.19ms min=194.19ms med=194.19ms max=194.19ms p(90)=194.19ms p(95)=194.19ms<br>webvital_time_to_first_byte_good.......: 1       0.473023/</pre><ul><li>webvital_first_contentful_paint : this metric measures the time from the application starts until the first content on the application page is rendered.</li><li>webvital_first_contentful_paint_good : the rating for the webvital_first_contentful_paint` . Because you only sent one iteration, the result is good.</li><li>webvital_time_to_first_byte : this metric measures the time from the time that the request is executed until the first byte of the response is received</li><li>webvital_time_to_first_byte_good : the rating for the webvital_time_to_first_byte. Because you only sent one iteration, the result is good.</li></ul><h3>Visualize the metrics</h3><p>The console report is a short version of available metrics that the k6-browser captures. If you want to have all the metrics and be able to visualize them so that you can quickly understand how your UI web application works, you can visualize them using Prometheus to store the data and Grafana to visualize.</p><p>Clone the <a href="https://github.com/grafana/xk6-output-prometheus-remote">xk6-output-prometheus-remote</a> repository created by Grafana team.</p><p>Run the following command from the root directory of the cloned repository:</p><pre>docker compose up -d</pre><p>You should see the Prometheus and Grafana containers up and running.</p><pre>[+] Running 23/23<br> ✔ grafana 9 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                                                                                                       34.3s <br>   ✔ 4db1b89c0bd1 Pull complete                                                                                                                                                                               4.4s <br>   ✔ 5d826d07bc4b Pull complete                                                                                                                                                                               4.4s <br>   ✔ bd304fdbf49f Pull complete                                                                                                                                                                               4.8s <br>   ✔ ed59c63897ad Pull complete                                                                                                                                                                               4.9s <br>   ✔ 64bc06362185 Pull complete                                                                                                                                                                               5.0s <br>   ✔ a02d3acd2d42 Pull complete                                                                                                                                                                               5.0s <br>   ✔ c5d09a6787ef Pull complete                                                                                                                                                                              12.4s <br>   ✔ 749ebef77de4 Pull complete                                                                                                                                                                              27.4s <br>   ✔ a72374eecc76 Pull complete                                                                                                                                                                              27.4s <br> ✔ prometheus 12 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                                                                                                40.5s <br>   ✔ 30ec41fb8fed Pull complete                                                                                                                                                                              10.6s <br>   ✔ e5f8ba06cb61 Pull complete                                                                                                                                                                              12.7s <br>   ✔ 5d47f929abda Pull complete                                                                                                                                                                              32.4s <br>   ✔ f98450aaa79e Pull complete                                                                                                                                                                              33.4s <br>   ✔ 2ca2eba21948 Pull complete                                                                                                                                                                              33.4s <br>   ✔ ff129d3d6d74 Pull complete                                                                                                                                                                              33.4s <br>   ✔ 4fee571a1cf5 Pull complete                                                                                                                                                                              33.5s <br>   ✔ ebe7f681b016 Pull complete                                                                                                                                                                              33.5s <br>   ✔ 51d55bf673c1 Pull complete                                                                                                                                                                              33.5s <br>   ✔ d033d1656b56 Pull complete                                                                                                                                                                              33.6s <br>   ✔ 93e64195a1ec Pull complete                                                                                                                                                                              33.6s <br>   ✔ 13595d3b00dd Pull complete                                                                                                                                                                              33.6s <br>[+] Building 86.6s (13/16)                                                                                                                                                                                         <br>[+] Building 86.9s (13/16)                                                                                                                                                                                         <br>[+] Building 88.6s (13/16)                                                                                                                                                                                         <br>[+] Building 89.5s (13/16)                                                                                                                                                                                         <br>[+] Building 89.8s (13/16)                                                                                                                                                                                         <br>[+] Building 140.2s (17/17) FINISHED                                                                                                                                                                               <br> =&gt; [k6 internal] load build definition from Dockerfile       </pre><p>Then run the following command to export metrics to the Prometheus database.</p><pre>K6_BROWSER_ENABLED=true k6 run -o experimental-prometheus-rw spotifyDashboard-k6.js</pre><p>You should see a similar output as below:</p><pre>          /\      |‾‾| /‾‾/   /‾‾/   <br>     /\  /  \     |  |/  /   /  /    <br>    /  \/    \    |     (   /   ‾‾\  <br>   /          \   |  |\  \ |  (‾)  | <br>  / __________ \  |__| \__\ \_____/ .io<br><br>  execution: local<br>     script: localSpotifyDashBoardApp.js<br>     output: Prometheus remote write (http://localhost:9090/api/v1/write)<br><br>  scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):<br>           * default: 1 iterations for each of 1 VUs (maxDuration: 10m0s, gracefulStop: 30s)</pre><p>Now, when you go to the <a href="http://localhost:9090/">Prometheus dashboard</a>, you can see the k6 metrics are stored in the Prometheus database.</p><p>You can also go to the Grafana dashboard to create the dashboard for the captured k6 metrics. Below is an example Grafana dashboard with metrics for webvitals , HTTP requests receiving 99 percentile, and iterations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s-8yol3jqgJQmLZU0Z_oag.png" /></figure><p>The article taught you how to integrate k6 with LambdaTest to implement browser testing. You also learned how to export test metrics to the Prometheus database so that you can visualize the metrics using the Grafana dashboard to grasp the test result quickly.</p><p>If you want to learn more about how k6-browser works, visit <a href="https://k6.io/docs/using-k6-browser/overview/">k6 documentation</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ee11175cfe9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/automation-with-donald/integrate-k6-browser-with-lambdatest-8ee11175cfe9">Integrate k6-browser with LambdaTest</a> was originally published in <a href="https://medium.com/automation-with-donald">Automation with Love</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Allure-testng cannot capture the test steps]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/automation-with-donald/allure-testng-cannot-capture-the-test-steps-dbdede4ebcba?source=rss----269efa07d359---4"><img src="https://cdn-images-1.medium.com/max/2600/0*bdz2vd1uqJ1hPqnU" width="3024"></a></p><p class="medium-feed-snippet">Recently, I encountered a problem when working with allure-testng, which caused the allure report does not show the @steps annotation from&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/automation-with-donald/allure-testng-cannot-capture-the-test-steps-dbdede4ebcba?source=rss----269efa07d359---4">Continue reading on Automation with Love »</a></p></div>]]></description>
            <link>https://medium.com/automation-with-donald/allure-testng-cannot-capture-the-test-steps-dbdede4ebcba?source=rss----269efa07d359---4</link>
            <guid isPermaLink="false">https://medium.com/p/dbdede4ebcba</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[allure]]></category>
            <category><![CDATA[testng]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Donald Le]]></dc:creator>
            <pubDate>Fri, 14 Apr 2023 09:06:45 GMT</pubDate>
            <atom:updated>2023-04-14T09:06:25.821Z</atom:updated>
        </item>
    </channel>
</rss>