<?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 UsamA Azhar on Medium]]></title>
        <description><![CDATA[Stories by UsamA Azhar on Medium]]></description>
        <link>https://medium.com/@osama.azhar963?source=rss-d27eba0fdb59------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*60MiFVHzxWxg7ku3</url>
            <title>Stories by UsamA Azhar on Medium</title>
            <link>https://medium.com/@osama.azhar963?source=rss-d27eba0fdb59------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 26 May 2026 10:08:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@osama.azhar963/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[Cypress REST API Testing]]></title>
            <link>https://medium.com/red-buffer/cypress-rest-api-testing-401f5c06c6e6?source=rss-d27eba0fdb59------2</link>
            <guid isPermaLink="false">https://medium.com/p/401f5c06c6e6</guid>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[api-test-automation]]></category>
            <category><![CDATA[cypress-automation]]></category>
            <category><![CDATA[cypress-testing]]></category>
            <dc:creator><![CDATA[UsamA Azhar]]></dc:creator>
            <pubDate>Thu, 27 Apr 2023 10:09:17 GMT</pubDate>
            <atom:updated>2023-04-27T10:09:17.003Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*NKKKPJ-RRipD--AnfKoUrg.jpeg" /></figure><p>Cypress is a popular JavaScript testing framework that is widely used for automated end-to-end testing of web applications. It comes with a powerful API that allows you to write tests in an expressive and concise manner. In addition to web application testing, Cypress can also be used for REST API testing.</p><p>REST APIs are a popular way to expose data and functionality over the internet. They follow the principles of the Representational State Transfer (REST) architectural style and typically use HTTP methods (GET, POST, PUT, DELETE, etc.) to perform CRUD (Create, Read, Update, Delete) operations on resources.</p><p>If you have ever tested an API via Postman or some other tool, this one will be a piece of cake for you. Cypress is a great testing tool that can be also very helpful when testing API. In this article, I’ll go over some basics on how to write an API test in Cypress.</p><p>You can check out some other articles on my medium, where I provide step-by-step explanations of some Cypress basics with which you can take things to another level. I have written about the following so far:</p><ol><li><a href="https://medium.com/red-buffer/introduction-to-cypress-automation-966ce81e6373">Introduction to Cypress Automation</a></li><li><a href="https://medium.com/red-buffer/cypress-generating-mochawesome-report-42d6436eb6f3">Cypress generating mochawesome report</a></li></ol><p>To get started with Cypress REST API Testing, you will need to install Cypress and set up a new project.</p><pre>npm install cypress --save-dev</pre><p>Once you have Cypress set up, you can start writing tests for your REST API endpoints.</p><h3><strong>.request() Command</strong></h3><p>This command will be the center of it all. To send a simple request with a “GET” method, you can call it like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hrzpe-zDzhB4ghLce82Dpg.png" /></figure><p>You don’t really need to add the method. Cypress optimizes their commands for maximum readability, which is one of the main features of using Cypress. So if you write a request like this, it will automatically be one with a method of “GET”. If you pass two arguments into the .request() command, the first argument will be considered a method and the second will be the URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MiPPKC-qH_FHxtRRCbNo9g.png" /></figure><p>You don’t need to specify the full URL. That is because the <strong>“/public/v2/users/“</strong> will be automatically appended to anything that is defined as “baseUrl” in <strong>“Cypress.config.js”</strong>.</p><p>.request() command can take a maximum of 3 arguments. The third one will be the request body.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*89zJm1ZHT506Fynb9ud52w.png" /></figure><p>This syntax is super useful when you want to send a bunch of requests to your database to quickly set up your data for UI tests.</p><h3>Passing Multiple Attributes to .request() Command</h3><p>If you want to pass some more options or just provide your .request() command with a little more context, you can pass a single object. The same request from the previous example can be written like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GbQ0d44Ttv-k8y2_VvmtwA.png" /></figure><p>This also gives you the ability to pass more options, for example, headers:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kQjDCKLx9dg-XDGxJC_oew.png" /></figure><h3>Getting Data From Request</h3><p>After a request receives a response from the server, you can access the information using .then() command. This will return all kinds of attributes like response body, status code, duration, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sQMDGShaqtJsRCB-8V8bmw.png" /></figure><p>If you want to use data from the response elsewhere in the test, you can use it like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J0WlmRQ-W79kd_1eqQ3suA.png" /></figure><h3>Testing Response Data</h3><p>Now that we have gotten data from our server, we can proceed with testing them. Cypress has a bundled chai library, which you can use inside your .then() command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WCgmd8Ra77FDAjQ5L87mXQ.png" /></figure><p>You can test various attributes of the API response, as the bundled chai library is pretty versatile. For example, you can check whether returned content has the proper type, contains certain items or you can write your own function to check a value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t3mBzGSefrStCx2WWj_V-w.png" /></figure><h3>Using cypress-plugin-api Plugin</h3><p>Cypress will open the browser each time you run a test, which is something to have in mind once you decide to use Cypress for API testing. Also, you need to open the browser console to look into the details of Cypress&#39; response.</p><p>But with the cypress-plugin-api plugin, the request, as well as the response get rendered into a browser window, so you can easily observe your API even in GUI mode. This plugin will add “.api()” command to your Cypress library, and the syntax is very similar to “.request()” command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hEpO8eXti09rfPM2vuM5SQ.png" /></figure><p>This test will then produce this beautiful render in your test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZWoG3pcLUdhX2Fq4St4AJQ.jpeg" /></figure><h3>Conclusion</h3><p>Cypress’ user-friendly interface and intuitive syntax make it easy for developers to write tests and debug any issues that may arise. Additionally, Cypress’ ability to integrate with other testing tools and frameworks makes it a valuable addition to any development workflow.</p><p>For more updates, follow me on <a href="https://medium.com/@osama.azhar963">Medium</a> or <a href="https://www.linkedin.com/in/usama-azhar/">LinkedIn</a>. Hope you liked it :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=401f5c06c6e6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/red-buffer/cypress-rest-api-testing-401f5c06c6e6">Cypress REST API Testing</a> was originally published in <a href="https://medium.com/red-buffer">Red Buffer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cypress — Generating Mochawesome Report]]></title>
            <link>https://medium.com/red-buffer/cypress-generating-mochawesome-report-42d6436eb6f3?source=rss-d27eba0fdb59------2</link>
            <guid isPermaLink="false">https://medium.com/p/42d6436eb6f3</guid>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[qa]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[framework]]></category>
            <dc:creator><![CDATA[UsamA Azhar]]></dc:creator>
            <pubDate>Thu, 22 Sep 2022 10:06:14 GMT</pubDate>
            <atom:updated>2022-09-22T10:12:24.426Z</atom:updated>
            <content:encoded><![CDATA[<h3>Cypress — Generating Mochawesome Report</h3><p>As the popularity of Cypress as a testing framework is increasing nowadays, it is important to reflect the test reports in a clear and accessible way. One might think of it as an HTML report which can be extracted from the test results. This is where mochawesome plays its ‘awesomeness’. You will get a step-by-step guide on how to generate reports with mochawesome for e2e tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FEDiI-TwCLoDngWRcERFbA.jpeg" /></figure><h3>What is Mochawesome?</h3><p>Mochawesome is a customized JavaScript testing reporter for mocha. It runs on Node.js (&gt;=10) and works in conjunction with mochawesome-report-generator to generate standalone HTML/CSS reports to help visualize your test runs.</p><h3>Features</h3><ul><li>Simple, clean, and modern design</li><li>Beautiful charts (via ChartJS)</li><li>Support for test and suite nesting</li><li>Displays before and after hooks</li><li>Review test code inline</li><li>Stack trace for failed tests</li><li>Support for adding context information to tests</li><li>Filters to display only the tests you want</li><li>Responsive and mobile-friendly</li><li>Offline viewing</li><li>Supports parallel mode</li></ul><h3>Installation and Setup Guide</h3><p>Let&#39;s start with the required packages you will need to generate mochawesome reports.</p><h4>Step 1:</h4><p>First, you need to install mochawesome package, which you can do by executing the following command:</p><pre>npm i --save-dev cypress-mochawesome-reporter</pre><h4>Step 2:</h4><p>Now we’ll need to change the cypress reporter &amp; set up hooks. For this, let&#39;s edit the config file (<strong><em>cypress.config.js</em></strong> by default)</p><pre>const { defineConfig } = require(&#39;cypress&#39;);</pre><pre>module.exports = defineConfig({</pre><pre>reporter: &#39;cypress-mochawesome-reporter&#39;,</pre><pre>e2e: {</pre><pre>setupNodeEvents(on, config) {</pre><pre>require(&#39;cypress-mochawesome-reporter/plugin&#39;)(on);</pre><pre>},</pre><pre>},</pre><pre>});</pre><h4>Step 3:</h4><p>Add the following code to your <strong><em>cypress/support/e2e.js</em></strong> file.</p><pre>import &#39;cypress-mochawesome-reporter/register&#39;;</pre><h4>Step 4:</h4><p>In order to run your test script to generate an HTML report, do the following steps.</p><ol><li>Go to your package.json file and add the following under scripts:</li></ol><p>“html-report” : “cypress run — — spec &lt;file-path&gt;.js — — browser chrome — — headed”</p><p>2. Simpy run the following command in your terminal:</p><pre>npm run html-report</pre><p>It will generate an <em>index.html </em>file under “reports/html”. Locate this folder in your directory and open this file.</p><h4>Mochawesome HTML report</h4><p>The HTML report will look something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZDFmanX0D9_1tZ__1edNAQ.jpeg" /></figure><h3>Custom Options</h3><p>If you want to customize your HTML reports with <em>mochawesome-report-generator flags</em>, just add the flags you want to <em>reporterOptions</em>, which are as follows:</p><pre>const { defineConfig } = require(&#39;cypress&#39;);</pre><pre>module.exports = defineConfig({</pre><pre>reporter: &#39;cypress-mochawesome-reporter&#39;,</pre><pre>reporterOptions: {</pre><pre>charts: true,</pre><pre>reportPageTitle: &#39;custom-title&#39;,</pre><pre>embeddedScreenshots: true,</pre><pre>inlineAssets: true,</pre><pre>saveAllAttempts: false,</pre><pre>},</pre><pre>e2e: {</pre><pre>setupNodeEvents(on, config) {</pre><pre>require(&#39;cypress-mochawesome-reporter/plugin&#39;)(on);</pre><pre>},</pre><pre>},</pre><pre>});</pre><h3>Conclusion</h3><p>My goal for this article is to improve your daily workflow. This article presents a way to eliminate the many invaluable hours you’ll probably spend trying to understand your Cypress reports. I hope the information presented helps you achieve this.</p><p>Thank you for taking the time to read this article.</p><p>For more, you can follow me on <a href="https://www.linkedin.com/in/usama-azhar">LinkedIn</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42d6436eb6f3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/red-buffer/cypress-generating-mochawesome-report-42d6436eb6f3">Cypress — Generating Mochawesome Report</a> was originally published in <a href="https://medium.com/red-buffer">Red Buffer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Cypress Automation]]></title>
            <link>https://medium.com/red-buffer/introduction-to-cypress-automation-966ce81e6373?source=rss-d27eba0fdb59------2</link>
            <guid isPermaLink="false">https://medium.com/p/966ce81e6373</guid>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[cypress-testing]]></category>
            <category><![CDATA[web-automation]]></category>
            <category><![CDATA[qa-testing]]></category>
            <category><![CDATA[cypress-automation]]></category>
            <dc:creator><![CDATA[UsamA Azhar]]></dc:creator>
            <pubDate>Thu, 07 Apr 2022 10:32:18 GMT</pubDate>
            <atom:updated>2022-04-07T10:32:18.398Z</atom:updated>
            <content:encoded><![CDATA[<p>A quick and easy overview to upgrade your game of automation testing using cypress.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wAFvudwY9aX_CW093HpLOA.png" /></figure><p>If you are a QA engineer who is tired of testing web applications manually and wish to somehow automate this laborious task, well this is the article that will help you put a bandage on your pain by giving you a skill that you can use to test the flow of any web application within few minutes.</p><p>As a part of the QA job, some level of testing knowledge is commonly required, but what if you can add a special ingredient to your testing recipe that not only can save you time but also make this job an interesting playground for you?</p><p>That special ingredient is called “Cypress.io”. Cypress is an end-to-end testing framework for web test automation. It enables the test automation engineers to write automated web tests in JavaScript. Cypress can be used for all kinds of testing, including end-to-end, integration, and unit tests. Let&#39;s make you familiar with these terms first!</p><h4>What Makes Cypress a unique tool?</h4><p>There are multiple unique factors, which makes Cypress one of the quickly adaptable choices for web automation. A few of them are:</p><p><strong>Time Travel:</strong> Cypress takes snapshots as you turn your tests, which you can view by simply hovering over commands in Command Log to see exactly what is happening in each step<br><strong>Debuggability:</strong> You don’t have to guess why your tests are failing, as cypress gives you readable errors and stack trees, which make debugging lightning fast.<br><strong>Screenshots and Videos:</strong> You can view screenshots that cypress takes automatically on failure. You can also make a video of your entire test suite when running from CLI.<br><strong> Automatic Waiting:</strong> With Cypress, you don&#39;t need to add waits or sleeps in your tests. Cypress automatically waits for the commands and assertions before moving on to the next step. This saves you from asynchronous hell as well.</p><h4><strong>Types of Testing</strong></h4><p>There are many types of testing an application, but I will be going through the three common types that I have witnessed and are often asked about in interviews.</p><p>1. <strong>End-to-End Testing:</strong> A methodology used to test the functionality and performance of an application under a product-like environment and data to replicate the live settings. The main goal is to simulate how a real user uses the application from start to finish.<br>2. <strong>Unit Testing:</strong> A unit is a single component of a software system that is tested during the development phase. The purpose of unit testing is to test the correctness of an isolated component.<br>3. <strong>Integration Testing:</strong> A type of software testing in which the different units, modules, or components of a software application are tested as a combined entity.</p><p>All three above-mentioned types of testing are used to verify if your application is performing as expected. Luckily, All three test types are very easy to create in Cypress. Let&#39;s get you started with Cypress.</p><h4>How to install Cypress?</h4><p>Installing cypress is pretty easy. Simply navigate into the directory of your project and run the following code in your terminal:</p><pre>npm install cypress --save-dev</pre><p>You can find more information about the installation of cypress in its official <a href="https://docs.cypress.io/guides/overview/why-cypress">documentation</a>.</p><p>You can run the following line of code in your terminal if you have installed Cypress using npm.</p><pre>npx cypress open</pre><p>It will open a test runner, with which you can run any test by just clicking on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*o1ujoTibHpfCn2bYMDZ4PA.png" /></figure><h4>Cypress Test Structure</h4><p>Cypress tests are usually written by using hooks (import from Mocha) that gives a structure to the test scripts. These are helpful to set conditions that tell how your code should run. Following are the hooks that cypress use:<br>1. <strong>describe():</strong> it is simply a way to group your tests.<br>2. <strong>before():</strong> runs once before all tests<br>3. <strong>beforeEach():</strong> runs before every test block<br>4. <strong>it():</strong> contains the testing code<br>5. <strong>afterEach():</strong> runs after each test block<br>6. <strong>after():</strong> runs once all tests are executed</p><h4>Writing tests in Cypress</h4><p>Now that you have installed Cypress and opened it, you can start writing your test scripts. <br>A folder is created upon installation with the name “cypress”. Inside this folder, you will find a sub-folder labeled “integration”. You can navigate inside this folder and create a file, e.g “my_first_test.js”. This will be the file that will hold your first test.</p><p>For the first test, I will show you how to visit your web page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*EnAMZ3wvG9E4riHm144Ffg.png" /></figure><p>The test is wrapped inside two functions:<br>1. <strong>describe a ()</strong> function that groups together related tests<br>2. <strong>it()</strong> function which creates an individual test.</p><p>Running this test will open the web page due to cy.visit command, and you can see the result in a separate browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2U2JLeiyVEGEFl4u8Qs71w.png" /></figure><p>There are only two states of a test, either it is passed or failed. Cypress test runner provides ample feedback for each failure that occurs. You will also notice that the test runner keeps track of how many passes and failures occur in your test suite. For Example, see the following image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CufsNQsi0_b-hPuRYTJXpg.png" /></figure><p>For this test, we are testing multiple strings on our webpage. So I used cy.contains(). This command takes an argument of a string and finds that element on the page. If the element is found, the test is passed and if the element is not found, the test fails.</p><p>Since the page does not contain the text “Hello World” our test failed. Cypress highlights the failed tests in the command line and gives a detailed explanation as to why the test failed.</p><h4>Conclusion</h4><p>This is how easy it is to perform a basic web page automation using Cypress. Using this tool, you can automate your testing tasks and perform thorough testing in just a single click.</p><p>Thanks for reading :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=966ce81e6373" width="1" height="1" alt=""><hr><p><a href="https://medium.com/red-buffer/introduction-to-cypress-automation-966ce81e6373">Introduction to Cypress Automation</a> was originally published in <a href="https://medium.com/red-buffer">Red Buffer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>