<?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 Kumar Jitendra  on Medium]]></title>
        <description><![CDATA[Stories by Kumar Jitendra  on Medium]]></description>
        <link>https://medium.com/@log2jeet24?source=rss-e28979e88988------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*_g6ajgSKqqvpXdJaqN01sw@2x.jpeg</url>
            <title>Stories by Kumar Jitendra  on Medium</title>
            <link>https://medium.com/@log2jeet24?source=rss-e28979e88988------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 18:29:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@log2jeet24/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[Git Hub Actions Integration with Playwright and Cypress]]></title>
            <link>https://medium.com/@log2jeet24/git-hub-actions-integration-with-playwright-and-cypress-39bf17ad93a3?source=rss-e28979e88988------2</link>
            <guid isPermaLink="false">https://medium.com/p/39bf17ad93a3</guid>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[playwright-automation]]></category>
            <category><![CDATA[cypress-testing]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Kumar Jitendra ]]></dc:creator>
            <pubDate>Wed, 10 Jan 2024 03:06:43 GMT</pubDate>
            <atom:updated>2024-02-21T07:08:00.881Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Git Hub Actions Integration with Playwright and Cypress</strong>.</p><p>Understanding the GitHub Actions Workflow is very essential for every developer or a software engineer who is working with the code, as it helps in achieving the Devops -Continuous Integration /Continuous Delivery pipeline.</p><p>While various CI/CD tools, like Jenkins, are commonly used by automation testers, this blog will specifically focus on <strong>GitHub Actions</strong>. Nowadays, many engineers use GitHub for version control and collaboration, making GitHub Actions the preferred choice for automation testers and developers when implementing CI/CD.</p><p><strong>In this blog, I will cover the following topics:</strong></p><ol><li>What are GitHub Actions?</li><li>The components of GitHub Actions</li><li>How to set up GitHub Actions in a GitHub repository with Playwright and Cypress Repository.</li><li>How to view GitHub Actions activity</li></ol><p><strong>Introduction to GitHub Actions:</strong> -</p><p>GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform that allows you to automate your build, test, and deployment pipeline. You can create workflows that build and test every pull request to your repository or deploy merged pull requests to production.</p><p>GitHub Actions goes beyond just DevOps and lets you run workflows when other events happen in your repository. For example, you can run a workflow to automatically add the appropriate labels whenever someone creates a new issue in your repository.</p><p>GitHub provides Linux, Windows, and macOS virtual machines to run your workflows, or you can host your own self-hosted runners in your own data center or cloud infrastructure.</p><p>GitHub Actions works with various languages and frameworks, and its configurations are in YAML. This means you can easily edit, reuse, share, and copy them like regular code</p><p><strong>Components of GitHub Actions</strong></p><p>You can configure a GitHub Actions <em>workflow</em> to be triggered when an <em>event</em> occurs in your repository, such as a pull request being opened, or an issue being created. Your workflow contains one or more <em>jobs</em> which can run in sequential order or in parallel. Each job will run inside its own virtual machine <em>runner</em>, or inside a container, and has one or more <em>steps</em> that either run a script that you define or run an <em>action</em>, which is a reusable extension that can simplify your workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9NcImz3eMJVj59Hp.png" /></figure><p>If you’ve configured GitHub Actions in your Git repository, and you push code to the remote branch, the GitHub Action will automatically trigger the predefined workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*QUWKA7fw88fVOy_7.png" /></figure><h3><strong>One example of GitHub Actions is:</strong></h3><p>If you’ve configured GitHub Actions in your Git repository and you push code to the remote branch, the GitHub Action will automatically trigger the predefined workflow.</p><p>It supports various events such as opening pull requests, merging code, or pushing to a branch, making it a powerful and flexible tool for different scenarios. GitHub Actions, being event-driven, responds to these events by executing the specified workflows.</p><ul><li>Workflow — A workflow defines a sequence of steps that are executed in response to a specific event. These events can range from code changes (push or pull requests) to external triggers, such as scheduled intervals or API calls. Workflow is created in yaml file.</li><li><strong>Different components under the GitHub Actions</strong>:-</li><li><strong>Triggers</strong> — Triggers are the events that initiate the execution of a workflow. GitHub Actions supports a wide range of triggers, including:</li><li><strong>Push events</strong>: When code is pushed to a repository</li><li><strong>Pull request events</strong>: When a pull request is created, updated, or merged</li><li><strong>Schedule events</strong>: Executing a workflow at specific times or intervals</li><li><strong>Manual events</strong>: Triggering a workflow manually from the repository</li><li><strong>Webhook events</strong>: Receiving events from external sources, such as other applications or services</li><li><strong>Jobs</strong> — A workflow is composed of one or more jobs. Each job represents a specific task within the automation process, such as building, testing, or deploying code. Jobs can be executed in parallel or sequentially, depending on the workflow configuration.</li><li><strong>Steps</strong> — Steps are the fundamental units of execution within a job. Each step performs a specific action, such as running a command, installing software, or publishing artifacts. Steps can be chained together to form a complex automation task.</li></ul><p><strong>Pre-Requisite: </strong>One needs to have a GitHub repository, to create and run a GitHub Actions workflow. GitHub Actions uses YAML syntax to define the workflow.</p><p>In the GitHub repository, one needs to create.github/workflows/directory and add a .yml file.</p><p>Add .yml file .github/workflows/main.yml ( It has to be in the same sequence. You can pass any name of your choice for .ym file)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*P1s98TEdk68_Y9BoP1-6ug.png" /></figure><p>Add the .yml flow for the Cypress Flow Integration: -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eOlto7E902miUOac9zQM-w.png" /></figure><p>Add .yml file for the Playwright Integration</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*BdywwvIYndo8OU9oNOCgJA.png" /></figure><p>Add the e2etest.yml file for executing the test for both the Playwright and Cypress together</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o7YayDdIJrSkztXsKg9PgQ.png" /></figure><p>Now whenever any of the code is committed the to the main branch — Git Hub Actions will run the test for both the Cypress and Playwright test together.</p><p>3. Select the workflow you want to see from the left sidebar — under the Git Hub Repository (Actions tab) .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8VeUOLU3_lx1i1Z56dCr-A.png" /></figure><p>We can see for both the Cypress and Playwright test is executed — under the Git Repository — Workflow for both the Cypress and Playwright test is executed separately.</p><p>We can check the Playwright Report — which will be generated: -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tSz-umQTkbiD3d9IeMzuDQ.png" /></figure><p>Playwright Report will get generated</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wf5SfHPyjx31RNYvie4GyA.png" /></figure><p>Cypress Test Execution: -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vnCG_WI8RYXoxSO-mgGPiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z1QH2OnEehQ3qozvyROixQ.png" /></figure><p>Cypress test will get executed: -</p><p>Conclusion: - In the following blog we have seen how with the help of GitHub Actions workflow — we can configure the workflow — and how it&#39;s easy to create and manage the automation workflows.</p><p>Thanks for reading and thanks <a href="https://medium.com/u/cf4a02363eb1">Anshita Bhasin</a> for her initial blog which provided me the support and motivation on writing it and spreading the knowledge.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39bf17ad93a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Definition of Async and await concepts in Java Script.]]></title>
            <link>https://medium.com/@log2jeet24/definition-of-async-and-await-concepts-in-java-script-6792c0ce80b7?source=rss-e28979e88988------2</link>
            <guid isPermaLink="false">https://medium.com/p/6792c0ce80b7</guid>
            <category><![CDATA[javascript-frameworks]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[promises]]></category>
            <category><![CDATA[javascript-development]]></category>
            <dc:creator><![CDATA[Kumar Jitendra ]]></dc:creator>
            <pubDate>Thu, 07 Dec 2023 11:54:55 GMT</pubDate>
            <atom:updated>2023-12-07T11:54:55.404Z</atom:updated>
            <content:encoded><![CDATA[<p>Definition of Async and await concepts in Java Script.</p><p><strong>Introduction</strong>:-</p><p>In JavaScript, to write or declare any asynchronous function — we can write with the help of async keyword. With the help of await keyword, we can call any asynchronous function.</p><p><strong>JavaScript Async/Await Keyword Definition: -</strong></p><p>We use the async keyword with a function to represent that the function is an asynchronous function. Async functions always return a promise. If the return value of an async function is not explicitly a promise, it will be implicitly wrapped in a promise.</p><p>The syntax of async function is:</p><pre>async function name(parameter1, parameter2, ...paramaterN) {<br>    // statements<br>}</pre><p>Here,</p><ul><li><strong>name</strong> — name of the function</li><li><strong>parameters</strong> — parameters that are passed to the function</li></ul><p><strong>Example: -</strong> Async function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*AYAbmlpeDrgTxpxqvBiXiQ.png" /></figure><p>Output: -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*FOxqXfp6AoV3oqHTvT7hxQ.png" /></figure><p>Example 02: - async function can also have synchronous steps and async function will always return a promise whether it is resolved or reject.</p><p>In the below examples we can see that we can call the async function with the help of then statement — as asynchronous function returns a promise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*qL5oeiDJP4B20aMONoEubw.png" /></figure><p>Output: -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*D3cXKbpU3lX5Cevynh87QQ.png" /></figure><p><strong>JavaScript -await keyword: -</strong> The await keyword is used inside the async function to wait for the asynchronous operation.</p><p>The use of await pauses the async function until the promise returns a result (resolve or reject) value. For example,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*iHM8P7bvxO7LEnx-nV0BEg.png" /></figure><p>Output: -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*f4dzT-tAGCbnY-YLTcxDwQ.png" /></figure><p>In the above program, a Promise object is created, and it gets resolved after <strong>4000</strong> milliseconds. Here, the asyncFunc() function is written using the async function.</p><p>The await keyword waits for the promise to be complete (resolve or reject).</p><p>The async function allows the asynchronous method to be executed in a seemingly synchronous way. Though the operation is asynchronous, it seems that the operation is executed in synchronous manner.</p><p>This can be useful if there are multiple promises in the program.</p><p><strong>Example 02:</strong> - showing the async/await keywords examples :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1biu1KFyZbowlJMAZrAVfQ.png" /></figure><p>Write another async function and call the async function with the help of await keyword inside the async function :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PUB-TpVcOTN4UxWFHDR61w.png" /></figure><p>//Call the function — getallInfo()</p><p>Output :-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*3wM9SNtEQSK4cWunVmLTMw.png" /><figcaption>Here we can see the Output of the code — as the return of the promise which showcases the resolved function result.</figcaption></figure><p>Use of async and await enables the use of ordinary try / catch blocks around asynchronous code.</p><p><strong>Important Points to remember</strong> :-</p><p>The await keyword is only valid inside async functions within regular JavaScript code. If you use it outside of an async function&#39;s body, you will get a <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError">SyntaxError</a>. await can be used on its own with <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules">JavaScript modules.</a></p><p>The purpose of async/await is to simplify the syntax necessary to consume promise-based APIs. The behavior of async/await is like combining <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_generators">generators</a> and promises.</p><p><strong>CONCLUSION: -</strong></p><p>With the help of async/await keyword following benefits can be achieved while handling the asynchronous call: -</p><ul><li>The code is more readable than using a <a href="https://www.programiz.com/javascript/callback">callback</a> or a <a href="https://www.programiz.com/javascript/promise">promise</a>.</li><li>Error handling is simpler.</li><li>Debugging is easier.</li><li>Multiple promises can be handled in a synchronous manner using the await keywords — as we can track multiple promise statements in one go for each of the promise separately.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6792c0ce80b7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript — Different types of Promise Object Methods to handle the asynchronous call.]]></title>
            <link>https://medium.com/@log2jeet24/javascript-different-types-of-promise-object-methods-to-handle-the-asynchronous-call-fc93d1506574?source=rss-e28979e88988------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc93d1506574</guid>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[promises-in-javascript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[promises]]></category>
            <dc:creator><![CDATA[Kumar Jitendra ]]></dc:creator>
            <pubDate>Sat, 25 Nov 2023 04:57:06 GMT</pubDate>
            <atom:updated>2023-12-07T09:38:03.368Z</atom:updated>
            <content:encoded><![CDATA[<p>JavaScript — Different types of Promise Object Methods to handle the asynchronous call.</p><p><strong>Introduction: -</strong></p><p>In my previous blog, we have discussed around the definition of Promise Object in Java Script and how with the help of Promise Object in Java Script — it is easier to handle the different asynchronous calls.</p><p>Link for Previous blog: - <a href="https://medium.com/@log2jeet24/promises-in-javascript-and-different-types-of-promises-handling-in-java-script-531e389974a2">JavaScript — Promises Introduction to handle the Asynchronous calls in Java Script. | by Kumar Jitendra | Nov, 2023 | Medium</a></p><p>We are going to discuss in the blog about the distinct types of Promise Methods available in Java Script: -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*XzMAJMF7zP-latB8uq09bQ.png" /></figure><p>We will discuss about each of the Promise methods available in Java Script in details:-</p><p>a) <strong>all (iterable — array) method</strong>: — With the<strong> help of promise. all () — method</strong> we can catch multiple promise statements (multiple asynchronous functions) inside the array. Suppose if we have 3 different asynchronous functions — and we want to call the asynchronous functions in one go — with the <strong>help of promise. All () - we can pass all the functions inside the array and execute all the asynchronous functions in one go</strong>.</p><p>Example to demonstrate the promise.all() — method in Java Script method: -</p><p>Let&#39;s create three different asynchronous functions: -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*as2nJ9LmZeNe5izu4kZU_w.png" /></figure><p>Usage of <strong>promise.all(Array of functions)</strong> — We can pass an array of functions inside the Promise.all() method: -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*rXlfRwB-TBQiGEUIcv00WQ.png" /></figure><p>Output: - We can check the<strong> Array Output of all the promise statements inside a single array</strong> — which will show all the collective function values from all the three functions: -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*pniH3YTlNjSSWdvSYW0rPw.png" /></figure><p><strong>Disadvantage of Promise.all() method</strong>: - With the help of Promise.all() method — all the asynchronous functions need to be resolved — and if <strong>any of the asynchronous function throws error — it will always print the error statement </strong>— handled under the catch statement.</p><p>Example demonstrating the error statement — using the promise.all() method: -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*Si9lIZzF537regSH6K1qgw.png" /></figure><p>With the promise.all() — though the first function is resolved — but the second function throws error — it will return only the rejected promise function.</p><p>Output: -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*_vwfbcl6FiYgrr_AXACmyA.png" /></figure><p>b) <strong>Promise.allSettled(Array of Iterables )</strong> — With the help of Promise.allSettled() method, we can iterate over each of the functions whether its resolved or rejected — it doesn&#39;t matter, and it will collectively give all the combined results.</p><p>We can iterate using the for Each Array -each of the functions array of values and print each of the function value.</p><p>Below are the examples of the t<strong>wo Asynchronous functions which we have created</strong>:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*T3y7SD1y6_FZYHVS-iIRSA.png" /></figure><p>With the help o<strong>f promise.allSettled ()</strong> — we will iterate using for each Loop over each of the function -and all the values will be returned — it doesn&#39;t matter whether the function is resolve or rejected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VA6iWF9yywXoKAxunrkp5w.png" /></figure><p>Output: — We can observe each of the function we are able to iterate whether the function is resolved or rejected — it doesn&#39;t matter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*H47Hs93J8K-E7bP2_KUmFg.png" /></figure><p>Difference between the<strong> promise. All () and promise.allSettled() method: -</strong></p><p><strong>Promise.all() Method</strong>: - It will iterate over each of the promise functions- and if any of the function is rejected due to any reason — then it will return only the rejected response and will throw an error.</p><p><strong>Promise.allSettled() Method</strong>: - It will iterate over each of the promise functions inside an array — and it doesn&#39;t matter whether the function is resolved or rejected.</p><p>c) <strong>Promise.any() Method: -</strong> This function waits for any of the function to resolved first. Suppose if we have 3 distinct functions and we wanted to know which function is resolved first — Promise.any() method will help in achieving this operation.</p><p>Examples demonstrating the Promise.any() method: -</p><p>Examples showin<strong>g three different asynchronous functions and with the help of </strong>Promise.any () method -we wanted to know which of the function is resolved first: -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z_6goE34n0B9q5jOmJfXhA.png" /></figure><p>Output: - It will show the functions which one will get resolved first. In the below Output message — we can see check first function is printed in the Output console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*ckmKnYl3Mu0ztCIIPU9Z_A.png" /></figure><p>d) <strong>Promise.race() Method</strong>: - It is a method to check which of the asynchronous functions will get executed first. Suppose if we have 3 different asynchronous and we wanted to know which of the asynchronous function will get resolved first. Promise.race() — method will help in achieving this functionality to know which of the asynchronous functions get resolved first.</p><p>Examples demonstrating the Promise.race() method — suppose if we have two different asynchronous functions and we wanted to know which of the asynchronous function will get resolved first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1nblpAVxyM_pD_GPzVapMg.png" /></figure><p>With the help of Promise.race() method — we will be able to find which of the asynchronous functions will get resolved first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xn2GLIXzKQnRArCB_2AOJA.png" /></figure><p>Output: - It will show the output which of the asynchronous function got resolved first and quicker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*CpvlZ_5g0-sO1c2zpGN_nw.png" /></figure><p>Difference between the Promise.race and Promise.any function: -</p><p><strong>Promise.any() Method</strong>: — It will show the output as which one of the asynchronous functions get resolved first.</p><p><strong>Promise.race() Method</strong>: — It will show the output as which one of the asynchronous functions get resolved quicker and takes less time in resolving the function.</p><p><strong>Conclusion</strong>: - In the following blog, we have discussed around the different types of methods available associated with the Promise class — to handle the asynchronous calls in the Java Script.</p><p>In the next blog — we will learn about the meaning of async and await concepts in Java Script.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc93d1506574" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript — Promises Introduction to handle the Asynchronous calls in Java Script.]]></title>
            <link>https://medium.com/@log2jeet24/promises-in-javascript-and-different-types-of-promises-handling-in-java-script-531e389974a2?source=rss-e28979e88988------2</link>
            <guid isPermaLink="false">https://medium.com/p/531e389974a2</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[promises-in-javascript]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <dc:creator><![CDATA[Kumar Jitendra ]]></dc:creator>
            <pubDate>Tue, 14 Nov 2023 11:12:00 GMT</pubDate>
            <atom:updated>2023-11-25T00:02:59.340Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>JavaScript — Promises Introduction to handle the Asynchronous calls in Java Script.</strong></p><p><strong>Promises Definition in Java Script: -</strong></p><p>Previous blog Description — <a href="https://medium.com/@log2jeet24/javascript-powerful-language-to-handle-the-synchronous-and-asynchronous-call-33450906af93">JavaScript — Powerful language to handle the Synchronous and Asynchronous call. | by Kumar Jitendra | Nov, 2023 | Medium</a></p><p>In my previous blog — we discussed around the Synchronous and Asynchronous operations in the JavaScript. Promises in JavaScript is an effective way of handling the Asynchronous call in the Java Script.</p><p>It is used to find out if the asynchronous operation is successfully completed or not.</p><p>A promise may have one of three states.</p><ul><li>Pending</li><li>Fulfilled</li><li>Rejected</li></ul><p>A promise starts in a pending state. That means the process is not complete. If the operation is successful, the process ends in a fulfilled state(resolved). And, if an error occurs, the process ends in a rejected state.</p><p><strong>Steps to Create a Promise in Java Script:</strong> —</p><p>To create a promise object, we use the Promise () constructor.</p><pre>let promise = new Promise (function (resolve, reject) {<br>     //do something<br>});</pre><p>The Promise () constructor takes a function as an argument. The function also accepts two functions resolve () and reject ().</p><p>If the promise returns successfully, the resolve () function is called. And, if an error occurs, the reject () function is called.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pgg4s24CIm_Gcitp8Hw2Sg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tuTWmSDQWNWE_cl3AbiUXw.png" /></figure><p>In the above program, a Promise object is created that takes two functions: resolve() and reject(). resolve () is used if the process is successful and reject () is used when an error occurs in the promise.</p><p>The promise is resolved if the value of count is true.</p><p>Working of JavaScript Promise methods —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*6BwvYZcup2BqRtET-sIPNg.png" /></figure><h3>JavaScript Promise Chaining: -</h3><p>Promises are useful <strong>when we have to handle more than one asynchronous task, one after another. For that, we use promise chaining</strong>.</p><p>You can perform an operation after a promise is resolved using methods then (), catch () and finally ().</p><h3>JavaScript then () method</h3><p>The then () method is used with the callback when the promise is successfully fulfilled or resolved.</p><p>The syntax of then () method is:</p><pre>promiseObject.then(on Fulfilled, on Rejected).</pre><h3>Example 2: Chaining the Promise with then ()</h3><pre>// returns a promise</pre><pre>let countValue = new Promise (function (resolve, reject) {<br>  resolve (&quot;Promise resolved&quot;).<br>});<br><br>// executes when promise is resolved successfully<br><br>countValue<br>  . then (function successValue(result) {<br>    console.log(result);<br>  })<br><br>  . then (function successValue1() {<br>    console.log (&quot;You can call multiple functions this way.&quot;) ;<br>  });</pre><p><strong>Output</strong></p><pre>Promise resolved<br>You can call multiple functions this way.</pre><p>In the above program, the then () method is used to chain the functions to the promise. The then () method is called when the promise is resolved successfully.</p><p>You can chain multiple then () methods with the promise.</p><p><strong>Create an asynchronous function — with the return type as Promise</strong> -resolve and reject — (function is resolved — when it returns the even numbers, and it throws error — if the function throws an error message).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*9bO8ox3T1efyyNiilSwH8A.png" /></figure><p>Examples of multiple — then call — Promise chaining</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*hjfwd1b5E29yrfJ-rYcVkw.png" /></figure><p>In this example, we can see that we are able to call multiple then statements to call the same function with different parameters.</p><h3>JavaScript catch () method</h3><p>The catch () method is used with the callback when the promise is rejected or if an error occurs. For example,</p><p>// returns a promise<br>let countValue = new Promise (function (resolve, reject) {<br> reject (‘Promise rejected’); <br>});</p><p>// executes when promise is resolved successfully<br>countValue.then(<br> function successValue(result) {<br> console.log(result);<br> },<br> )</p><p>// executes if there is an error<br>. catch (<br> function error Value(result) {<br> console.log(result);<br> }<br>);</p><p>In the above program, the promise is rejected. And the catch () method is used with a promise to handle the error.</p><p>Work of Promise chaining: -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*c00GEh_mq0ezFtO8UK8NWw.png" /></figure><h3>JavaScript Promise Versus Callback</h3><p>Promises are like <a href="https://www.programiz.com/javascript/callback">callback functions</a> in a sense that they both can be used to handle asynchronous tasks.</p><p>JavaScript callback functions can also be used to perform synchronous tasks.</p><p>Their differences can be summarized in the following points:</p><h3>JavaScript Promise</h3><ol><li>The syntax is user-friendly and easy to read.</li><li>Error handling is easier to manage.</li></ol><h3>JavaScript finally () method</h3><p>You can also use the finally () method with promises. The finally () method gets executed when the promise is either resolved successfully or rejected. For example,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*ri2cKmOlbpw_cz7aXENZpg.png" /></figure><p>Output: -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*Ihx_hXe2DWhO7-cIzVwdDg.png" /></figure><p><strong>Conclusion: -</strong></p><p>Promises in JavaScript is especially useful way to handle asynchronous calls in Java Script. Promises are like <a href="https://www.programiz.com/javascript/callback">callback functions</a> in a sense that they both can be used to handle asynchronous tasks.</p><p>In the next blog — we will lea<strong>rn about various methods available inside Promise object — which makes the handling of Asynchronous calls in the Java Script much easier</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=531e389974a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript — Powerful language to handle the Synchronous and Asynchronous call.]]></title>
            <link>https://medium.com/@log2jeet24/javascript-powerful-language-to-handle-the-synchronous-and-asynchronous-call-33450906af93?source=rss-e28979e88988------2</link>
            <guid isPermaLink="false">https://medium.com/p/33450906af93</guid>
            <dc:creator><![CDATA[Kumar Jitendra ]]></dc:creator>
            <pubDate>Tue, 07 Nov 2023 05:30:44 GMT</pubDate>
            <atom:updated>2023-11-21T10:24:30.712Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>JavaScript — Powerful language to handle the Synchronous and Asynchronous call.</strong></p><h3>Java Script-Introduction to Java Script:</h3><p>JavaScript is a lightweight programming language commonly used by web developers to add dynamic interactions to web pages, applications, servers, and even games.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/0*yE_4Lu_ZxwnkO13_.jpeg" /></figure><p>JavaScript is a weakly typed language (dynamically typed). JavaScript can be used for Client-side developments as well as Server-side developments. JavaScript is both an imperative and declarative type of language. JavaScript contains a standard library of objects, like Array, Date, and Math, and a core set of language elements like operators, control structures, and statements.</p><p>A JavaScript engin<strong>e is a program that executes JavaScript code and converts it to a language the computer understands. Every web browser contains a JavaScript engine.</strong> For example, V8 is the JavaScript engine in Google Chrome and Node.js. Different browsers have different JavaScript engines, but they implement the same basic concept under the hood.</p><p>JavaScript is also a popular language for QA automation because it provides a flexible and powerful toolset for testing web applications. With JavaScript, developers can write automated tests for web applications that run in the browser, such as end-to-end tests, integration tests, and unit tests.</p><p><strong>JavaScript is widely used as a programming language for many Automation tools available in the market like Playwright, Cypress, WebDriver IO, and many others</strong>.</p><p><strong>Synchronous way of Writing code in JavaScript</strong></p><p>JavaScript is <strong>synchronous, blocking, and single-threaded</strong>. This means that the JavaScript engine executes ou<strong>r program sequentially</strong>, one line at a time from top to bottom in the exact order of the statements. In synchronous way — <strong>each line of code is executed line by line and the execution time is more while completing the execution. This is the common feature which is available in other Programming Language like Java and Python.</strong></p><p><strong>Examples demonstrating the Synchronous way of handling the code in JS:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*W21HOU015JoJLvFU_Py-Yg.png" /></figure><p>Another example of understanding the synchronous way of handling the code in JavaScript. <br>In the below examples<strong> we can see that each line of code is executed sequentially, and the total execution time can be more</strong> — if the line of code is too complex. Each line of code is not independent, and the next line of code will only get executed when the previous line is executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*QpT30gdfhOtOV2rDSa2HTg.png" /><figcaption>JavaScript —Examples showing Synchronous way of handling code</figcaption></figure><p><strong>Asynchronous Way of Writing code in Java Script: -</strong></p><p>Unlike synchronous operations, an <strong>asynchronous operation does not block the next task from commencing even if the current task isn’t complete yet.</strong> The JavaScript engine works with additional features called Web APIs (setTimeout, setInterval, etc.) in the web browser, which allows JavaScript to behave asynchronously</p><p>With the help of these Web APIs, JavaScript can move certain tasks to the browser while JavaScript continues executing the synchronous operations. As a result of this asynchronous behavior, if we have a task that may take some time (accessing a database, file system operations, etc.), the asynchronous task can be handed off to the browser to happen in the background without blocking the next task.</p><p>JavaScript’s <strong>asynchronous programming model is well-suited for browser automation, where multiple actions often happen simultaneously</strong>. Playwright uses promises to handle asynchronous actions, which makes it easy to write code that is both readable and efficient.</p><p><strong>Asynchronous call</strong>-in simpler steps: -</p><p>a) examples of asynchronous — where each line of code is treated as task — and it is independent of each other</p><p><strong>Examples of Asynchronous function</strong>: -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-kwxQ63f6EvFICMxODzssw.png" /></figure><p>a) In the above examples we can see that the fi<strong>rst console.log statement is executed (‘Asynchronous Prog Starts)</strong>, and the<strong> third console log statement (‘Asynchronous Prog End) is</strong> executed before the set Timeout () — function.</p><p>b) <strong>set Timeout ()</strong> — is an asynchronous function which will execute parallelly after the wait time of 5 seconds -and it will be treated as an independent task, and it will be running in the background and wait for 5 seconds</p><p>c) <strong>set Timeout ()</strong> function, which is one of the browser’s Web APIs. It takes two parameters: a <strong>callback function as the first parameter and the time (specified in ms) you want to wait before executing the callback function as the second parameter</strong>. A new execution context is created and pushed to the stack. Because <strong>setTimeout is a Web API, the Web API will register the callback function passed to </strong><strong>setTimeout in the API environment and trigger the timer in the browser for 5000m</strong>s, then set Timeout is popped off the call stack.</p><p>Another usage of Asynchronous function — where we can use — it&#39;s the file read method — where we can implement the file Read Method to read the contents of the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KYgwTS3yYNDa-Ly4kQJwSQ.png" /></figure><p>Inside the fs_mod — mod<strong>ule available in Java Script — we have all the File handling — read and write modules available</strong>.</p><p><strong>Read file — is the method where we can read the text file </strong>— and it calls the anonymous function — and it stores the data inside one of the parameters.</p><p>This is another example demonstrating the usage of asynchronous function — where each statement is treated as an independent task and execution is done parallelly of one another.</p><p><strong>CONCLUSION</strong>: - On the above examples, have tried to show how the JavaScript handles the synchronous and asynchronous way of handling the code. In this post, we’ve seen a high-level overview of the steps taken by the JavaScript engine to execute synchronous code and asynchronous code. We also saw how we can make JavaScript behave asynchronously by using web APIs provided by the browser. Understanding the basics of how the JavaScript engine works, is fundamental for JavaScript developers who want to master the language.</p><p>Knowing and understanding the concepts of synchronous and asynchronous way of witing code in Java Script — helps in understanding many of the clear concepts — when we deep dive into any of the Automation tools — where many of the concepts is implemented.</p><p>In the next blog, we will continue — on how to handle the asynchronous calls by using the promise concepts and the understanding of the await keywords in the Java Script. Happy Learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33450906af93" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WebDriverIO New Update — no need to mention any Browser Version — for Chromium Browsers.]]></title>
            <link>https://medium.com/@log2jeet24/webdriverio-new-update-no-need-to-mention-any-browser-version-for-chromium-browsers-58b0b5827696?source=rss-e28979e88988------2</link>
            <guid isPermaLink="false">https://medium.com/p/58b0b5827696</guid>
            <category><![CDATA[updates]]></category>
            <category><![CDATA[chrome-for-testing]]></category>
            <category><![CDATA[edge-browser]]></category>
            <category><![CDATA[webdriver]]></category>
            <category><![CDATA[webdriverio]]></category>
            <dc:creator><![CDATA[Kumar Jitendra ]]></dc:creator>
            <pubDate>Sat, 05 Aug 2023 12:08:06 GMT</pubDate>
            <atom:updated>2023-08-05T12:08:06.086Z</atom:updated>
            <content:encoded><![CDATA[<h3>WebDriverIO New Update — no need to mention any Browser Version — for Chromium Browsers.</h3><p>WebDriverIO new update has been released on 31 July — from <strong>version 8.14 on wards — no need to mention any Chrome Driver or Edge Driver version inside the WDIO — config file</strong>.</p><p>New Browser —<strong> Chrome for Automation testing</strong> has been released — if any of the matched Browser version is not found — Chrome for Automation Testing Browser will be opened and in this case we no need to specify any Browser version for Chrome and Edge Browser.</p><p>Now we no need to mention <strong>any browser — driver service inside the wdio -conf file — and the Browser version will be handled automatically</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*pIXrk14EeB32F5AtlZF3PQ.png" /></figure><p>Steps to follow to up<strong>date an existing WDIO Project — to ensure no need to mention any browser type</strong> :-</p><p>a) Step 1 — Update th<strong>e package.json with the updated WDIO Dependency to 8.14.3</strong>. After updating the version make sure we do — npm update to update the dependencies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*7c8P0TYTkWsJiK5FErp00A.png" /></figure><p>Step 2 :- After the WDIO CLI <strong>— project is updated to the current version — 8.14.3</strong> — navigate to th<strong>e WDIO — conf file to update the Browser version</strong>.</p><p>a) <strong>For Chrome Browser</strong> :- If we give the browser version as stable — it will automatically download the Chrome for Testing Browser — and launch the Chrome for Testing Browser for testing. Now we no need to mention the Driver Version — where we want to test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*BAwbT9rw8G-vwAJk4kNwdg.png" /></figure><p><strong>For Edge Browser Update</strong> :- WebdriverIO will now automatically detect the installed version of Microsoft Edge and download the appropriate Edgedriver for you</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*mdACF5htusuUg55_Xjr0tg.png" /></figure><p>Step 3 :-</p><p>Comment out the<strong> services part — where we used to mention the particular browser driver service</strong> — which we wanted to launch — like wdio-chromedriver-service wdio-edgedriver-service.</p><p>Now we no need to mention any driver service — comment out the services section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EaxiT0eHPKhzuUmGeSiA5g.png" /></figure><p>Step 4 : — Once the above mentioned settings is done — and we run our script — Chrome for Testing for the Chrome Browser and the Edge Browser will get launched.</p><p>Run the Script — for launching the Chrome and Edge Browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*yLfULUycjtxeHMHOfmwTdg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*166s8918muyjaDceVAw3Rg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*GFzkW9DZ-aKx9qglciGxww.png" /></figure><p>We can see the Chrome for Testing Browser is getting launched and we haven&#39;t mentioned any Chrome Browser version inside the WDIO — config file.</p><p>Similarly we can see t<strong>he Edge Browser — will get launched</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*Y9GL8M_XbbHzBuNqKUuNSw.png" /></figure><p>Wishing all the best and happy learning!</p><p>WebDriver IO new Version update about the Browser Update can be found at the below link :-</p><p><a href="https://webdriver.io/blog/2023/07/31/driver-management/">Take a seat, WebdriverIO is driving for you! | WebdriverIO</a></p><p>All the sample code can be found at the below git repo link :-</p><p><a href="https://github.com/log2jiten24/WebDriverIO_TypeScript_Mocha/tree/master">https://github.com/log2jiten24/WebDriverIO_TypeScript_Mocha/tree/master</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58b0b5827696" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>