<?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 RAKESH on Medium]]></title>
        <description><![CDATA[Stories by RAKESH on Medium]]></description>
        <link>https://medium.com/@jonbonraki?source=rss-2614a020d3ff------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*f4Ob9Kh1vbekUFtC.jpg</url>
            <title>Stories by RAKESH on Medium</title>
            <link>https://medium.com/@jonbonraki?source=rss-2614a020d3ff------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 16:17:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jonbonraki/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[PMP Flow]]></title>
            <link>https://medium.com/@jonbonraki/pmp-flow-53b5dbc21601?source=rss-2614a020d3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/53b5dbc21601</guid>
            <category><![CDATA[pmp-certification]]></category>
            <category><![CDATA[pmp-course]]></category>
            <category><![CDATA[pmp]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[pmp-training]]></category>
            <dc:creator><![CDATA[RAKESH]]></dc:creator>
            <pubDate>Thu, 23 Apr 2020 03:41:01 GMT</pubDate>
            <atom:updated>2020-04-23T03:41:01.085Z</atom:updated>
            <content:encoded><![CDATA[<p>I have seen Richard vargos YouTube video in my bid to prepare for pmp. here is the link for those wish to prepare for PMP. its a must watch video, I felt the video did a good job in explaining the things in the order which chapter needs to be watched.</p><p>As I finished the video Richard left us with exercise to practice the pmp flow chart with a set of white paper with canvas and another sheet of cards which contain PMP chapter as cards.</p><p>As I took printouts of the sheets and tried to go through the process of pasting the PMP chapter cards on their placeholders of the canvas, I realized why not make it digital? I Luckily have enough knowledge to do so. Lets spin up the angular cdk kit s drag and drop feature functionality to create a draggable canvas in angular 7.</p><p>In doing so i would get to play with angular 7 and angular cdk kit too, hopefully host it and share the application with community such that they can gain some value from it in their journey for preparation of PMP exam.</p><p>If your are interested in knowing the steps in which i accomplished, please feel to read further from here.</p><p>If your are happy to jump on to the application and play with the exercise that richard has listed in the video. here is the link to it.</p><p>Happy Exam Preparation to my fellow PMP Prospective s.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53b5dbc21601" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Experiences From Moving An Application from Angular 4 to Angular 5.]]></title>
            <link>https://medium.com/@jonbonraki/experiences-in-moving-a-application-from-angular-4-to-angular-5-31569f2cb230?source=rss-2614a020d3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/31569f2cb230</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular-5]]></category>
            <category><![CDATA[angular2]]></category>
            <category><![CDATA[localization]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[RAKESH]]></dc:creator>
            <pubDate>Mon, 25 Dec 2017 02:15:51 GMT</pubDate>
            <atom:updated>2017-12-25T02:17:29.490Z</atom:updated>
            <content:encoded><![CDATA[<p>Here are two things I wanted to share in an application from angular 4 to angular 5.</p><p>First Step is to upgrade all of our angular dependencies.</p><pre>npm install @angular/animations@&#39;^5.0.0&#39; @angular/common@&#39;^5.0.0&#39; @angular/compiler@&#39;^5.0.0&#39; @angular/compiler-cli@&#39;^5.0.0&#39; @angular/core@&#39;^5.0.0&#39; @angular/forms@&#39;^5.0.0&#39; @angular/http@&#39;^5.0.0&#39; @angular/platform-browser@&#39;^5.0.0&#39; @angular/platform-browser-dynamic@&#39;^5.0.0&#39; @angular/platform-server@&#39;^5.0.0&#39; @angular/router@&#39;^5.0.0&#39; typescript@2.4.2 rxjs@&#39;^5.5.2&#39;</pre><pre>npm install typescript@2.4.2 --save-exact</pre><ol><li><strong>Change HttpModule and the Http service to HttpClientModule</strong> and <strong>HttpClient service.</strong></li></ol><p>Switch from <strong>HttpModule and the Http service </strong>as they are deprecated and their Corresponding counterparts are<strong> HttpClientModule</strong> and the <strong>HttpClient . </strong>HttpClient simplifies the default ergonomics (You don’t need to map to JSON anymore) and now supports typed return values and interceptors.</p><pre><strong>Change From:</strong> <br>import { Http, Response } from ‘@angular/http’;</pre><pre><strong>Change To</strong>: <br>import { HttpClient, HttpClientModule } from ‘@angular/common/http’</pre><p><strong>2. Ng2-Translate to Ngx-translate</strong></p><p>For Localization of text in our application we used ng2-translate. This has also been upgraded to ngx-translate.So Along with Angular 5 upgrade we had to upgrade to ngx-translate.The following are the changes.</p><p>npm install @ngx-translate/core --save</p><pre>npm install @ngx-translate/http-loader --save</pre><p>Change existing import from ‘ng2-translate’ to ‘ngx-translate’</p><pre><strong>import &#39;@ngx-translate/core&#39;</strong>;<br><br><strong>import &#39;@ngx-translate/http-loader&#39;</strong>;</pre><p><strong>Changes in Importing The Translate modules While Bootstrapping the Application.</strong></p><p>Change the existing import of http and ng2-translate module from</p><pre><strong>Change From:<em><br>import </em></strong><em>{ TranslateModule,<br><br>         TranslateLoader,<br><br>         TranslateStaticLoader} </em><strong><em>from &#39;ng2-translate&#39;</em></strong><em>;<br><br></em><strong>Change To:<br><em>import </em></strong><em>{ TranslateModule, TranslateLoader} </em><strong><em>from &#39;@ngx-translate/core&#39;</em></strong><em>;<br><br></em><strong><em>import </em></strong><em>{ TranslateHttpLoader } </em><strong><em>from &#39;@ngx-translate/http-loader&#39;</em></strong><em>;</em></pre><pre><strong>Change from:<br> </strong>TranslateModule.<em>forRoot</em>({<br><br>    <strong>provide</strong>: TranslateLoader,<br><br>    useFactory: (http: Http) =&gt; <strong>new </strong>TranslateStaticLoader(http, <strong>&#39;languages&#39;</strong>, <strong>&#39;.json&#39;</strong>),<br><br>    <strong>deps</strong>: [Http]<br><br>})</pre><pre><strong>Change to</strong>: <br>TranslateModule.<em>forRoot</em>({<br><br>    <strong>loader</strong>: {<br><br>        <strong>provide</strong>: TranslateLoader,<br><br>        useFactory: (httpClient: HttpClient) =&gt; <strong>new </strong>TranslateHttpLoader(httpClient, <strong>&#39;languages&#39;</strong>, <strong>&#39;.json&#39;</strong>),<br>        <strong>deps</strong>: [HttpClient]<br>    }<br>})</pre><p>References:</p><ul><li><a href="https://angular-update-guide.firebaseapp.com/">Angular Update Guide - Beta</a></li><li><a href="https://angular.io/guide/http">Angular</a></li><li><a href="https://github.com/ngx-translate/core">GitHub - ngx-translate/core: The internationalization (i18n) library for Angular</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31569f2cb230" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generate Environment Specific Rest URL Through Web pack For Application Built from Angular.]]></title>
            <link>https://medium.com/@jonbonraki/generate-environment-specific-rest-url-through-web-pack-for-application-built-from-angular-a8470412297c?source=rss-2614a020d3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8470412297c</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[RAKESH]]></dc:creator>
            <pubDate>Sun, 10 Dec 2017 00:52:25 GMT</pubDate>
            <atom:updated>2017-12-10T00:52:25.577Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, We will go through questions any Front End Developer has to address while building up a project from scratch.</p><p>· Why Does JavaScript Need To Care which Environment It Is In?</p><p>· How Do We Generate A Environment Specific Rest API URL?</p><p>· Once We Understood The Above Questions, We will develop a solution to by Using webpack.</p><h4><strong><em>Why Does JavaScript Need To Care which Environment It Is In?</em></strong></h4><p>We have different staging environments in phase of deploying our application to a ultimate production environment . Some of the staging environments are Dev, QA, SAT, UAT, and Prod.A JavaScript Package Which we Ship to all of these staging environments is a Static Code, why does it have to know which environment it is in?</p><h4><strong>Each Environment is Different And Data Powering the JavaScript Application Is Different.</strong></h4><p>It has to Care, The Rest services on which we feed is a environment specific, Data emanating from the database is specific to environment.Even though Our JavaScript application is a static code, The data we retrieve from the Rest Service is not static and it will depend on Environment It is In.</p><h4><strong>How Do We Generate A Environment Specific Rest API URL?</strong></h4><p>The window of time we have during bundling of our static application is time in which we can set the environment specific Rest API URL.</p><h4>Once We Understood The Above Questions, We need a solution to address.</h4><p>So how does an app using Web pack as build tool for packaging static file able to have dynamic Rest API URL pointed to different environment when it’s compile. Lets dive into it without wasting much time.</p><h3><strong>Set Up mock Rest end points using express.js</strong></h3><p>I did set up a node server with routes with end points specific to dev, qa , uat, sat and prod which returns json object as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oQ0nJFkqPqlnV2jB_hfdqg.png" /></figure><p>Run cd api, once you your are in api folder, do an npm install, and get the routes for different apis up by doing node server.js</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*w33_bal9CaXQcW1rDaqY7Q.png" /></figure><p>If you are interested in going through the detailed tutorial of setting Rest ApI with Node.js,I would suggest you to check out this article, which I found very helpful.</p><p><a href="http://bigspaceship.github.io/blog/2014/05/14/how-to-create-a-rest-api-with-node-dot-js/">Create a REST API with Node.js</a></p><h3>Set Up Script In Package.json and Configure Webpack.js</h3><pre>&quot;start&quot;: &quot;webpack-dev-server <strong>--env.dev --config config/webpack.js</strong> --progress --profile --colors --hot --port=4200 --open&quot;,</pre><p>This Script Kicks off webpack.js file with a variable which will be passed as input parameter as shown below.- -env.dev passes the variable into config object of webpack.js as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*gfvIJKEFCJIhtoZrvVVMQw.png" /></figure><p>Inside webpack.js, setUpApi function will be passed with this environment variable to do a sanity check and If it carries a dev value, we will assign the Dev instance of REST API URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*zOYQ2QXflCOO9FxFsIjbWQ.png" /></figure><p>The apiHost variable will carry the API URL of Dev, But this is still a problem, Scope of the variable apiHost is limited to webpack.js and it only lives in webpack.js.To make it Global we have a Super tool from Webpack in the form of plugin known as DefinePlugin.</p><h3>DefinePlugin (Plugin From Webpack To Define Global Variables During Time a.k.a Super Tool)</h3><p>With DefinePlugin you can Initialize a global Constant which is set during the build time of application and available through out the application.</p><p>So, We set our <strong>apiHost</strong> URL inside webapack with DefinePlugin as shown Below.when the <strong>apiHost</strong> is populated We make sure it is hold under <strong>process.env.apIHost </strong>as shown below.When Webpack Compilation is complete and a bundle is created, It populates the environment specific DEV URL in <strong>process.env.apiHost</strong>. Now <strong>process.env.apiHos</strong>t becomes global constant through out the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*U6AIKjBOb94zMQnwL2nmfQ.png" /></figure><h4>How do We Utilize This Global Constant In Our Application?</h4><p>Now That we Crossed Bridge of creating a global constant through out the application,Process.env.apiHost can be defined in your application.In our demo project we have an api.service.ts which should carry our Rest API URL call through process.env.apiHost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*FSws55pvX1mc-7VKpZou_A.png" /></figure><p>Instantiate Constructor with apiService, call the method as shown to render the content message under messageFromEnvironment to view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*CCgn9q6ICzV9-9N8hP3oIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*i6DggdnoGIegupzvvhVeFg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BhonOZnFVR9haEZu7GnIig.png" /></figure><h3>Now What About Other Environments?</h3><p>Similarly we can take the same approach we did above and extend it to other environment QA, SAT, UAT and Prod.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*kAyLwjF0G-flbp2PULqMvw.png" /></figure><p><strong><em>For QAT(Quality Acceptance Testing):</em></strong></p><pre>“start”: “webpack-dev-server <strong>— env.qa — config config/webpack.js</strong> — progress — profile — colors — hot — port=4200 — open”,</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LVnQvnPyX2nSftLck8PTXw.png" /></figure><p><strong><em>For SAT(System Acceptance Testing):</em></strong></p><pre>“start”: “webpack-dev-server <strong>— env.sat — config config/webpack.js</strong> — progress — profile — colors — hot — port=4200 — open”,</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dNLTLpMN2ebiTDBIuTc-aw.png" /></figure><p><strong><em>For UAT(User Acceptance Testing):</em></strong></p><pre>“start”: “webpack-dev-server <strong>— env.uat— config config/webpack.js</strong> — progress — profile — colors — hot — port=4200 — open”,</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*SrGsHSPKOm_7QMeQCA5rnw.png" /></figure><p><strong><em>For PROD(Production):</em></strong></p><pre>“start”: “webpack-dev-server <strong>— env.prod — config config/webpack.js</strong> — progress — profile — colors — hot — port=4200 — open”,</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*AtLdADXdC8cqBVWefRTk4Q.png" /></figure><p>Here is the package.json.</p><pre>&quot;scripts&quot;: {</pre><pre>&quot;ng&quot;: &quot;ng&quot;,</pre><pre>&quot;start&quot;: &quot;webpack-dev-server --env.dev --config config/webpack.js --progress --profile --colors --hot --port=4200 --open&quot;,</pre><pre>&quot;build:dev&quot;: &quot;rimraf dist &amp;&amp; webpack --env.dev --config config/webpack.js --progress --profile --hot&quot;,</pre><pre>&quot;build:qa&quot;: &quot;rimraf dist &amp;&amp; webpack --env.qa --config config/webpack.js --progress --profile --colors --hot&quot;,</pre><pre>&quot;build:sat&quot;: &quot;rimraf dist &amp;&amp; webpack --env.sat --config config/webpack.js --progress --profile --colors --hot&quot;,</pre><pre>&quot;build:uat&quot;: &quot;rimraf dist &amp;&amp; webpack --env.uat --config config/webpack.js --progress --profile --colors --hot&quot;,</pre><pre>&quot;build:prod&quot;: &quot;rimraf dist &amp;&amp; webpack --env.prod --config config/webpack.js --progress --profile --hot&quot;<br>}</pre><p>Here is Source Code For Demo: <a href="https://github.com/HAL90012017/WebPackEnvironmentRestApiURL">https://github.com/HAL90012017/WebPackEnvironmentRestApiURL</a></p><p>Thanks for reading! ❤</p><h3><strong>References</strong></h3><ul><li><a href="https://webpack.js.org/plugins/define-plugin/">DefinePlugin | webpack</a></li><li><a href="http://bigspaceship.github.io/blog/2014/05/14/how-to-create-a-rest-api-with-node-dot-js/">Create a REST API with Node.js</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8470412297c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Template Driven Angular Validations.]]></title>
            <link>https://medium.com/@jonbonraki/template-driven-angular-validations-57d291467f2b?source=rss-2614a020d3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/57d291467f2b</guid>
            <category><![CDATA[angular-cli]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[forms]]></category>
            <category><![CDATA[angular-5]]></category>
            <dc:creator><![CDATA[RAKESH]]></dc:creator>
            <pubDate>Sat, 25 Nov 2017 00:27:46 GMT</pubDate>
            <atom:updated>2017-11-25T23:28:41.699Z</atom:updated>
            <content:encoded><![CDATA[<p>Angular Comes with Validation Modules Like Template Driven, Reactive and Dynamic Form.Today we will take a look at Template driven Validations.</p><p>Template Driven Angular Validations are Simplest form of all validations and it is Used to Conduct the form validation of simplest sort.</p><p>I will walk you through a simple form validation where a user will have to will fill in employee details before hitting on submit button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VE76up7nX1SyHv8Ug1mMNQ.png" /></figure><p>The form will consist of Employee Name, Employee Number and Employee Start Date.</p><p>All three fields are required in order to submit employee details. If the user hits save without entering the required fields, all the fields should lighten up and throw out validation error messages.</p><p>When everything required is entered, you can save the form.</p><h3><strong>Register the Form with NgForm</strong></h3><blockquote>We attach the form name which is <strong><em>empolyeeDetailsForm</em></strong> to form which encapsulates all the three fields within itself.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*K_TL29IRMNpLZRuxDirCaA.png" /></figure><h3>Register Each of the Form Elements To Track and validate the Element.</h3><p>Once we register the form to ngForm, we need to register each of our fields with angular form which we created on form element.</p><p>This is done by giving the name of the element and specifying the name with ngModel attribute as shown below. Also don’t forget to add required attribute to each of the fields.</p><pre> name=&quot;employeeName&quot;  #employeeName=&quot;ngModel&quot;<br> name=&quot;employeeNumber&quot;  #employeeNumber=&quot;ngModel&quot;<br> name=&quot;employeeStartdate&quot; #employeeStartdate=&quot;ngModel&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V74Y0Zez6DG6k0fN2R368w.png" /></figure><p>This registers each element to angular form.</p><h3>Track control, Determine and Show the validation Message.</h3><p>Now we need to know whether each of our element is invalid and touched, so that we can determine the state of the element. It can be tracked by using form properties like invalid or touched and show the validation messages accordingly. Please bear in mind that we don’t have $prepended to each of the properties as it used to be in doppelgängers of legacy angular (angular js).</p><p>We use these properties to show the validation message below the element name. Note that we have validation class where it carries red color to show the text in red. You can use your own custom class to meet your requirement to display a validation message.</p><pre>&lt;span *ngIf=&quot;(employeeName.invalid &amp;&amp; employeeName.touched)&quot; class=&quot;validation&quot;&gt;<br>    Employee Name is required<br>  &lt;/span&gt;</pre><pre>&lt;span *ngIf=&quot;(employeeNumber.invalid &amp;&amp; employeeNumber.touched)&quot; class=&quot;validation&quot;&gt;<br>    Employee Number is required<br>  &lt;/span&gt;</pre><pre>&lt;span *ngIf=&quot;(employeeStartdate.invalid &amp;&amp; employeeStartdate.touched)&quot; class=&quot;validation&quot;&gt;<br>  Employee Start Date is required<br>&lt;/span&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IH8ffH9CTqDch4Gycb9sbw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XeD_ZRN9zR6EreI04IaAtw.png" /></figure><h3><strong>Is That it?</strong></h3><p>But wait, what happens when the User clicks on Submit Button without playing or touching with fields?</p><p>This is where we use markAsTouched() to lighten up the form and prompt the user that they can’t get away with such a smart trick.</p><pre>public submit(employeeDetailsForm) {<br> if (employeeDetailsForm) {<br> this.submitted = true;<br> } <br>else {<br> for (const i in this.employeeDetailsForm.controls) {<br> if (employeeDetailsForm.controls[i]) {<br>  employeeDetailsForm.controls[i].markAsTouched();}<br> }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zD4L1bud4HZbUSgGOq5NZA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SWx5j95wqxH6ZLdyJDMyMg.png" /></figure><p>The Source code for demo can be found at the following Link. please feel free to leave any comment or question you have.</p><p><a href="https://github.com/HAL90012017/angular-forms/tree/template-driven-forms">HAL90012017/angular-forms</a></p><p><strong><em>If you like the article and found it useful please Don’t forgot to click on clap button.</em></strong></p><p>References</p><ul><li><a href="https://angular.io/guide/forms">Angular</a></li><li><a href="https://material.angular.io/guide/getting-started">Angular Material</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57d291467f2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debug Angular.IO Code with Visual Studio Code]]></title>
            <link>https://medium.com/@jonbonraki/debug-angular-io-code-with-virtual-studio-code-852ed5abc75?source=rss-2614a020d3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/852ed5abc75</guid>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[RAKESH]]></dc:creator>
            <pubDate>Mon, 23 Oct 2017 00:48:50 GMT</pubDate>
            <atom:updated>2017-10-23T00:49:37.352Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever since I started working on Angular.IO(Angular 2 and above versions), I was excited on using VsCode IDE in two aspects.</p><blockquote>In terms of its smooth control</blockquote><blockquote>How less the memory it takes out of your system to operate itself.</blockquote><p>Thus in my foray into VsCode I also wanted to debug in VsCode, Thus I Came Across Steps in Setting Up Configuration and I Consolidated into following Six Steps as shown below.</p><p>I wanted to share the configuration i set up for debugging in VsCode with chrome</p><p>Its pretty simple and straight forward.</p><h3><strong>1.Install the </strong><a href="https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome"><strong>Chrome Debugger Extension</strong></a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*b19Q6aoq9dcTAyj-tBFWiw.png" /></figure><h3><strong>2. Create launch.json</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*Em7vQt2kc2fjwVWHoz1wUA.png" /></figure><h3><strong>3. Use the launch.json</strong></h3><p>You note that the host number 8081 is specified in URL and port.This is where my webpack throws the bundled code of my application.</p><pre>{<br>  &quot;version&quot;: &quot;0.2.0&quot;,<br>  &quot;configurations&quot;: [<br>    {<br>      &quot;type&quot;: &quot;chrome&quot;,<br>      &quot;request&quot;: &quot;launch&quot;,<br>      &quot;name&quot;: &quot;Launch Chrome&quot;,<br>      &quot;url&quot;: &quot;http://localhost:8081&quot;,<br>      &quot;webRoot&quot;: &quot;${workspaceRoot}&quot;,<br>      &quot;sourceMaps&quot;: true,<br>      &quot;userDataDir&quot;: &quot;${workspaceRoot}/.vscode/chrome&quot;,<br>      &quot;runtimeArgs&quot;: [<br>        &quot;--disable-session-crashed-bubble&quot;<br>      ]<br>    },<br>    {<br>      &quot;name&quot;: &quot;Attach Chrome&quot;,<br>      &quot;type&quot;: &quot;chrome&quot;,<br>      &quot;request&quot;: &quot;attach&quot;,<br>      &quot;url&quot;: &quot;http://localhost:8081&quot;,<br>      &quot;port&quot;: 8081,<br>      &quot;webRoot&quot;: &quot;${workspaceRoot}&quot;,<br>      &quot;sourceMaps&quot;: true<br>    }<br>  ]<br>}</pre><h3><strong>4. Boot Up the application</strong></h3><p>We usually have a command of some sort to start your web application.</p><p>If your are using webpack configuration <strong>npm start.</strong></p><p>If your are using the angular cli, use<strong> ng serve.</strong></p><h3><strong>5. Start Debugging.</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*V3Yi19Jxwq4tMG8PEIA7wA.png" /></figure><p>Press F5 and the chrome opens up your application in debugging mode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*prK0BGVqKcAmOn2WjxUq8g.png" /></figure><h3><strong>6. Break Points</strong></h3><p>Place the break points (red dot in the gutter as shown belw )in the vsCode on the lines you want to debug.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*dmAMIqzYJp2gA3FOQAw9ZA.png" /></figure><p>Now we are done setting up the configuration, you can start Debugging your code in Visual Studio.</p><h3><strong>References</strong></h3><ul><li><a href="https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome">[Deprecated] Debugger for Chrome - Visual Studio Marketplace</a></li><li><a href="https://code.visualstudio.com/Docs/editor/debugging#_launch-configurations">Debugging in Visual Studio Code</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=852ed5abc75" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tutorial On How to Generate Code Coverage Through Webpack Angular IO]]></title>
            <link>https://medium.com/@jonbonraki/how-do-i-set-up-angular-4-unit-test-coverage-with-webpack-d90b1f2ec51c?source=rss-2614a020d3ff------2</link>
            <guid isPermaLink="false">https://medium.com/p/d90b1f2ec51c</guid>
            <category><![CDATA[angular-4]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[code-coverage]]></category>
            <category><![CDATA[unit-testing]]></category>
            <dc:creator><![CDATA[RAKESH]]></dc:creator>
            <pubDate>Sun, 08 Oct 2017 16:40:08 GMT</pubDate>
            <atom:updated>2020-02-05T20:05:36.250Z</atom:updated>
            <content:encoded><![CDATA[<p>Working on the Angular IO app?</p><p>Awesome.</p><p>You got some functionality going on the app and want to add more lines of code to the application and afraid it might break the existing functionality?</p><p>The Deterrence against such thing from happening is a Unit test. Unit tests are an insurance against a bad code that might break existing functionality.</p><p>The more the percent of the files in your app that come under the Unit tests, the better the deterrence.</p><p>You Have to Set up your Unit test with karma.conf.js, Now you do like to See the Lines of code that were covered as part of the Unit tests that you added?</p><h3><strong>Coverage through Angular CLI.</strong></h3><p>Note that we can do a lot of the unit test coverage with Angular CLI too.</p><p>I found an article to generate test code coverage through angular CLI.</p><p><a href="https://coryrylan.com/blog/enforcing-code-coverage-in-angular-cli-projects">https://coryrylan.com/blog/enforcing-code-coverage-in-angular-cli-projects</a></p><p>While the Angular CLI is Extremely quick and easy to set up, ideal for beginners, It is shy-ed away from the apps that are deployed in production for many reasons Like Inflexible structuring of the folder.</p><p>There are also some other reasons where laid out very well in the following article.</p><p><a href="https://medium.jonasbandi.net/my-concerns-with-the-angular-cli-9002bdf36975">My Concerns with the Angular CLI</a></p><p>So I am not going in-depth in setting up coverage through angular-CLI.</p><h3>Coverage through Webpack.</h3><p>I had come across where Minimum Amount of documentation or tutorials walking through the Unit test code coverage generation, So Today I m going to walk you through the code coverage generation from the example Based of Angular documentation.<a href="https://angular.io/tutorial">https://angular.io/tutorial</a></p><p>I made a GitHub repository of the project mentioned in angular documentation and it is <a href="https://github.com/HAL90012017/AngularUnitTestCoverage">https://github.com/HAL90012017/AngularUnitTestCoverage</a></p><p>After the app has been set up locally and running.</p><h3><strong>Step 1: Add The following packages to packages.json</strong></h3><pre><strong>&quot;karma-coverage&quot;</strong>: <strong>&quot;^1.1.1&quot;</strong>,<br><strong>&quot;istanbul-instrumenter-loader&quot;</strong>: <strong>&quot;2.0.0&quot;</strong>,<br><strong>&quot;karma-coverage-istanbul-reporter&quot;</strong>: <strong>&quot;^1.3.0&quot;</strong>,<br><strong>&quot;karma-mocha-reporter&quot;</strong>: <strong>&quot;^2.2.3&quot;</strong>,<br><strong>&quot;karma-remap-coverage&quot;</strong>: <strong>&quot;^0.1.4&quot;</strong></pre><p>Do an npm install, it will fetch the packages and place it in your node_modules.</p><p>We will be using <strong>“istanbul-instrumenter-loader”</strong>, its a node module package that is available through npm install <strong>istanbul-instrumenter-loader.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*2FUwYMxiQYMuTHiZcvJijg.png" /></figure><p>The above-mentioned change is available on branch step-1</p><p><a href="https://github.com/HAL90012017/AngularUnitTestCoverage/tree/step-1">https://github.com/HAL90012017/AngularUnitTestCoverage/tree/step-1</a></p><h3><strong>Step 2 : Add a Rule To Webpack.test.js</strong></h3><p>Once you have this module installed successfully we need to configure the module with webpack with a rule with enforcing attribute as post to go through files and generate the code coverage as shown below.</p><pre><em>/**<br> * Instruments JS files with Istanbul for subsequent code coverage reporting.<br> * Instrument only testing sources.<br> *<br> * See: https://github.com/deepsweet/istanbul-instrumenter-loader<br> */<br></em>{<br>    <strong>enforce</strong>: <strong>&#39;post&#39;</strong>,<br>    <strong>test</strong>: /\.ts$/,<br>    <strong>loader</strong>: <strong>&#39;istanbul-instrumenter-loader&#39;</strong>,<br>    <strong>include</strong>: helpers.<em>root</em>(<strong>&#39;src&#39;</strong>, <strong>&#39;app&#39;</strong>),<br>    <strong>exclude</strong>: /(node_modules|app\\spec)/,<br>}</pre><p>include is the important attribute where you let istanbul-instumenter-loader all your app files reside in, this helps istanbul-instumenter-loader to go through each file and form the percentage of the file that came under Coverage.</p><p>The above-mentioned change is available on branch step-2</p><p><a href="https://github.com/HAL90012017/AngularUnitTestCoverage/tree/step-3"><em>Step-2-Git-hub-branch</em></a></p><h3><strong>Step 3: karma.conf.js</strong></h3><p>we can configure the app with karma.conf.js as shown below.</p><pre><strong>var webpackConfig </strong>= <strong><em>require</em></strong>(<strong>&#39;./webpack.test&#39;</strong>);</pre><pre><em>module</em>.<strong>exports </strong>= <strong>function </strong>(config) {<br>  <strong>var </strong>_config = {<br>    <strong>basePath</strong>: <strong>&#39;&#39;</strong>,</pre><pre>    <strong>frameworks</strong>: [<strong>&#39;jasmine&#39;</strong>],</pre><pre>    <strong>files</strong>: [<br>      {<strong>pattern</strong>: <strong>&#39;./config/karma-test-shim.js&#39;</strong>, <strong>watched</strong>: <strong>false</strong>}<br>    ],</pre><pre>    <strong>preprocessors</strong>: {<br>      <strong>&#39;./config/karma-test-shim.js&#39;</strong>: [<strong>&#39;webpack&#39;</strong>, <strong>&#39;sourcemap&#39;</strong>]<br>    },</pre><pre>    <strong>webpack</strong>: <strong>webpackConfig</strong>,</pre><pre>    <strong>webpackMiddleware</strong>: {<br>      <strong>stats</strong>: <strong>&#39;errors-only&#39;<br>    </strong>},</pre><pre>    <strong>webpackServer</strong>: {<br>      <strong>noInfo</strong>: <strong>true<br>    </strong>},</pre><pre>    <strong>reporters</strong>: [<strong>&#39;progress&#39;</strong>, <strong>&#39;kjhtml&#39;</strong>],<br>    <strong>port</strong>: 9876,<br>    <strong>colors</strong>: <strong>true</strong>,<br>    <strong>logLevel</strong>: config.<strong>LOG_INFO</strong>,<br>    <strong>autoWatch</strong>: <strong>false</strong>,<br>    <strong>browsers</strong>: [<strong>&#39;Chrome&#39;</strong>],<br>    <strong>singleRun</strong>: <strong>true<br>  </strong>};</pre><pre>  config.set(_config);<br>};</pre><p>Adding<strong> Coverage Reporter and remapCoverageReporter </strong>will create a coverage folder with index.html which contains all the Cumulative percentage of the total file coverage and make a line change for as shown below</p><p><strong>reporters</strong>: [<strong>‘mocha’</strong>, <strong>‘coverage’</strong>, <strong>‘remap-coverage’</strong>]</p><pre><strong>coverageReporter</strong>: {<br>    <strong>type</strong>: <strong>&#39;in-memory&#39;<br></strong>},<br><br><strong>remapCoverageReporter</strong>: {<br>    <strong>&#39;text-summary&#39;</strong>: <strong>null</strong>,<br>    <strong>json</strong>: <strong>&#39;./coverage/coverage.json&#39;</strong>,<br>    <strong>html</strong>: <strong>&#39;./coverage/html&#39;<br><br></strong>},As you see we have zero unit test case at this point, but we wouldn’t like to know what is our unit test coverage for each file we have.</pre><pre><strong>reporters</strong>: [<strong>&#39;mocha&#39;</strong>, <strong>&#39;coverage&#39;</strong>, <strong>&#39;remap-coverage&#39;</strong>],</pre><p>The above-mentioned change is available on branch step-3</p><p><a href="https://github.com/HAL90012017/AngularUnitTestCoverage/tree/step-3"><em>Step-3-Git-hub-branch</em></a></p><h3><strong>Step-4: Karma-test-shim.js</strong></h3><p>Finally, we arrived at Step-4 where we tell the webpack the entry point of all project ts files with the following lines.</p><p>karma-test-shim.js, is basically a root file which encompasses all the entry point of the file that we tell the webpack to compile the files and if you find any files with .ts, Supply them to webpack.test.js</p><pre><strong>var </strong>appContext = <strong><em>require</em></strong>.context(<strong>&#39;../src/app/&#39;</strong>, <strong>true</strong>, /\.ts/);<br>appContext.keys().map(appContext);</pre><p>This is the important step and often the boilerplate karma-test-shim.js comes with below-mentioned configuration which will only generate the<strong> code coverage for files that have the corresponding spec.</strong></p><pre><strong>var </strong>appContext = <strong><em>require</em></strong>.context(<strong>&#39;../src&#39;</strong>, <strong>true</strong>, /\spec/\.ts/);<br>appContext.keys().map(appContext);</pre><p>The above-mentioned change is available on branch step-4</p><p>you will be able to see unit test coverage generated for each file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sUgOTLiCfRngP6NxgEkyMw.png" /></figure><p>Viola Done!. please let me know what you think.</p><p><a href="https://github.com/HAL90012017/AngularUnitTestCoverage/tree/step-4"><em>Step-4-Git-hub-branch</em></a></p><p><strong><em>If you like the article and found it useful please Don’t forgot to click on the clap button below</em></strong></p><p>References</p><ul><li><a href="https://angular.io/guide/webpack#conclusion">Angular Docs</a></li><li><a href="https://webpack.github.io/docs/context.html">context</a></li><li><a href="https://medium.jonasbandi.net/my-concerns-with-the-angular-cli-9002bdf36975">My Concerns with the Angular CLI</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d90b1f2ec51c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>