<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Anandteerth Onkar</title>
    <description>The latest articles on DEV Community by Anandteerth Onkar (@aonkar).</description>
    <link>https://dev.to/aonkar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F352383%2Fabe7336b-a5ce-42ec-bf53-9684b28caad7.png</url>
      <title>DEV Community: Anandteerth Onkar</title>
      <link>https://dev.to/aonkar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aonkar"/>
    <language>en</language>
    <item>
      <title>JavaScript: Synchronous or Asynchronous?</title>
      <dc:creator>Anandteerth Onkar</dc:creator>
      <pubDate>Fri, 27 Aug 2021 23:26:47 +0000</pubDate>
      <link>https://dev.to/aonkar/javascript-synchronous-or-asynchronous-29ia</link>
      <guid>https://dev.to/aonkar/javascript-synchronous-or-asynchronous-29ia</guid>
      <description>&lt;h3&gt;
  
  
  Understanding the Synchronous and Asynchronous operations:
&lt;/h3&gt;

&lt;p&gt;In synchronous operations, operation are performed one at a time. The next operation is unblocked only when the ongoing operation is completed.&lt;br&gt;
Simple words, you need to wait for a operation in progress to finish, in order to start the next one in the queue. &lt;/p&gt;

&lt;p&gt;In asynchronous operations, the next operation can be started before the previous one finishes.&lt;br&gt;
Asynchronous programming allows to handling of multiple requests simultaneously, thereby allowing to accomplish more tasks within shorter time span.   &lt;/p&gt;

&lt;h3&gt;
  
  
  So what is JavaScript?
&lt;/h3&gt;

