<?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 Dikshita Shirodkar on Medium]]></title>
        <description><![CDATA[Stories by Dikshita Shirodkar on Medium]]></description>
        <link>https://medium.com/@dikshita-shirodkar?source=rss-1a2f3e9da66b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*9GbkMU5NyOdnJ2Sd</url>
            <title>Stories by Dikshita Shirodkar on Medium</title>
            <link>https://medium.com/@dikshita-shirodkar?source=rss-1a2f3e9da66b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 15:51:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dikshita-shirodkar/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[Automate your e2e accessibility tests using pa11y]]></title>
            <link>https://dikshita-shirodkar.medium.com/automate-your-e2e-accessibility-tests-using-pa11y-e8dd290d7152?source=rss-1a2f3e9da66b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8dd290d7152</guid>
            <category><![CDATA[e2e-testing]]></category>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[pa11y]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[a11y]]></category>
            <dc:creator><![CDATA[Dikshita Shirodkar]]></dc:creator>
            <pubDate>Mon, 21 Nov 2022 07:50:06 GMT</pubDate>
            <atom:updated>2022-11-21T07:54:51.604Z</atom:updated>
            <content:encoded><![CDATA[<p>I’m excited to announce the new <a href="https://www.npmjs.com/package/pa11y-e2e-tests">pa11y-e2e-tests</a> e2e framework, which helps you find accessibility issues of any web app. This enhancement is simple, fast, reliable, and easy to integrate with your existing e2e tests.</p><p>But before we jump into this interesting framework, lets summarise accessibility testing in simple words.</p><h3>What is accessibility testing?</h3><p>Accessibility testing ensures that differently-abled people can access the information displayed on the application as people without disabilities.</p><h3>Why it is essential?</h3><p>Improving the accessibility of your product can attract the usability of any application, including those with low vision, blindness, hearing impairment, cognitive impairment, motor impairments, or situational disabilities.</p><h3>Process of finding a11y issues in any application?</h3><p>There are a set of rules/guidelines which are defined by <a href="https://www.w3.org/WAI/standards-guidelines/wcag/">WCAG</a> (Web Content Accessibility Guidelines), which needs to be followed while developing any web application. Mention rules within the guidelines help design a website that can increase customer engagement despite disabilities.</p><p>Manually understanding and finding accessibility issues within an application can be quite tedious. Hence there are various tools in the market which help resolve this problem.</p><p>This framework is built using <a href="https://pa11y.org/">Pa11y</a> which is a free and open-source tool helping out the development team to build and design accessible web pages.</p><h3>How to use <a href="https://www.npmjs.com/package/pa11y-e2e-tests">pa11y-e2e-tests</a>?</h3><p>This package identifies accessibility issues, which can be integrated with your existing e2e tests.</p><h3>Installation</h3><p>Install the package, using the command:</p><p>npm install pa11y-e2e-tests --save</p><h3>Configure</h3><p>Before getting started with accessibility testing, we need to be mindful of a few things like</p><ol><li>browser - for launching the application in an automated way, so that pa11y identifies the a11y issues</li><li>launch_url: contains the default URL to be launched by the browser</li><li>src_folders: Need to define the folder name which contains tests to be run</li><li>reports_path: Location to be specified for test results to be saved</li><li>reporter: The type of report required, currently supports JSON and HTML</li></ol><p>And many more, Pa11y has lots of options you can use to change the way the browser runs or the way page is loaded (reference <a href="https://github.com/pa11y/pa11y#configuration">link</a> ). Below listed are the default settings that have been passed during the test execution.</p><p>Let’s configure our framework by creating a file with the name pa11y.config.js and add respective information to get started with a11y testing.</p><pre>module.exports = {<br>  launch_url: &quot;&lt;https://www.saucedemo.com&gt;&quot;,<br>  src_folders: &quot;tests&quot;,<br>  reports_path: &quot;reports&quot;,<br>  reporter: [&quot;json&quot;, &quot;html&quot;],<br>  test_settings: {<br>    runners: [<br>      &#39;axe&#39;,<br>      &#39;htmlcs&#39;<br>    ],<br>    standard: &#39;WCAG2A&#39;,<br>    timeout: 120000,<br>    includeNotices: true,<br>    includeWarnings: true<br>  },<br>  puppeteer_settings: {<br>    headless: false,<br>    executablePath: &#39;/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome&#39;<br>  }<br>};</pre><p>Note: puppeteer_settings is passed internally to launch the browser and perform necessary actions on the webpage.</p><h3>Let’s get started</h3><ol><li>Create a first test file under the tests folder, and name the file as test.js</li></ol><pre>module.exports = {<br>  url: `/`,<br>  actions: [<br>    &#39;set field #username to standard_user&#39;,<br>    &#39;set field #password to secret_sauce&#39;,<br>    &#39;click element input[name=login-button]&#39;,<br>    &#39;wait for element div[class=&quot;app_logo&quot;] to be visible&#39;<br>  ]<br>}</pre><p>The above code launches a browser on the URL defined within the config file. It then performs the actions required to log in to the site. Like entering a username, and password on the login page and clicking on the login button.</p><p>These tests will generate a report summarising the total number of accessibility issues existing on the homepage screen (after the login screen).</p><ol><li>Add the command to run the accessibility tests inside your package.json</li></ol><pre>&quot;scripts&quot;: {<br>	&quot;test&quot;: &quot;runAccessibility&quot;<br>}</pre><p>The below command will run all the tests placed under tests folder</p><pre>npm run test</pre><p>You can also run a single file, using the command</p><pre>npm run test --test tests/firstTest.js</pre><p>2. Here you go, reports folder will contain all the test results under it. It would have both JSON and HTML reports</p><p>I hope you find this package useful. Happy reading 🙂</p><p>Resources:</p><ul><li><a href="https://pa11y.org/">Pa11y website</a></li><li><a href="https://www.w3.org/WAI/standards-guidelines/wcag/">WCAG guidelines</a></li><li><a href="https://www.iweb.co.uk/2016/10/inclusive-design-why-our-websites-should-more-accessible/">Why websites should be accessible</a></li><li><a href="https://medium.com/pulsar/which-accessibility-testing-tool-should-you-use-e5990e6ef0a">Another useful blog explaining accessibility testing manually using different tools</a></li></ul><p>Also you can checkout my original blog on <a href="https://dikshitashirodkar.com/accessibilityPa11y/">https://dikshitashirodkar.com/accessibilityPa11y/</a> and more blogs related to automation!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8dd290d7152" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[UI attribute validation with Nightwatch]]></title>
            <link>https://dikshita-shirodkar.medium.com/ui-attribute-validation-with-nightwatch-e86dcb96554b?source=rss-1a2f3e9da66b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e86dcb96554b</guid>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[ui-design]]></category>
            <category><![CDATA[nightwatchjs]]></category>
            <category><![CDATA[node]]></category>
            <category><![CDATA[ui-ux-design]]></category>
            <dc:creator><![CDATA[Dikshita Shirodkar]]></dc:creator>
            <pubDate>Thu, 03 Nov 2022 07:38:10 GMT</pubDate>
            <atom:updated>2022-11-03T07:38:10.885Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, I faced a challenge in one of my project, wherein there were 3 different designs and we had to test these designs on different screen resolutions and browsers.</p><p>Doing this activity manually is quite tedious, when it comes to matching each element attributes on different browsers, resolutions and so on..</p><p>So thought of creating something exciting and useful which can be used prior to the actual development of a website.</p><h3>How did I solve the above problem?</h3><p>So, I have created <a href="https://www.npmjs.com/package/nightwatch-ui-attributes-validator">nightwatch-ui-attributes-validator</a> package which solves the problem of validating the element attributes of any web application. It compares actual attributes of the website against the baselines (expected) attributes provided by the user and highlights the deviations. As a result, it increases the visual coverage of any application. This blog shall focus on how to use the package, in your nightwatch project.</p><p>Step 1: Create a folder, initialise the project and install nightwatch</p><pre>mkdir nightwatch-UI-tests<br>cd nightwatch-UI-tests<br>npm init<br>npm install nightwatch --save</pre><p>Step 2: Install nightwatch-UI-attributes-validator using below command</p><pre>npm install nightwatch-ui-attributes-validator --save</pre><p>Step 3: Define your baseline (expected UI attributes) in the below format.</p><pre>const sideBarElements = {<br>  desktop: [<br>    {<br>      &quot;tag&quot;: &quot;h3&quot;,<br>      &quot;selector&quot;: &quot;//h3[@class=&#39;mt-2 author-bio&#39;]&quot;,<br>      &quot;text&quot;: &quot;Dikshita Shirodkar&quot;,<br>      &quot;attributes&quot;: {<br>        &quot;font-family&quot;: &quot;Raleway&quot;,<br>        &quot;font-weight&quot;: 700,<br>        &quot;color&quot;: &quot;rgba(0, 0, 0, 0.8)&quot;,<br>        &quot;font-size&quot;: &quot;38.4px&quot;,<br>        &quot;line-height&quot;: &quot;42.24px&quot;,<br>        &quot;letter-spacing&quot;: &quot;normal&quot;,<br>        &quot;text-align&quot;: &quot;left&quot;,<br>        &quot;display&quot;: &quot;block&quot;<br>      }<br>    }<br>  ],<br>  mobile: [<br>    {<br>      &quot;tag&quot;: &quot;h4&quot;,<br>      &quot;selector&quot;: &quot;//h4[@class=&#39;mr-4 mt-4&#39;]&quot;,<br>      &quot;text&quot;: &quot;Dikshita Shirodkar&quot;,<br>      &quot;attributes&quot;: {<br>        &quot;font-family&quot;: &quot;Raleway&quot;,<br>        &quot;font-weight&quot;: 700,<br>        &quot;color&quot;: &quot;rgba(0, 0, 0, 0.8)&quot;,<br>        &quot;font-size&quot;: &quot;16px&quot;,<br>        &quot;line-height&quot;: &quot;17.6px&quot;,<br>        &quot;letter-spacing&quot;: &quot;normal&quot;,<br>        &quot;text-align&quot;: &quot;left&quot;,<br>        &quot;display&quot;: &quot;block&quot;<br>      }<br>    }<br>  ]<br>};</pre><pre>module.exports = { sideBarElements };</pre><p><strong><em>Explanation around the above baseline file:</em></strong></p><p>We have 2 environments, where we need to run our UI tests:</p><ol><li>Desktop (1920 screen resolutions)</li><li>Mobile (414 screen resolution)</li></ol><p>However we can have multiple environment, depending on the need. Respective UI attributes for each element should be defined in the format as defined. These are HTML element attributes and can vary depending on the design for respective resolutions (environments)</p><ul><li>The baseline file can be supports js or json format</li><li>We can have multiple baseline files, and should be place under baseline directory (mine are under baseline folder)</li></ul><p>That’s pretty cool, we have defined our baselines or in simple words our expected outputs.</p><p>Step 4: Let’s create, nightwatch.conf.js, where you specify test_settings required in the project, along with some custom configurations required for this package</p><pre>const chrome = require(&#39;selenium-webdriver/chrome&#39;);<br>const capabilities = new chrome.Options();<br>capabilities.addArguments(&#39;--ignore-certificate-errors&#39;);<br>capabilities.headless();</pre><pre>module.exports = {<br>  custom_commands_path : &quot;./node_modules/nightwatch-ui-attributes-validator/commands&quot;,<br>  custom_assertions_path : &quot;./node_modules/nightwatch-ui-attributes-validator/assertions&quot;,<br>  skip_testcases_on_fail: false,<br>  disable_error_log: true,</pre><pre>  screenshots: {<br>    enabled: false,<br>    path: &#39;screens&#39;,<br>    on_failure: true<br>  },</pre><pre>  test_workers: {<br>    enabled: true,<br>  },</pre><pre>  globals: {<br>    baselineDirPath : &quot;./baselines&quot;,<br>  },<br>  <br>  test_settings: {<br>    desktop: {<br>      log_path: false,<br>      capabilities,<br>      src_folders: [&quot;./desktopTests&quot;],<br>      window_size: {width: 1920, height:1080},<br>      output_folder: &#39;reports/desktop_reports&#39;,<br>      webdriver: {<br>        start_process: true,<br>        port: 4444,<br>        server_path: require(&#39;chromedriver&#39;).path,<br>      },<br>      desiredCapabilities: {<br>        browserName : &#39;chrome&#39;,<br>        chromeOptions: {<br>          cli_args: []<br>        }<br>      },<br>    },<br>    mobile: {<br>      capabilities,<br>      window_size: {width: 414, height:896},<br>      output_folder: &#39;reports/mobile_reports&#39;,<br>      src_folders: [&quot;./mobileTests&quot;],<br>      webdriver: {<br>        start_process: true,<br>        server_path: require(&#39;chromedriver&#39;).path,<br>      },<br>      desiredCapabilities: {<br>        browserName: &#39;chrome&#39;,<br>        chromeOptions: {<br>          cli_args: []<br>        }<br>      },<br>    },<br>  }<br>};</pre><p><strong><em>Explanation around </em></strong><strong><em>nightwatch.conf.js:</em></strong></p><ul><li>This tells nightwatch to include the commands require for validation</li></ul><pre>custom_commands_path: [&#39;./node_modules/nightwatch-ui-atrributes-validator/commands&#39;]</pre><ul><li>This tells nightwatch to include the assertions require for asserting the elements attributes`</li></ul><pre>custom_commands_path: [&#39;./node_modules/nightwatch-ui-atrributes-validator/commands&#39;]</pre><ul><li>Remember, we stored all our baseline files under baseline directory, here we specified the directory name. (<strong><em>This is required to be mentioned</em></strong>)</li></ul><pre>globals: { baselineDirPath : &quot;./baseline&quot; }</pre><p><strong><em>Note:</em></strong> We have defined test settings for desktop, mobile and respectively defined their UI attributes within baseline. Like mentioned, you can add as many test environments, as required.</p><h3>How do we add the UI validation within your tests?</h3><p><strong><em>Note</em></strong>: It is always better to manage your tests for different platforms in seperate folders.</p><ul><li>Step 1: Create src folder with name desktopTests and add your UI tests for desktop under this folder. One such example of UI tests is the below file</li></ul><pre>const { sideBarElements } = require(&#39;../baselines/homepageElement&#39;);</pre><pre>describe(&#39;Verify the UI attributes of the side bar component on both desktop and mobile&#39;, function() {<br>  it(&#39;Validate the side base for desktop screen&#39;, function(browser) {<br>    browser<br>    .url(https://medium.com/&#39;https://dikshitashirodkar.com/&#39;)<br>    .assert.titleMatches(&#39;Home | QA Talking point&#39;)<br>    .assert.validateBaseline(sideBarElements.desktop)<br>    .end();<br>  });<br>});</pre><p><strong><em>Explanation of the above UI tests</em></strong></p><ul><li>assert.validateBaseline is the command used for validation the UI attributes.</li><li>It accepts parameter having name of the object having the UI attributes to be passed.</li></ul><h3>How do we run it?</h3><p>In order run the UI tests, we simply use the below command:</p><ul><li>For desktop tests:</li></ul><p>npx nightwatch --env desktop --reporter=html</p><pre>nightwatch-UI-tests npx nightwatch --env desktop --reporter=html</pre><pre>&gt; nightwatch-UI-tests@1.0.0 test-desktop /Users/dikshitashirodkar/Work/nightwatch-UI-tests<br>&gt; npx nightwatch --env desktop --reporter=html</pre><pre>[Verify the UI attributes of the side bar component on both desktop and mobile] Test Suite<br>───────────────────────────────────────────────────────────────────────────────<br>ℹ Connected to ChromeDriver on port undefined (942ms).<br>  Using: chrome (106.0.5249.61) on MAC OS X.</pre><pre>  Running Validate the side base for desktop screen:<br>───────────────────────────────────────────────────────────────────────────────<br>  ℹ Loaded url https://dikshitashirodkar.com/ in 6945ms<br>  ✔ Testing if the page title matches &#39;Home | QA Talking point&#39; (34ms)<br>  ✔ Testing if element &#39;Dikshita Shirodkar&#39; attributes are matching<br>  ✔ Passed [equal]: Matching font-family to be Raleway<br>  ✔ Passed [equal]: Matching font-weight to be 700<br>  ✔ Passed [equal]: Matching color to be rgba(0, 0, 0, 0.8)<br>  ✔ Passed [equal]: Matching font-size to be 38.4px<br>  ✔ Passed [equal]: Matching line-height to be 42.24px<br>  ✔ Passed [equal]: Matching letter-spacing to be normal<br>  ✔ Passed [equal]: Matching text-align to be left<br>  ✔ Passed [equal]: Matching display to be block</pre><pre>  ✔ Testing if the baseline attributes are matching the actual page attributes</pre><pre>OK. 11 assertions passed. (7.12s)<br> Wrote HTML report file to: /Users/dikshitashirodkar/Work/nightwatch-UI-tests/reports/desktop_reports/nightwatch-html-report/index.html</pre><ul><li>For mobile tests:</li></ul><p>npx nightwatch --env mobile --reporter=html</p><h3>Reporting</h3><p>Reports would be generated in respective folder defined in the config file, seperately for both desktop and mobile</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*bG2lgIsbw_Pfx-Vn.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e86dcb96554b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Structure Nightwatch.js and perform execution within Docker]]></title>
            <link>https://dikshita-shirodkar.medium.com/structure-nightwatch-js-and-perform-execution-within-docker-680c43643a69?source=rss-1a2f3e9da66b------2</link>
            <guid isPermaLink="false">https://medium.com/p/680c43643a69</guid>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[ubuntu-20-04]]></category>
            <category><![CDATA[nightwatchjs]]></category>
            <dc:creator><![CDATA[Dikshita Shirodkar]]></dc:creator>
            <pubDate>Thu, 26 Aug 2021 05:52:34 GMT</pubDate>
            <atom:updated>2021-08-26T05:53:51.965Z</atom:updated>
            <content:encoded><![CDATA[<p>My last post talked about <a href="https://dikshita-shirodkar.medium.com/shipping-docker-learn-to-build-docker-image-for-ubuntu-20-04-fe9b082fd3f4">How to build Docker Image for Ubuntu 20.04</a>. Now it’s time to dive into structuring Night watch.js and executing the tests within Docker container.</p><h3>Introduction to Nightwatch.js?</h3><p>Nightwatch.js is a popular framework which can be integrated and easy to use E2E testing solution for web applications and websites, which uses javascript and W3C webdriver API.</p><h3>Why Nightwatch.js?</h3><p>Nightwatch offers different advantages out of various tools available in the market, like:</p><ol><li>NightwatchJS API’s are much faster than any automation tool</li><li>Built-in test runners</li><li>Continuous integration</li><li>Easy to extend, allows you to write my own custom commands and assertions</li><li>Chain of commands</li><li>Light weight</li><li>Nightwatch JS is built on Node.js, it has some major advantages over any other Selenium automation testing tool</li></ol><h3>Installation of Nightwatch.js</h3><p><strong>Note</strong>: Before we start installing the Nightwatch.js related packages, make sure we install the npm tool, which is the node package manager.</p><p>Step 1. Initialize the project, by running command:</p><pre>npm init</pre><p>Step 2. Install nightwatch</p><pre>npm install nightwatch --save -dev</pre><p>Nightwatch.js offers an in-built test runner which expects a JSON configuration file to be passed. The default configuration file is nightwatch.json which needs to be present in the root directory.</p><p>Also, add a new script to your package.json, to run your e2e test:</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;test&quot;: &quot;nightwatch&quot;<br>  }<br>}</pre><p>Step 3. Install chromediver</p><pre>npm install i chromedriver --save -dev</pre><p>Step 4. Now, lets update nightwatch.conf.js file in the root structure to:</p><pre>module.exports = {<br>  src_folders: [&quot;tests&quot;],<br>  page_objects_path: [&quot;page-objects&quot;],<br><br>  webdriver: {<br>    start_process: true,<br>    server_path: &quot;node_modules/.bin/chromedriver&quot;,<br>    port: 9515,<br>  },<br><br>  // Will take screenshots on any test failures<br>  test_settings: {<br>    default: {<br>      screenshots: {<br>        enabled: true,<br>        path: &quot;tests_output/screenshots&quot;,<br>        on_failure: true,<br>      },<br><br>      desiredCapabilities: {<br>        browserName: &quot;chrome&quot;,<br>      },<br>    },<br>  },<br>}</pre><p><strong>Note:</strong> For more details w.r.t nightwatch.conf.js you can refer to this <a href="https://nightwatchjs.org/gettingstarted/configuration/#nightwatch-json">link</a>. for adding additional configurations.</p><p>As you see above, we have defined couple of configuration within nightwatch.conf.js. Let&#39;s create the folders structure respective to the configuration in the root</p><pre>test-NightwatchJS<br>│<br>└───page-objects<br>│   │   gitPage.js<br>│   │<br>└───tests<br>│   │  git.js<br>│<br>└───tests_output<br>│   │<br>│   └───screenshots<br>│       │   img1.png</pre><h3>Let’s write our first test using Nightwatch.js</h3><ol><li>Add below code inside gitPage.js</li></ol><pre>const { browser } = require(&quot;nightwatch&quot;)<br><br>module.exports = {<br>  elements: {<br>    email: &quot;#user_email&quot;,<br>    heading: {<br>      selector:<br>        &#39;//h1[@class=&quot;h1-mktg color-text-white mb-3 position-relative z-2&quot;]&#39;,<br>      locateStrategy: &quot;xpath&quot;,<br>    },<br>  },<br>  commands: [<br>    {<br>      openUrl() {<br>        return this.api.url(https://medium.com/&quot;https://github.com/&quot;)<br>      },<br>      setEmail(email) {<br>        return this.assert<br>          .visible(&quot;@email&quot;, &quot;Email field is displayed&quot;)<br>          .click(&quot;@email&quot;)<br>          .setValue(&quot;@email&quot;, email)<br>      },<br>      verifyHeading(expectedText) {<br>        return this.assert<br>          .visible(&quot;@heading&quot;, &quot;heading is displayed&quot;)<br>          .getText(&quot;@heading&quot;, function(result) {<br>            this.assert.equal(result.value, expectedText)<br>          })<br>      },<br>    },<br>  ],<br>}</pre><p>This is basically is a simple test to open the url and enter the email in the email Box and finally match the heading of the page using assertions.</p><p>2. Add below tests within gitLogin.js</p><pre>const { browser } = require(&quot;nightwatch&quot;)<br><br>module.exports = {<br>  &quot;First test execution&quot;: function(browser) {<br>    const git = browser.page.gitPage()<br><br>    git<br>      .openUrl()<br>      .page.gitPage()<br>      .setEmail(&quot;hello&quot;)<br>  },<br><br>  &quot;Second test execution&quot;: function(browser) {<br>    const git = browser.page.gitPage()<br><br>    git.verifyHeading(&quot;Where the world builds software&quot;)<br>  },<br>}</pre><p>Here, we are calling the functions defined in the gitPage.js and passing the necessary arguments.</p><p>3. Finally, execute the test:</p><pre>npm run nightwatch<br><br>$  test-NightwatchJS npm test<br><br>&gt; test-nightwatchjs@1.0.0 test /Users/WORK/test-NightwatchJS<br>&gt; nightwatch<br><br><br>[Git Test] Test Suite<br>=====================<br>ℹ Connected to localhost on port 9515 (2048ms).<br>  Using: chrome (91.0.4472.114) on Mac OS X platform.<br><br>✔ Running First test execution:<br><br>✔ Email field is displayed (64ms)<br><br>OK. 1 assertions passed. (3.524s)<br>✔ Running Second test execution:<br><br>✔ heading is displayed (24ms)<br>✔ Passed [equal]: Where the world builds software == Where the world builds software<br><br>OK. 2 assertions passed. (59ms)<br><br>OK. 3  total assertions passed (6.176s)</pre><p>Voila 😎, you just execute your first e2e test using Nightwatch.js</p><h3>Why tests?</h3><p>There should be some gap between development and production for testing, so that we avoid surprises like issues during a deployment which can be due to rushy fix pushed, dropping the quality for the end users. Another main reason to run tests is because it imitates the actual user’s behavior using the site.</p><h3>Why Execute within Docker?</h3><p>We have a main challenge to maintain and test the stability of our test. Hence we require a environment close to production. Since we develop the automatons scripts on our machine, but the end goal is to run the scripts on the production environment whose configuration could be different from yours. This is when we see error occurring in our test scripts, so to avoid and eliminate such last minute surprises, which can take ample amount of time, we need a environment with similar configuration like Prod.</p><p>That’s where Docker comes into picture, solving all the problems. Docker creates a isolated world (containerized) with all the external configurations, required to build the environment.</p><h3>Setting up Docker with Nightwatch.js</h3><p>As we learnt in the <a href="https://dikshita-shirodkar.medium.com/shipping-docker-learn-to-build-docker-image-for-ubuntu-20-04-fe9b082fd3f4">previous article</a> to create and access a container (<strong>Ubuntu 20.04 machine</strong>) using docker.compose.yaml. We will following the same steps to access that existing container.</p><p>Now install the dependencies required for NightwatchJS setup in the container. I have tried to minimize the human effort by adding all the require dependencies in a shell file, executing this shell file, will automatically install all the dependecies within that container.</p><p>Note: This file also includes instruction to install application level dependencies: such as navigating to the Nightwatch directory, installing the packages of Nightwatch and running of the e2e tests.</p><pre>#!/bin/bash<br><br>## Installing environment level dependencies<br>apt update<br>DEBIAN_FRONTEND=noninteractive apt install npm -y<br>apt install curl<br>curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash<br>export NVM_DIR=&quot;$HOME/.nvm&quot;<br>[ -s &quot;$NVM_DIR/nvm.sh&quot; ] &amp;&amp; \. &quot;$NVM_DIR/nvm.sh&quot;<br>nvm install v14.17.0<br>nvm use v14.17.0<br>apt install vim<br>apt install wget -y<br>wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -P /tmp<br>apt install /tmp/google-chrome-stable_current_amd64.deb<br><br>## Installing application level dependencies<br>cd /root/test-NightwatchJS # Navigate to the nightwatch folder structure<br>npm install # Install nightwatch related dependencies<br>npm run test # Run the nightwatch tests<br>/bin/bash</pre><p>Thanks for reading! 🙂</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=680c43643a69" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shipping Docker]]></title>
            <link>https://medium.com/theleanprogrammer/shipping-docker-learn-to-build-docker-image-for-ubuntu-20-04-fe9b082fd3f4?source=rss-1a2f3e9da66b------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe9b082fd3f4</guid>
            <category><![CDATA[ubuntu-20-04]]></category>
            <category><![CDATA[docker-image]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Dikshita Shirodkar]]></dc:creator>
            <pubDate>Wed, 25 Aug 2021 05:54:01 GMT</pubDate>
            <atom:updated>2021-09-04T15:09:51.397Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building Docker Image for Ubuntu 20.04</h4><p>In this article, you’ll learn how to build a Ubuntu 20.04 image. But before starting to build the image, let’s quickly have a brief about docker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Oq4QgtMk-n5Q0mtKLwyHA.png" /></figure><h3>Why Docker??</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*vmOWsdwCCbLnhamS.jpg" /><figcaption>Docker</figcaption></figure><p>Docker helps you to build, ship and run your app, anywhere. It helps you to pack all your libraries, binaries, OS, and application-related services readily available to build your app. Hence termed as containerized technology easy for people to use.</p><p>Docker is like a virtual machine but unlike a virtual machine. Instead of creating a whole virtual operating system, this application allows you to use the same kernel as the system the docker is running on. What is a Docker image?</p><h3>What is a Docker image?</h3><p>Images are files used to execute a set of code within a docker container. They contain a set of commands to build a docker container. An image can be compared as a snapshot of a virtual machine. The image itself contains commands needed to build a container using the libraries, dependencies, tools, environment files, configs in order to run the application within a container. Containers are dependent on images because the images act as a starting point, which helps to build a container (runtime environment).</p><p>Here’s is a list of docker commands</p><ul><li>docker-compose up -d - Builds, (re)creates, starts, and attaches to containers for a service.</li><li>docker ps - list the containers</li><li>Docker images :- lists all the images</li><li>docker run - Runs a command in a new container.</li><li>docker start - Starts one or more stopped containers.</li><li>docker stop - Stops one or more running containers.</li><li>docker build - Builds the image from the Docker file.</li><li>docker pull - Pulls an image or repository from a registry.</li><li>docker push - Pushes and image or repository to a registry.</li><li>docker exec - Runs a command in a run-time container.</li><li>docker search - Searches the Docker Hub for images.</li><li>docker commit - Create a new image from a container’s changes.</li></ul><p>To know the full list of commands, do refer to the <a href="https://docs.docker.com/engine/reference/commandline/docker/">Docker documentation</a></p><h4>Installing Docker</h4><p>Before we start, we need to have Docker installed, whether it’s on your local machine or a remote server. Refer to the <a href="https://docs.docker.com/get-docker/">official site</a> to install and set up Docker on your machine.</p><p>Once you install the Docker, you will be able to view &amp; access the GUI interface, which would look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*3t5JqPAO49ZhcD4b.png" /><figcaption>Docker GUI</figcaption></figure><h4>Pull a Docker image of Ubuntu machine with version 20.04</h4><p>1. In order to use Ubuntu 20.04, we need to pull the image from the docker hub. Docker Hub is a hosted repository service provided by Docker for finding and sharing container images with anyone over the internet. For more information refer to this <a href="https://www.docker.com/products/docker-hub">site</a>.</p><p>To pull the image, run the below command:</p><pre>$ docker pull ubuntu:20.04</pre><p>This will pull the Ubuntu image and will be able to see it in the listing screen within the Docker GUI interface. Also, you can verify the pull, via the CLI command</p><pre>$ docker image ls -a</pre><pre>REPOSITORY                       TAG       IMAGE ID       CREATED        SIZE<br>ubuntu                           20.04     7e0aa2d69a15   2 months ago   72.7MB</pre><p>2. Let’s run the Ubuntu 20.04 image using the command:</p><pre>$ docker run -it --entrypoint &quot;/bin/bash&quot; ubuntu:20.04</pre><p>This will build and run a container for Ubuntu 20.04 image. Also, we have attached an entry point, that will launch a bash shell.</p><h4><strong>Build a Ubuntu 20.04 container using a docker-compose</strong></h4><p>Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.</p><p>Here we will build the Ubuntu 20.04 container using docker-compose.</p><ol><li>Create docker-compose.yaml file and add necessary configurations to pull and build the container. The file looks like this:</li></ol><pre>version: &#39;3.9&#39; # optional since v1.27.0<br>services:<br>  ubuntu:<br>    image: ubuntu:20.04<br>    tty: true</pre><p>2. List the Docker containers using the command:</p><pre>$ docker ps -a<br>CONTAINER ID   IMAGE          COMMAND       CREATED          STATUS                        PORTS     NAMES<br>e547b463ed0e   ubuntu:20.04   &quot;/bin/bash&quot;   4 weeks ago      Exited (0) 34 minutes ago               testProject_ubuntu_1</pre><p>3. Run and build the docker-compose.yaml</p><pre>$ docker-compose up -d<br>Docker Compose is now in the Docker CLI, try `docker compose up`</pre><pre>Starting testProject_ubuntu_1 ... done</pre><p>4. Now you can access the container, simply by executing:</p><pre>$ docker exec -i -t testProject_ubuntu_1 /bin/bash<br>root@e547b463ed0e:/#</pre><p>There you go, we have created a Docker container of Ubuntu 20.04. That’s all 😄</p><p>Don’t forget to follow The Lean Programmer Publication for more such articles, and subscribe to our newsletter <a href="http://tinyletter.com/TheLeanProgrammer">tinyletter.com/TheLeanProgrammer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe9b082fd3f4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/theleanprogrammer/shipping-docker-learn-to-build-docker-image-for-ubuntu-20-04-fe9b082fd3f4">Shipping Docker</a> was originally published in <a href="https://medium.com/theleanprogrammer">TheLeanProgrammer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Power your Cypress tests with CircleCI]]></title>
            <link>https://medium.com/geekculture/power-your-cypress-tests-with-circleci-88e94507d25a?source=rss-1a2f3e9da66b------2</link>
            <guid isPermaLink="false">https://medium.com/p/88e94507d25a</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[circleci]]></category>
            <category><![CDATA[node]]></category>
            <dc:creator><![CDATA[Dikshita Shirodkar]]></dc:creator>
            <pubDate>Mon, 23 Aug 2021 12:15:23 GMT</pubDate>
            <atom:updated>2021-08-25T07:30:17.881Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog, will make you understand how to implement your e2e tests using Cypress and do continuous integration and delivery with CircleCI for your tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hejhTWmH8jqMscCJE6X-CA.png" /><figcaption>cypress+circleci</figcaption></figure><h3>About Cypress</h3><p>Cypress is a next generation front end testing tool, built for modern web app’s. Cypress comes fully baked with features like:<br> <br> — Time travel <br> <br> — Debuggability<br> <br> — Automatic waiting <br> <br> — Screenshots and Videos <br> <br> — Cross browser Testing</p><p>And lots more…</p><p>Cypress is architecturally different. Unlike most tools, it operates within the same run loop of your application. It synchronizes with a Node process and manages the communication, synchronization and performs task on behalf of each other.</p><h3>Project Setup</h3><p>Let’s start setting up a basic Cypress project <br> <br> — Create a folder with name cypress-circleci and initialize your node project</p><pre>$ mkdir cypress-circleci<br>$ npm init</pre><p>- Install cypress with command</p><pre>npm install cypress --save</pre><p>- Open the cypress from your project</p><pre>npx cypress open</pre><p>- Folder structure would look something like these</p><blockquote>circleci-cypress<br>│<br>└───fixtures<br>│ │ sampleData.json<br>│ │<br>└───integration<br>│ │ siteVerify.js<br>│<br>└───plugins<br>│ │ index.js<br>│<br>└───screenshots<br>│ │ img1.pmg<br>│<br>└───results<br>│ │ test<br>│<br>└───supports<br>│ │ commands.js<br>│ │ index.js<br>|<br>└───cypress.json<br>└───package.json</blockquote><p>- Create a basic test to verify the site “<a href="https://dikshitashirodkar.com"/">https://dikshitashirodkar.com&quot;</a>. And you can configure the base url of your site inside cypress.json</p><pre>{<br>  &quot;baseUrl&quot;: &quot;https://dikshitashirodkar.com/&quot;,<br>  &quot;video&quot;: false,<br>  &quot;reporterOptions&quot;: {<br>    &quot;mochaFile&quot;: &quot;cypress/results/tests-[hash].xml&quot;,<br>    &quot;toConsole&quot;: true<br>  }<br>}</pre><p><strong>Note</strong>: By default, cypress provides a video recording of the executed tests, here we have explictily turned it off using the video flag. And added configurations for an xml report.</p><p>The below test file uses fixtures (used to store and manage test data, which is nothing but a json file). <br> A simple fixture file with name sample.json</p><pre>{<br>  &quot;imageName&quot;: &quot;dikshita&quot;,<br>  &quot;heading&quot;: &quot;QA Talking point&quot;<br>}</pre><p>Here’s basic test integration/test.js. The test contains:<br> <br> 1. Visit the site<br> <br> 2. Verify the response status of the site to be 200<br> <br> 3. Verify the heading of the blog to be &quot;QA Talking point&quot;<br> <br> 4. Verify the image icon of the blog to be &quot;dikshita&quot;</p><pre>describe(&quot;Verify the website&quot;, function() {<br>  before(function() {<br>    cy.visit(&quot;/&quot;)<br>  })</pre><pre>  beforeEach(function() {<br>    cy.fixture(&quot;sample&quot;).then(function(sample) {<br>      this.sample = sample<br>    })<br>  })</pre><pre>  it(&quot;verify the status of the site&quot;, function() {<br>    cy.request(&quot;/about&quot;).should(function(response) {<br>      expect(response.status).to.eq(200)<br>    })<br>  })</pre><pre>  it(&quot;verify the heading of the blog&quot;, function() {<br>    cy.get(&quot;.head-logo&quot;)<br>      .children(&quot;a&quot;)<br>      .should(&quot;have.text&quot;, this.sample.heading)<br>  })</pre><pre>  it(&quot;verfiy the image icon on the site&quot;, function() {<br>    console.log(this.sample, &quot;printing data&quot;)<br>    cy.get(&quot;.profile-img&quot;)<br>      .should(&quot;have.attr&quot;, &quot;src&quot;)<br>      .and(&quot;include&quot;, this.sample.imageName)<br>  })<br>})</pre><p>Let’s execute the tests using command:</p><pre>npm run cypress run --browser chrome</pre><p>The output of the result would something like:</p><pre>Spec                                              Tests  Passing  Failing  Pending  Skipped<br>  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐<br>  │ ✔  tests/verifySite.js                      00:08        3        3        -        -        - │<br>  └────────────────────────────────────────────────────────────────────────────────────────────────┘<br>    ✔  All specs passed!                        00:08        3        3        -        -        -</pre><p>There you go, you have successfully configured and executed…🏅</p><h3>Run cypress with CircleCI</h3><p>CircleCI is a continuous integration and deployment tool, which helps teams to integrate their code within the repository and build the tests, “n” no of times in a day. CircleCI uses Orbs which are open-source, shareable packages of parameterizable resuable configuration elements, with includes jobs, commands and executors. <br> CircleCI also provides Orb for cypress to test without spending time configuring CircleCI. It also records results &amp; provides a GUI.</p><h3>Let’s jump to configure CircleCI</h3><p>- Create a folder .circleci in the root directory of your project<br> - Add a file within the .circleci folder as config.yml</p><pre>version: 2.1<br>orbs:<br>  cypress: cypress-io/cypress@1<br>executors:<br>  with-chrome:<br>    resource_class: small<br>    docker:<br>      - image: &quot;cypress/browsers:node14.16.0-chrome90-ff88&quot;<br>workflows:<br>  build:<br>    jobs:<br>      - cypress/install<br>      - cypress/run:<br>          requires:<br>            - cypress/install<br>          executor: with-chrome<br>          browser: chrome<br>          post-steps:<br>            - run: ls<br>            - store_test_results:<br>                path: cypress/results<br>            - store_artifacts:<br>                path: cypress/screenshots</pre><p><strong>Note</strong>: Place your cypress project into a version controlled system (github or bitbucket). In our case we would place it on github.</p><h3>Setup your CircleCI account</h3><p>1. You can login to CircleCI portal via gitHub and you’ll have access to all your github repositories within the Project listing screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*fp6WLZoPKNHPb5FC.png" /></figure><p>2. In order to setup circleci for your git hub project, select Setup project. This will then ask you to choose the branch from which you want to execute your tests and it should contain the config.yml inside .circleci folder. Or another option would be to create a new config file.</p><p><strong>Note</strong>: <br> For this blog post, we are triggering the pipeline manually. But you can definitely, automate the pipeline trigger process.</p><p>3. As you setup the project, the pipeline would be triggered automatically and the build progress can be seen</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*TkqRJEbMHTR2nOet.png" /><figcaption>Build progess</figcaption></figure><p>4. Success of the pipeline would look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*XYZZg_npLBOg3aa_.png" /><figcaption>Sucess status</figcaption></figure><p>5. The failed pipeline would look like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*MREG_KnBNo0rZatM.png" /><figcaption>Failure status</figcaption></figure><p>6. We have added the configuration to store both test results &amp; the artifacts in our config.yml file. Hence we would also be able to see the details of the test failing, within the test section and screenshot link of the test in the artifact section</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*cnPjbRx1zyl2GYt3.png" /><figcaption>Tests failed</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*59UaLOc2NWO4V3p6.png" /><figcaption>Artifacts</figcaption></figure><p>That’s all for this blog. Hope you have enjoyed it. Thanks for reading…!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=88e94507d25a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/power-your-cypress-tests-with-circleci-88e94507d25a">Power your Cypress tests with CircleCI</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Detox: End-to-End Testing library]]></title>
            <link>https://medium.com/theleanprogrammer/setup-detox-with-react-native-and-appcenter-da8c3c498452?source=rss-1a2f3e9da66b------2</link>
            <guid isPermaLink="false">https://medium.com/p/da8c3c498452</guid>
            <category><![CDATA[appcenter]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[detox]]></category>
            <dc:creator><![CDATA[Dikshita Shirodkar]]></dc:creator>
            <pubDate>Wed, 14 Jul 2021 05:42:35 GMT</pubDate>
            <atom:updated>2021-09-04T15:08:06.467Z</atom:updated>
            <content:encoded><![CDATA[<h4>Setting up Detox using React Native and AppCenter</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zgHB4_cenftQju3Q7Ub-HA.png" /></figure><h3>Mobile automation baked into the entire pipeline from start to finish using Detox — React Native &amp; App Center</h3><p>Having the right test automation is the key to the success of any Product. Testing your application from the perspective of an end-user automatically, ensuring the quality of code, along with delivering it, on the right medium available.</p><p>There are various tools when it comes to web automation like Cypress, WebdriverIO, and many others. But when it comes to mobile, automation is not that common. The reason for writing an article on mobile automation is to explain how to achieve and implement end-to-end testing of mobile using Detox and integration with CI/CD pipeline like AppCenter for distribution.</p><h3>Why Detox?</h3><p>Detox an End to End testing library for applications that are developed using React Native and for pure native applications. It allows mobile tests to be performed by running a real device/simulator and showcasing the interaction like a real User. Less flaky Cross-Platform, supports both android and IOS Debuggable Made for CI</p><p><strong><em>Note: Let&#39;s focus on iOS, otherwise the length of the article will become too long.</em></strong></p><p>The following React Native versions have been tested: iOS Android &lt;=0.62 &lt;=0.56 — Full support</p><blockquote><em>=0.57 &lt;=0.62 — Visibility edge-case: see this RN issue*</em></blockquote><h3>Let’s get Started</h3><h4>Prerequisites:</h4><p>- Mac with macOS</p><p>- Xcode</p><h4>Create a sample react-native application</h4><p>1. Install react-native</p><pre>$ npm install react-native -g</pre><p>2. Setup react-native via command line</p><pre>$ npx react-native init &lt;project_Name&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*JTOxFT9R9wen_Wb0.jpg" /><figcaption>React Native</figcaption></figure><p>3. Launch the app by navigating within your project</p><pre>$ react-native run-ios</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*4sVoS1VS14E52kiS.jpg" /></figure><p>4. Install the latest version of Home Brew</p><pre>$ brew tap wix/brew</pre><p>5. Install the latest version of apple-simutils</p><pre>$ brew install applesimutils</pre><p>6. Install Detox command-line tool</p><pre>$ npm install -g detox-cli</pre><p>7. Add Detox as a dev dependency for the project</p><pre>$ yarn add detox -D</pre><h4>Add Detox configuration</h4><p>Let&#39;s add detox configuration to your project. Always try keeping the detox configuration separate in your package.json file. I have added 2 configurations, one in case of debug mode to run it locally and one in release mode while trying to integrate it with a CI/CD pipeline.</p><pre>&quot;detox&quot;: {<br>    &quot;configurations&quot;: {<br>      &quot;ios.sim.debug&quot;: {<br>        &quot;binaryPath&quot;: &quot;ios/build/Build/Products/Debug-iphonesimulator/DetoxTest.app&quot;,<br>        &quot;build&quot;: &quot;xcodebuild -workspace ios/DetoxTest.xcworkspace -scheme Staging -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build&quot;,<br>        &quot;type&quot;: &quot;ios.simulator&quot;,<br>        &quot;device&quot;: {<br>          &quot;type&quot;: &quot;iPhone 11 Pro&quot;<br>        }<br>      },<br>      &quot;ios.sim.release&quot;: {<br>        &quot;binaryPath&quot;: &quot;ios/build/Build/Products/Release-iphonesimulator/DetoxTest.app&quot;,<br>        &quot;build&quot;: &quot;export RCT_NO_LAUNCH_PACKAGER=true &amp;&amp; xcodebuild -workspace ios/DetoxTest.xcworkspace -scheme Staging -configuration Release -sdk iphonesimulator -derivedDataPath ios/build -quiet&quot;,<br>        &quot;type&quot;: &quot;ios.simulator&quot;,<br>        &quot;device&quot;: {<br>          &quot;type&quot;: &quot;iPhone 11 Pro&quot;<br>        }<br>      }<br>    },<br>    &quot;test-runner&quot;: &quot;jest&quot;,<br>    &quot;runner-config&quot;: &quot;e2e/config.json&quot;<br>  }<br>}</pre><p>Now, let&#39;s install one of the frameworks either jest or mocha.</p><p>1. Install detox-cli for jest or mocha</p><pre>$ detox init -r jest</pre><p>OR</p><pre>$ detox init -r mocha</pre><p>It will create an e2e folder in your project, with some basic test files which allow you to start writing your first script, init.js, and some config files, wherein you can mention the type of reporting required.</p><p>There are various reporters available, but I tried using jest-stare as it gives reports in both HTML and JSON format.</p><p>2. Install <a href="https://www.npmjs.com/package/jest-stare">jest-stare</a> reporting</p><pre>$ npm i jest-stare</pre><p>Now, change the config.json file to use the reporter you just added. By defining the jest-stare reporter, e.g</p><pre>&quot;reporters&quot;: [&quot;../node_modules/jest-stare&quot;]</pre><p>Its always important to maintain the folder structure, so that the effort is always streamlined, hence better to keep common things together. I have tried keeping the specs in one folder and user data in a separate JSON file. Let’s do it!</p><p>- Create a sub-folder under e2e naming it specs and add all the specs files underneath</p><pre>e2e<br>├── specs</pre><p>- Create a JSON file under e2e mentioning it as users.json, wherein you will store all the user-related information. As a part of testing, we always need to keep in mind having separate user data for each environment. Why not make it configurable? Let&#39;s do that</p><pre>e2e<br>├── specs<br>└── user.json</pre><pre>{<br>  &quot;dev&quot;: {<br>    &quot;devLoginDetails&quot;: {<br>      &quot;username&quot;: &quot;abc@gmail.com&quot;,<br>      &quot;password&quot;: &quot;12345&quot;<br>    }<br>  },<br>  &quot;stage&quot;: {<br>    &quot;stgLoginDetails&quot;: {<br>      &quot;username&quot;: &quot;cdf@gmail.com&quot;,<br>      &quot;password&quot;: &quot;98765&quot;<br>    }<br>  }<br>}</pre><p>- Now, let&#39;s create a environment file and name it testEnvConfig.js wherein you will mention the environment-specific data, like in our case we have users specific to the environment</p><pre>process.env.ENV_NAME = &quot;dev&quot;</pre><p>- Add, testID for the element you want to perform action now. Move to the source code of your project, identify the element and add testID like below:</p><pre>testID={&#39;basics&#39;}</pre><p>- We shall now modify our firstTest.e2e.js to verify some elements from the react welcome page</p><pre>describe(&quot;Verify the react welcome page elements&quot;, () =&gt; {<br>  beforeEach(async () =&gt; {<br>    await device.reloadReactNative()<br>  })</pre><pre>  it(&quot;should have welcome screen&quot;, async () =&gt; {<br>    await expect(element(by.id(&quot;welcome&quot;))).toBeVisible()<br>  })</pre><pre>  it(&quot;should be able to click on basics link&quot;, async () =&gt; {<br>    await element(by.id(&quot;basics&quot;)).tap()<br>    await expect(element(by.text(&quot;The Basics&quot;))).tap()<br>  })<br>})</pre><p>- In order to execute the tests, we first need to build the app using detox commands</p><pre>$ detox:build</pre><ul><li>Followed by the command to run tests under specs folder, use</li></ul><pre>$ detox:test e2e/specs</pre><ul><li>This will now generate a jest-stare folder within your project, which will have HTML and JSON reporting files, mentioning all the failed and passed test cases. Along with detailed summary for test scenarios under the specs file</li></ul><h3>What&#39;s next now?</h3><p>Yes, as promised we will see the functional tests written in detox to be integrated with CI/CD tools like app center. Having automation scripts is wonderful, but would it make sense if there is an error in code and scripts fail. But your app getting delivering to various environments. The most important part of having automation scripts is to reduce manual effort and having automated deployment and failing the deployments in case of errors.</p><p>Every CI/CD has its own shell files. In the case of <a href="https://appcenter.ms/">appcenter</a> we do have multiple files for executing functions before build (post-build), after build (pre-build), Post-clone, and various others. Let&#39;s focus on appcenter-pre-build.sh file, wherein our app has started building and then let&#39;s add our commands to execute E2E testing before building the app</p><p>- Build the app via detox</p><pre>echo &quot;Building the project for Detox tests...&quot;<br>npx detox build --configuration ios.sim.release</pre><p>- Step 2: Execute our E2E tests via Detox <br> But is that enough?</p><p>We still haven&#39;t stopped the distribution of the app when your tests fail. Here’s a solution provided by app-center, wherein you can use app-center’s open API to cancel the build, using the token</p><pre>echo &quot;Executing Detox tests...&quot;<br>if npx detox test e2e/specs/firstspec.e2e.js --configuration ios.sim.release --cleanup; then<br>  echo &quot;All tests succeeded&quot;<br>else<br>  echo &quot;Test failed&quot;<br>  echo &quot;Cancelling app center build&quot;<br>  API_TOKEN=&quot;&lt;UserToken&gt;&quot;<br>  OWNER_NAME=&quot;&lt;ownerName&gt;&quot;<br>  APP_NAME=&quot;&lt;appName&gt;&quot;<br>  curl -iv &quot;https://appcenter.ms/api/v0.1/apps/$OWNER_NAME/$APP_NAME/builds/$APPCENTER_BUILD_ID&quot; \<br>  -X PATCH \<br>  -d &quot;{\&quot;status\&quot;:\&quot;cancelling\&quot;}&quot; \<br>  --header &#39;Content-Type: application/json&#39; \<br>  --header &quot;X-API-Token: $API_TOKEN&quot;<br>  exit<br>fi</pre><p>Yahoo!! We have successfully implemented our e2e with CI/CD..</p><h3>Summary</h3><p>There are various elements that help you perform different operations and actions of the device, the list is available <a href="https://github.com/wix/Detox/blob/master/docs/README.md">here</a>. Also, tools like Detox helps increase the speed and can be easily integrated with react native apps. The community is growing faster. Have you used Detox for mobile app testing?</p><blockquote><em>Happy using Detox!! 👻</em></blockquote><p>Don’t forget to follow The Lean Programmer Publication for more such articles, and subscribe to our newsletter <a href="http://tinyletter.com/TheLeanProgrammer">tinyletter.com/TheLeanProgrammer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da8c3c498452" width="1" height="1" alt=""><hr><p><a href="https://medium.com/theleanprogrammer/setup-detox-with-react-native-and-appcenter-da8c3c498452">Detox: End-to-End Testing library</a> was originally published in <a href="https://medium.com/theleanprogrammer">TheLeanProgrammer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[File Upload With Encryption]]></title>
            <link>https://medium.com/theleanprogrammer/upload-files-to-drive-in-nodejs-with-encryption-c570b942689b?source=rss-1a2f3e9da66b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c570b942689b</guid>
            <category><![CDATA[google-drive]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[google-drive-api]]></category>
            <category><![CDATA[encryption]]></category>
            <dc:creator><![CDATA[Dikshita Shirodkar]]></dc:creator>
            <pubDate>Wed, 07 Jul 2021 08:38:02 GMT</pubDate>
            <atom:updated>2021-09-26T08:58:21.655Z</atom:updated>
            <content:encoded><![CDATA[<h4>Uploading Files To Drive in NodeJs With Encryption</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UGvndFNlbW5t_rtGgC2Aig.png" /></figure><p>This article is an extension to my previous article <a href="https://dikshitashirodkar.com/lighthouse_with_ga/">generate a front-end performance report</a>, where we generated performance. In this article, we are going to upload the reports to Google Drive.</p><h3>Why upload files to Google Drive?</h3><p>So as testers, we always face challenges when it comes to reporting. Reporting can be in any form, but today we are going to talk about reports generated when we run our e2e automation suites or reports which are generated when we run performance tests.</p><h3>Where do we store them?</h3><p>If running the e2e tests via a CI/CD pipeline, let’s take an example of GitActions. GitAction spins a server when a workflow is triggered and it does the necessary jobs, provides us a report which is mostly preferred to in html format. But where to store them or how to access those reports?</p><p>There are various options available, like <em>posting into a database or uploading the reports to google drive</em>.</p><p>Yes, you heard that correctly!!. Google drive provides API which allows you to upload files in any format onto GoogleDrive.</p><p>So in today’s blog, we are going to learn how to upload files to google drive.</p><h4>Before we start, here are some prerequisite:</h4><p>Enable the google drive API, and generate a client credentials file and download the file on your local machine.</p><ol><li>Enable the google API</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/0*PlnmxCy6HoL2jElE.png" /><figcaption>Google console API</figcaption></figure><p>2. Generate the credentials File, that will have a clientID &amp; clientSecret.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/0*6VXAGiaPMZiTCdSg.png" /><figcaption>Credentials File</figcaption></figure><p><em>Note: This file should not be exposed to others for security reasons.</em></p><p>Since the leak of such files is risky, let’s encrypt these files using a <a href="https://www.npmjs.com/package/json-file-encrypt">json encryption</a> package.</p><p>Install the package using the below command:</p><pre>npm install json-file-encrypt</pre><p>3. Create a cryptography.js that will help us to encrypt and decrypt any file which is in json format. Also, the below code will automatically identify whether the file needs to be encrypted or decrypted based on the extension of the file.</p><p><em>Note: Encrypted files will always have </em><em>.enc extension in the filename.</em></p><pre>const fs = require(&#39;fs&#39;);<br>const jfe = require(&#39;json-file-encrypt&#39;);</pre><pre>// path of the file to encrypt or decrypt<br>const filePath = process.argv[2];</pre><pre>// key to encrypt or decrypt any file<br>const key = process.argv[3];</pre><pre>//generating encryption key<br>const encryptionKey = new jfe.encryptor(key);</pre><pre>const content = fs.readFileSync(filePath);<br>if (filePath.includes(&#39;enc&#39;)) {<br>  const decryptedConfig = encryptionKey.decrypt(content.toString());<br>  const newFilePath = filePath.slice(0, filePath.length - 4);<br>  fs.writeFile(newFilePath, decryptedConfig, (err) =&gt; {<br>    if (err) {<br>      console.log(&#39;Error found&#39;, err);<br>      return;<br>    }<br>    console.log(&#39;Sucessfully decrypted file at&#39;, newFilePath);<br>  });<br>} else {<br>  const encryptedContent = encryptionKey.encrypt(content);<br>  const newFilePath = `${filePath}.enc`;<br>  fs.writeFile(newFilePath, encryptedContent, (err) =&gt; {<br>    if (err) {<br>      console.log(&#39;Error found&#39;, err);<br>      return;<br>    }<br>    console.log(&#39;Sucessfully encrypted file at&#39;, newFilePath);<br>  });<br>}</pre><ul><li>Here’s a command to encrypt or decrypt the file</li></ul><pre>node cryptography.js &lt;Path of fileToEncrypt or fileToDecrypt&gt; &lt;keyToencrypt&gt;</pre><p>Example:</p><pre>node cryptography.js ./client_secret.json xyZ@837YTVXW</pre><p>The above command will encrypt or decrypt the file in a .enc extension</p><p>4. Now, let&#39;s install the Google API package, simply by using the command:</p><pre>npm install googleapis --save</pre><p>5. Here’s the script gdrive-auth-util.js which exports an authorize function to access google drive.</p><pre>const fs = require(&#39;fs&#39;);<br>const readline = require(&#39;readline&#39;);<br>const {google} = require(&#39;googleapis&#39;);<br>const jfe = require(&#39;json-file-encrypt&#39;);</pre><pre>const SCOPES = [&#39;https://www.googleapis.com/auth/drive&#39;];<br>const TOKEN_PATH = &#39;./token.json&#39;;</pre><pre>//generating encryption key<br>const encryptionKey = new jfe.encryptor(process.argv[2]);</pre><pre>// Reading the encrypted credentials.json.enc file and decrypting it<br>const authorize = (credentials, callback) =&gt; {<br>  const {client_secret, client_id, redirect_uris} = credentials.installed;<br>  const oAuth2Client = new google.auth.OAuth2(<br>    client_id,<br>    client_secret,<br>    redirect_uris[0],<br>  );<br>  fs.readFile(TOKEN_PATH, (err, token) =&gt; {<br>    if (err) {<br>      return getAccessToken(oAuth2Client, callback);<br>    }<br>    const decryptToken = encryptionKey.decrypt(token.toString());<br>    oAuth2Client.setCredentials(JSON.parse(decryptToken));<br>    callback(oAuth2Client);<br>  });<br>};</pre><pre>const getAccessToken = (oAuth2Client, callback) =&gt; {<br>  const authUrl = oAuth2Client.generateAuthUrl({<br>    access_type: &#39;offline&#39;,<br>    scope: SCOPES,<br>  });<br>  const rl = readline.createInterface({<br>    input: process.stdin,<br>    output: process.stdout,<br>  });<br>  rl.question(&#39;Enter the code from that page here: &#39;, (code) =&gt; {<br>    rl.close();<br>    oAuth2Client.getToken(code, (err, token) =&gt; {<br>      if (err) return console.error(&#39;Error retrieving access token&#39;, err);<br>      oAuth2Client.setCredentials(token);</pre><pre>      fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err) =&gt; {<br>        if (err) return console.error(err);<br>      });<br>      callback(oAuth2Client);<br>    });<br>  });<br>};</pre><pre>module.exports = authorize;</pre><p>6. Finally create a file uploadToDrive.js which uploads the html Report to google drive. Also, you can pass the parentID (path of the specific folder) you want to upload in.</p><pre>/** @format */</pre><pre>const fs = require(&#39;fs&#39;);<br>const {google} = require(&#39;googleapis&#39;);<br>const jfe = require(&#39;json-file-encrypt&#39;);</pre><pre>const {authorize} = require(&#39;./gdrive-auth-util.js&#39;);</pre><pre>//generating encryption key<br>const encryptionKey = new jfe.encryptor(process.argv[2]);</pre><pre>// format the date for fileName<br>const date = new Date();<br>// eslint-disable-next-line max-len<br>const getTimeStamp = `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}-${date.getHours()}-${date.getMinutes()}`;</pre><pre>// Creating the report fileMetaData<br>const fileMetaData = {<br>    fileName: &#39;example.html&#39;,<br>    name: `${getTimeStamp}-example.html`,<br>    // parentID helps to upload file to a particular folder<br>    parents: [asdjaskd2834728sdfs],<br>};</pre><pre>const uploadFile = (drive) =&gt; {<br>  var media = {<br>    mimeType: &#39;text/html&#39;,<br>    //Path of the report file<br>    body: fs.createReadStream(`./${fileMetaData.fileName}`),<br>  };<br>  drive.files.create(<br>    {<br>      resource: fileMetaData,<br>      media: media,<br>      fields: &#39;id&#39;,<br>    },<br>    (err, file) =&gt; {<br>      if (err) {<br>        // Handle error<br>        console.error(err);<br>      }</pre><pre>      console.log(&#39;Successfully uploded to drive!..&#39;)<br>    },<br>  );<br>};</pre><pre>const storeFiles = (auth) =&gt; {<br>  const drive = google.drive({version: &#39;v3&#39;, auth});<br>  uploadFile(drive);<br>};</pre><pre>const main = () =&gt; {<br>  fs.readFile(&#39;./client_secret.json.enc&#39;, (err, content) =&gt; {<br>    if (err) return console.log(&#39;Error loading client secret file:&#39;, err);<br>    const decryptCredentials = encryptionKey.decrypt(content.toString());<br>    authorize(JSON.parse(decryptCredentials), storeFiles);<br>  });<br>};</pre><pre>if (require.main === module) {<br>  try {<br>    main();<br>  } catch (e) {<br>    console.log(e);<br>  }<br>} else {<br>  module.exports = main;<br>}</pre><p>A token is generated the very first time the authentication is made with Google drive (by executing the uploadToDrive.js). Copy the token and paste it into the token.json file. Encrypt the token.json file token.json.enc for more security.</p><p><em>Note: modifying the scopes or changing the permission to access your google drive will alter the user’s access and refresh tokens, which is created automatically when the authorization flow completes for the first time.</em></p><p>Run the command to upload the file to google drive:</p><pre>node uploadToDrive.js xyZ@837YTVXW</pre><p>There you go... Files will be uploaded to the appropriate folder…</p><p>Thank you for reading.</p><p>Don’t forget to follow The Lean Programmer Publication for more such articles, and subscribe to our newsletter <a href="http://tinyletter.com/TheLeanProgrammer">tinyletter.com/TheLeanProgrammer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c570b942689b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/theleanprogrammer/upload-files-to-drive-in-nodejs-with-encryption-c570b942689b">File Upload With Encryption</a> was originally published in <a href="https://medium.com/theleanprogrammer">TheLeanProgrammer</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Run front-end performance test using lighthouse with puppeteer + Git Actions]]></title>
            <link>https://dikshita-shirodkar.medium.com/run-front-end-performance-test-using-lighthouse-with-puppeteer-git-actions-80b88a81dbeb?source=rss-1a2f3e9da66b------2</link>
            <guid isPermaLink="false">https://medium.com/p/80b88a81dbeb</guid>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[puppeteer]]></category>
            <category><![CDATA[performance-testing]]></category>
            <category><![CDATA[frontend-testing]]></category>
            <category><![CDATA[lighthouse]]></category>
            <dc:creator><![CDATA[Dikshita Shirodkar]]></dc:creator>
            <pubDate>Tue, 06 Jul 2021 05:18:25 GMT</pubDate>
            <atom:updated>2021-07-06T05:50:14.577Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is front-end performance?</h3><p>In simple words, it’s nothing but the experience of the product for end users. Mainly describes the performance of your product.</p><h3>Why front-end performance is important?</h3><p>Earlier, the front-end performance was not necessarily important as the pages use to simply load the html. However the need urged when we adopted use of CSS, Ajax, dynamic images as the web page became a collection of such resources. So if we ignore the front-end performance testing, the sufferings would be to the product adheres to the business.</p><p>Billions of websites are browsed every minute, and the half of the users just closes them within seconds. Just because the users are not likely to spend their time on slow loading sites.</p><p>The ultimate desire of front-end performance is to provide what they need from the site, within no time.</p><h3>Factors impacting the performance</h3><p>There are various factors impacting the performance of any site. I tried listing some of them below: <br> — Unused CSS <br> — Unoptimized images <br> — Minimizing the http requests <br> — Cookie size <br> — Non-blocking javascripts <br> — Javascripts profiling <br> — And lots more</p><h3>Different tools are available for testing the front-end performance</h3><p>Below are some listed: <br> — Lighthouse <br> — Web Page Test <br> — Pingdom <br> — Jmeter</p><p>My personal favorite for front-end testing is Lighthouse. As it just doesn’t tell you about the problem but also provides possible solutions to fix these problems.</p><h3>What is puppeteer?</h3><p>Puppeteer is NodeJS library that provides a high-level API control over special devTools protocol. By default its runs in headless mode and had multiple advantages for test automation for web applications &amp; scraping websites for data.</p><h3>Configure Lighthouse</h3><p>Lighthouse is integrated to Google Chrome. After collecting performance-related insights, the tool automatically compiles a report into a HTML support. Apart from presenting all collected data in a clear, concise way each report has a section dedicated to potential fixes of the detected issues.</p><p>- Install Lighthouse</p><pre>yarn add lighthouse</pre><p>- Install Puppeteer</p><pre>yarn add puppeteer</pre><p>- Folder structure</p><pre>perf<br>  ├─ reports<br>      ├─ loginPageforWeb.html<br>      ├─ homePageforweb.html<br>  └─ config<br>      ├─ siteConfig.json<br>      ├─ lighthouseSettings.json<br>  └─ utils<br>      ├─ auth.js<br>  └─ generatePerfReport.js</pre><p>- Lighthouse provides various options to configure as per convinces of your site. Which could be passed into a lighthouseSettings.json file something like I did below:</p><pre>{<br>  &quot;extends&quot;: &quot;lighthouse:default&quot;,<br>  &quot;settings&quot;: {<br>    &quot;onlyCategories&quot;: [<br>      &quot;accessibility&quot;,<br>      &quot;best-practices&quot;,<br>      &quot;performance&quot;,<br>      &quot;seo&quot;<br>    ],<br>    &quot;formFactor&quot;: &quot;desktop&quot;,<br>    &quot;screenEmulation&quot;: {<br>      &quot;mobile&quot;: false,<br>      &quot;width&quot;: 1350,<br>      &quot;height&quot;: 940,<br>      &quot;deviceScaleFactor&quot;: 1,<br>      &quot;disabled&quot;: false<br>    },<br>    &quot;emulatedUserAgent&quot;: &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4420.0 Safari/537.36 Chrome-Lighthouse&quot;<br>  }<br>}</pre><p>- Keep all the site related variables into one file, like siteConfig.json:</p><pre>{<br>  &quot;dev&quot;: {<br>    &quot;originUrl&quot;: &quot;https://abc.com&quot;,<br>    &quot;targetUrl: &quot;https://abc.com/home&quot;,<br>    &quot;username&quot;: &quot;efg&quot;,<br>    &quot;password&quot;: &quot;Password123&quot;<br>  }<br>}</pre><h3>Launch browser using puppeteer and run our first test</h3><p>Here is the file generatePerfReport.js which generates performance report of any random site.</p><pre>const puppeteer = require(&#39;puppeteer&#39;);<br>const lighthouse = require(&#39;lighthouse&#39;);</pre><pre>const settings = require(&#39;./config/lighthouseSettings.json&#39;)</pre><pre>const PORT = 8041;</pre><pre>const options = {<br>  port: PORT,<br>  disableStorageReset: true,<br>  output: &#39;html&#39;,<br>};</pre><pre>const generatePerformanceReport = async () =&gt; {<br>  const browser = await puppeteer.launch({<br>    args: [`--remote-debugging-port=${PORT}`],<br>    headless: true, //can be set to false<br>    slowMo: 50,<br>  });</pre><pre>  const url = &quot;https://abc.com&quot;<br>  const loginPageReport = await lighthouse(url, options, settings);<br>  const loginPageReportHtml = loginPageReport.report;<br>  fs.writeFileSync(<br>    `./reports/loginPageReportfor.html`,<br>    loginPageReportHtml,<br>  );<br>  console.log(&#39;Performance report generated successfully!!&#39;);</pre><pre>  await browser.close();<br>};</pre><pre>if (require.main === module) {<br>  try {<br>    generatePerformanceReport();<br>  } catch (e) {<br>    console.log(e);<br>  }<br>} else {<br>  module.exports = generatePerformanceReport;<br>}</pre><h3>Get the performance of authenticated sites using puppeteer</h3><p>Let’s create a test file auth.js which helps us to login to any authenticated site. It takes 2 parameter browser and origin which we will discuss on further</p><pre>const config = require(&#39;config/siteConfig.json&#39;);</pre><pre>// config required inorder to login to the site<br>const EMAIL = config.username;<br>const PASSWORD = config.password;</pre><pre>// Test Steps to login the site with username &amp; password</pre><pre>const login = async (browser, origin) =&gt; {<br>  const page = await browser.newPage();<br>  await page.goto(origin);<br>  await page.waitForSelector(&#39;input[id=&quot;username&quot;]&#39;, {visible: true});<br>  await page.waitForSelector(&#39;input[id=&quot;username&quot;]&#39;, {visible: true});<br>  const emailInput = await page.$(&#39;input[id=&quot;username&quot;]&#39;);<br>  await emailInput.type(EMAIL);<br>  const nextBttn = await page.$(&#39;span[id=&quot;submit-text&quot;]&#39;);<br>  await nextBttn.click();<br>  await page.waitForSelector(&#39;input[id=&quot;password&quot;]&#39;, {visible: true});<br>  const passwordInput = await page.\$(&#39;input[id=&quot;password&quot;]&#39;);<br>  await passwordInput.type(PASSWORD);<br>  await Promise.all([<br>    page.click(&#39;button[id=&quot;submit-login-form&quot;]&#39;),<br>    page.waitForNavigation(),<br>  ]);<br>  await page.close();<br>};</pre><pre>module.exports = login;</pre><p>Now, let’s enhance generatePerfReport.js to get performance of authenticated pages</p><pre>const fs = require(&#39;fs&#39;);<br>const puppeteer = require(&#39;puppeteer&#39;);<br>const lighthouse = require(&#39;lighthouse&#39;);</pre><pre>const config = require(&#39;config/siteConfig.json&#39;);<br>const settings = require(&#39;./config/lighthouseSettings.json&#39;)<br>const login = require(&#39;./utils/auth&#39;);</pre><pre>const PORT = 8041;</pre><pre>const options = {<br>  port: PORT,<br>  disableStorageReset: true,<br>  output: &#39;html&#39;,<br>};</pre><pre>// Launching browser in headless mode to generate report for login &amp; homePage<br>const generatePerformanceReport = async () =&gt; {<br>  const browser = await puppeteer.launch({<br>    args: [`--remote-debugging-port=${PORT}`],<br>    headless: true, //can be set to false<br>    slowMo: 50,<br>  });</pre><pre>  // Generating report for login page, which is an unauthenticated page<br>  await generateReportForLogin();</pre><pre>  // Logging into the site<br>  await login(browser, config.originUrl);</pre><pre>  // Generating report for home page, which is an authenticated page<br>  await generateReportForHome();</pre><pre>  await browser.close();<br>};</pre><pre>// Storing the login page report in file system<br>const generateReportForLogin = async () =&gt; {<br>  const loginPageReport = await lighthouse(config.originUrl, options, settings);<br>  const loginPageReportHtml = loginPageReport.report;<br>  fs.writeFileSync(<br>    `./reports/loginPageReport.html`,<br>    loginPageReportHtml,<br>  );<br>  console.log(`login page performance report generated successfully`);<br>};</pre><pre>// Storing the home page report in file system<br>const generateReportForHome = async () =&gt; {<br>  //HomePage performance<br>  const url = config.targetUrl;<br>  const homePageReport = await lighthouse(url, options, settings);<br>  const homePageReportHtml = homePageReport.report;<br>  fs.writeFileSync(<br>    `./reports/homePageReport.html`,<br>    homePageReportHtml,<br>  );<br>  console.log(`home page performance report generated successfully`);<br>};</pre><pre>if (require.main === module) {<br>  try {<br>    generatePerformanceReport();<br>  } catch (e) {<br>    console.log(e);<br>  }<br>} else {<br>  module.exports = generatePerformanceReport;<br>}</pre><p>- Run your performance test, by using simple command:</p><pre>node generatePerformanceReport.js</pre><h3>How do we fix the performance related issues ?</h3><p>There is a wonderful blog, which explains how such issues could fixed, continue reading for <a href="https://medium.com/@april9288/how-i-got-a-100-lighthouse-score-with-my-react-app-2b676ef62113">reference</a>.</p><h3>Where you run the front-end performance test?</h3><p>Never run the performance test on local machine, as the results would always fluctuating. Due to various factors affecting the run.</p><p>- Internet traffic &amp; routing changes <br> — Testing on different devices, such as a high-performance desktop and a low-performance laptop <br> — Browser extensions that inject JavaScript and add/modify network requests etc</p><p>Hence always run it in a stable enviroment. So lets do something exciting, lets generate our performance reports using Github Actions.</p><p>- Structure your github actions folders:</p><pre>.github<br>├─ workflows<br>├─ runPerfActions.yaml</pre><p>- Lets proceed with configuring our yaml file</p><pre>name: Trigger front end perf<br>on:<br>  workflow_dispatch:<br>jobs:<br>  generatePerfReport:<br>    runs-on: ubuntu-latest<br>    defaults:<br>      run:<br>        working-directory: e2e/perf<br>    strategy:<br>      matrix:<br>        node-version: [12.x]<br>    steps:<br>    - uses: actions/checkout@v2<br>    - name: Install node ${{ matrix.node-version }}<br>      uses: actions/setup-node@v2<br>      with:<br>        node-version: ${{ matrix.node-version }}<br>    - uses: borales/actions-yarn@v2.0.0<br>    - run: yarn install<br>    - run: node generatePerfReport.js</pre><p><em>Recommendation: You could also try posting your reports on Google drive. Shortly would be posting a article on how to upload reports to google drive</em></p><p>Thanks for reading 😄.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80b88a81dbeb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fab things which could be done with InfluxDB & Grafana]]></title>
            <link>https://dikshita-shirodkar.medium.com/fab-things-which-could-be-done-with-influxdb-grafana-e41e88a8e159?source=rss-1a2f3e9da66b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e41e88a8e159</guid>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[influxdb]]></category>
            <dc:creator><![CDATA[Dikshita Shirodkar]]></dc:creator>
            <pubDate>Mon, 05 Jul 2021 09:46:34 GMT</pubDate>
            <atom:updated>2021-07-05T09:46:34.593Z</atom:updated>
            <content:encoded><![CDATA[<h3>Learn what’s InfluxDB?</h3><p>InfluxDB is nothing new but a database, which is a time series database platform. Its built to handle massive countless time-stamped entires stored at a place. Which can store infrastructure, applications and sensors data entires.</p><p><strong>You would wonder why influxDB??</strong> instead of other databases available in market like mySQL, PostgreSQL, Microsoft SQL Server, MongoDB etc. The answer to it is, influxDB is very light weight, simple and the best part of the database is that it could be used directly by making raw https requests.</p><h3>Installation of influxDB on MacOS</h3><p>1. Install InfluxDB service on your system</p><pre>brew update<br>brew install influxdb</pre><p>For other operating systems you may refer this link: <a href="https://docs.influxdata.com/influxdb/v1.7/introduction/installation/#installing-influxdb-oss">Installation links</a></p><p><strong><em>Note: Default port used by influxDB is 8086</em></strong></p><p>2. Start the service on your MacOS</p><pre>brew services start influxdb</pre><p>3. Now, let’s jump inside the influxDB</p><pre>➜  ~ influx<br>Connected to http://localhost:8086 version 1.8.2<br>InfluxDB shell version: 1.8.2</pre><p>4. Stopping the InfluxDB service is easy.</p><pre>brew services stop influxdb</pre><h3>Concepts and terminologies used in InfluxDB</h3><h4>Database</h4><p>A database is a container (place) for storing information, with time series data incase of influxDB. How do we create a database? It’s simple</p><pre>create database groccery</pre><p>To list the created databases:</p><pre>show databases</pre><h4>Fields</h4><p>Fields are actually the columns in a measurement. It’s a key-value pair, includes storing of fields in the field column and values in the values column. Fields aren’t indexed, hence while using a query for values which do not vary &amp; not part of where clause are generally stored as fields in a table.</p><h4>Tags</h4><p>Tags in general term are fields which are indexed when created. And allows better quering and filtering of data in a measurement.</p><h4>Measurement</h4><p>It’s a combination of fields and tags which together creates a measurement (table).It’s a part wherein we can store data in associated fields in influxDB.</p><p>Before creating a measurement we need to use the database within which a measurement (table) would be created. So let’s first use the database</p><pre>&gt; use groccery<br>Using database groccery</pre><p>Now, create a measurement with fields and tags forming its structure. Let us insert multiple records in the measurement.</p><pre>insert fruits,category=pome,type=apple value=10<br>insert fruits,category=citrus,type=orange value=5<br>insert fruits,category=stone,type=cherries value=15<br>insert fruits,category=pome,type=pears value=25</pre><p>Fruits here is a measurement, which contains category, type as tags and value being the field. Let’s execute the query to see all the inserted records under the fruits measurement:</p><pre>&gt; select * from fruits<br>name: fruits<br>time                category type     value<br>----                -------- ----     -----<br>1606373405724568000 pome     apple    10<br>1606373527398317000 citrus   orange   5<br>1606373532126017000 stone    cherries 15<br>1606373542271729000 pome     pears    25</pre><p>For more details on InfluxDb, you may refer this <a href="https://docs.influxdata.com/influxdb/v2.0/get-started/">link</a></p><h3>What’s Grafana?</h3><p>It’s a visualization dashboard, which allows you to plot interactive and dynamic graphs. It provides plotting of data in different forms like, graphs, charts, alerts etc.</p><p>You can plot beautiful graphs with time-series data, which is the exact requirement fulfilled by InfluxDB.</p><h3>Install Grafana on MacOS</h3><p>1. Install Grafana service on your system</p><pre>brew update<br>brew install grafana</pre><p>Links for installing grafana on other operating systems are <a href="https://grafana.com/docs/grafana/latest/installation/">here</a></p><p>2. Start the Grafana service using command</p><pre>➜  ~ brew services start grafana<br>Service `grafana` already started, use `brew services restart grafana` to restart.</pre><p><em>Note: Default port used by grafana is 3000 and the standard username/password after installation is admin/admin. Password can be changed after logging into the system</em></p><p>3. Access “<a href="http://localhost:3000/login">http://localhost:3000/login</a>&quot; and login with admin/admin credentials. <br> Here’s the first glance of the Grafana dashboard</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*VUkocLu8CrOnPdqC.png" /></figure><p>4. Stopping the Grafana service is simple too</p><pre>brew services stop grafana</pre><h3>Quering and building dashboards within Grafana</h3><p>Firstly, we need to connect the data-source which would provide us the data to plot dynamic graphs. Let’s proceed with the steps required to connect InfluxDB with Grafana. <br> <br> 1. Start the influxDB service <br> <br> 2. Start the grafana service <br> <br> 3. Login to grafana dashboard and move to datasource section. <br> <br> There are couple of datasources which are provided by Grafana i.e: <br> <br>- Prometheus <br> <br>- Graphite <br> <br>- Open TSDB <br> <br>- InfluxDB and many more</p><p>We would use InfluxDB, hence choose datasource as Influx add the required details regarding database, save the settings and success message should be shown.</p><pre>Data source is working</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*z6ZyCk6kZw2_VcAA.png" /></figure><p>4. Now proceed creating a dashboard which would display the data related to a application or a system. <br> <br> 5. Create a new dashboard, access the settings icon to rename it as <strong>Grocerry Reports</strong> <br> <br> 6. Create a panel within the Dashboard, access the datasource and query the data as follows:</p><p><strong>In-order to get hands On, let’s create 2 panels</strong> <br> <br> 1. Types of fruits which will be a pie chart, whose query would be something like</p><pre>SELECT &quot;value&quot; FROM &quot;fruits&quot; WHERE $timeFilter GROUP BY &quot;type&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*HNLmumceF1_xz36u.png" /></figure><p>2. Categorize fruits in terms of citrus, pome &amp; stone which would be a bar guage representation, with query</p><pre>SELECT &quot;value&quot; FROM &quot;fruits&quot; WHERE $timeFilter GROUP BY &quot;category&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*bC4gKgHyXqXIWthS.png" /></figure><p>That’s about it! I may have missed few things here for sure. Connect with me at <a href="https://dikshitashirodkar.com/influxdb_with_grafana/dikshitashirodkar25@gmail.com">dikshitashirodkar25@gmail.com</a>, If you would like to know more, or comment down here :)</p><p>Also for more blogs refer to: <a href="https://dikshitashirodkar.com/">https://dikshitashirodkar.com/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e41e88a8e159" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>