&lt;p&gt;At its core, JavaScript is by default Synchronous in nature.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's break it down:&lt;/strong&gt;&lt;br&gt;
It is Synchronous because it is Single-threaded. In single-thread one operation is executed at a time.&lt;br&gt;
It blocks other operations in queue, as they need to wait until the previous operation has completed execution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In nutshell:&lt;/strong&gt;&lt;br&gt;
In JavaScript, only one operation will be executed at a time and the successive operations in stack need to wait until the ongoing operation is completed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; If JavaScript is Synchronous in nature, why on this earth Asynchronous JavaScript term so popular amongst JavaScript developers?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Answer:&lt;/strong&gt; The developers manipulate JavaScript to behave Asynchronously. To make this manipulation, there are 3 techniques:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Callback function&lt;/li&gt;
&lt;li&gt;Promises&lt;/li&gt;
&lt;li&gt;Async/Await.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Resources I recommend to understand these asynchronous techniques:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Callbacks:&lt;/strong&gt;&lt;br&gt;
Watch this awesome video by &lt;a href="https://youtu.be/8aGhZQkoFbQ"&gt;Philip Roberts&lt;/a&gt; while referring to his &lt;a href="http://latentflip.com/loupe/?code=JC5vbignYnV0dG9uJywgJ2NsaWNrJywgZnVuY3Rpb24gb25DbGljaygpIHsKICAgIHNldFRpbWVvdXQoZnVuY3Rpb24gdGltZXIoKSB7CiAgICAgICAgY29uc29sZS5sb2coJ1lvdSBjbGlja2VkIHRoZSBidXR0b24hJyk7ICAgIAogICAgfSwgMjAwMCk7Cn0pOwoKY29uc29sZS5sb2coIkhpISIpOwoKc2V0VGltZW91dChmdW5jdGlvbiB0aW1lb3V0KCkgewogICAgY29uc29sZS5sb2coIkNsaWNrIHRoZSBidXR0b24hIik7Cn0sIDUwMDApOwoKY29uc29sZS5sb2coIldlbGNvbWUgdG8gbG91cGUuIik7!!!PGJ1dHRvbj5DbGljayBtZSE8L2J1dHRvbj4%3D"&gt;Demo website&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://callbackhell.com/"&gt;Callback Hell&lt;/a&gt;: Callback Hell is a Nightmare. Refer this if you want to dig deeper into callbacks&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Promises:&lt;/strong&gt;&lt;br&gt;
Video by &lt;a href="https://www.youtube.com/watch?v=YiYtwbnPfkY&amp;amp;ab_channel=Codevolution"&gt;Codevolution&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Async/Await:&lt;/strong&gt;&lt;br&gt;
Best article on this topic by &lt;a href="https://dev.to/gafi/7-reasons-to-always-use-async-await-over-plain-promises-tutorial-4ej9?ref=hackernoon.com&amp;amp;signin=true"&gt;Mostafa Gaafar&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All 3 techniques in one video by &lt;a href="https://www.youtube.com/watch?v=F8xANXY0kaU&amp;amp;ab_channel=codeSTACKr"&gt;codeSTACKr&lt;/a&gt;&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;I will be creating articles on each of these topics. Need feedback from bloggers &amp;amp; readers of dev community, that will help me to improve my work.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>javascript</category>
      <category>callbacks</category>
      <category>promises</category>
      <category>asyncawait</category>
    </item>
    <item>
      <title>Cypress: Complete Setup Guide</title>
      <dc:creator>Anandteerth Onkar</dc:creator>
      <pubDate>Sun, 08 Aug 2021 00:33:04 +0000</pubDate>
      <link>https://dev.to/aonkar/cypress-complete-setup-guide-5d1c</link>
      <guid>https://dev.to/aonkar/cypress-complete-setup-guide-5d1c</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This blog post is a simple and easy guide for the first time Cypress users, who wish to setup Cypress on their Windows machines.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Environment Setup:
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Install node.js and Set node_home (Open Environment Variables and add the node bin folder path to Paths).&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F51tmpkhicz830xgb1y9a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F51tmpkhicz830xgb1y9a.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Install Visual Studio Code a.k.a VS Code(Recommended IDE for JS/TS projects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install plugins highlighted in image below to VS Code, by going to plugins tab.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhntxoodcbwtfuxrrq8ho.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhntxoodcbwtfuxrrq8ho.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Installing &amp;amp; Setting up Cypress:.
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Create a project folder (&lt;strong&gt;Note:&lt;/strong&gt; Don't name it as &lt;strong&gt;Cypress&lt;/strong&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's says you named it: 'CypressAutomationProject'.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open the project folder in VS Code.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F99o4iac4yuxx16mdoekt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F99o4iac4yuxx16mdoekt.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;In VS Code terminal, run a command - &lt;code&gt;npm init&lt;/code&gt; .

&lt;ul&gt;
&lt;li&gt;Enter the package name and just hit enter for other options leaving them blank.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fly841ibg234xi8hibd6c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fly841ibg234xi8hibd6c.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This will create a new package.json file in your project folder.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5s9fvsdm8vfbu1m0mmsn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5s9fvsdm8vfbu1m0mmsn.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;In VS Code terminal, run a command - &lt;code&gt;npm install --save-dev   cypress&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This will install the latest Cypress version locally as a dev dependency for your project.&lt;br&gt;
node_modules folder will be created in main project folder.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe14yny64a04d3dnphje5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe14yny64a04d3dnphje5.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; At this moment you won't be able to see the Cypress folder in your project folder. This is a bit tricky, as the suspense reveals in the next command.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In VS Code terminal, run a command - 
&lt;code&gt;./node_modules/.bin/cypress open&lt;/code&gt;
or
&lt;code&gt;npx cypress open&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8380xmsgsbc3l7105c4q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8380xmsgsbc3l7105c4q.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;When you run this command, the Cypress Test Runner is opened, and now you can see a Cypress folder created in your project folder.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can click on any of the spec file listed in test runner, and see Cypress in action. ( I will include the details of test runner in my next blog article).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Cypress Project Configuration:
&lt;/h3&gt;

&lt;p&gt;These configuration serve as the key aspects to the cypress project.&lt;/p&gt;

&lt;p&gt;There are 3 main configuration files:&lt;/p&gt;

&lt;p&gt;1) &lt;strong&gt;jsconfig.json&lt;/strong&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Not present by default, need to create. &lt;/li&gt;
&lt;li&gt;&lt;p&gt;Therefore the step here is to create a jsconfig.json file under main project folder - 'CypressAutomationProject'.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enter below code &amp;amp; Save the file:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "include": [
      "./node_modules/cypress",
      "cypress/**/*.js"
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2nud26eedovuijm08c4w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2nud26eedovuijm08c4w.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; The definition in this file helps us to populate all cypress commands (methods) to be used in project spec files (i.e. Test Scripts).&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;2) &lt;strong&gt;cypress.json&lt;/strong&gt; &lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Present, nested under cypress folder inside main project folder. (Project Folder &amp;gt; cypress &amp;gt; cypress.json).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We use this file to view default settings or update the default project settings (Closely related to Cypress).&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The settings can be viewed on Cypress Test Runner under Settings tab.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;In cypress.json, the main line of code to be entered is:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   "$schema": "https://on.cypress.io/cypress.schema.json"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbdkmucqb6670qqvwx8b1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbdkmucqb6670qqvwx8b1.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;This acts as an intellisense that populates all cypress settings automatically (After type double quotes you can see the list).&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;p&gt;3) &lt;strong&gt;package.json&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Present, nested under main project folder. (Project Folder &amp;gt; cypress &amp;gt; package.json).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This is related to Node.js, where devDependencies and Scripts can be defined.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We are going to define scripts in this file to run the cypress in Head and Headless mode.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Remove the default test script present and enter below lines lines of code under the scripts object and save the file.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
 "scripts" : {
    "cy:open": "./node_modules/.bin/cypress open",
    "cy:run": "./node_modules/.bin/cypress run"
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmx7kdnr4njbnz49qfr82.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmx7kdnr4njbnz49qfr82.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;To run the scripts in Head mode, run command: &lt;code&gt;npm run cy:open&lt;/code&gt;.&lt;br&gt;
(Note: This actually opens up test runner).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;To run the scripts in Headless mode, run command: &lt;code&gt;npm run cy:run&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;p&gt;Hurray! Your machine is now setup to use Cypress. Enjoy every bit of it, It's really an awesome tool.&lt;br&gt;
Any queries related to cypress, please post them in comments.&lt;/p&gt;

</description>
      <category>node</category>
      <category>cypress</category>
      <category>javascript</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
