<?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 Prince Green on Medium]]></title>
        <description><![CDATA[Stories by Prince Green on Medium]]></description>
        <link>https://medium.com/@getprabuk?source=rss-4882131d0b16------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3UOQnZZhwVmBXPXv.</url>
            <title>Stories by Prince Green on Medium</title>
            <link>https://medium.com/@getprabuk?source=rss-4882131d0b16------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 09:04:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@getprabuk/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[Angular 6 + Travis CI with Headless Chrome]]></title>
            <link>https://levelup.gitconnected.com/angular-6-travis-ci-with-headless-chrome-58fab1b394e1?source=rss-4882131d0b16------2</link>
            <guid isPermaLink="false">https://medium.com/p/58fab1b394e1</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[headless-chrome]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <dc:creator><![CDATA[Prince Green]]></dc:creator>
            <pubDate>Wed, 16 Jan 2019 12:54:51 GMT</pubDate>
            <atom:updated>2019-01-18T12:02:08.784Z</atom:updated>
            <content:encoded><![CDATA[<h4>Enable CI/CD and automated testing of Angular apps using Travis CI</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n0BsjrlVEkj57j7v13j92A.png" /></figure><p>Testing plays a major role in application development, and automated testing empowers developers to be more productive and ship tested features.</p><p>Angular by default comes with <a href="https://jasmine.github.io/">Jasmine test framework</a> and it automatically generates spec files when generating a schematic with Angular CLI</p><pre>&gt; ng generate &lt;schematic goes here&gt;</pre><p>And setting up an automated pipeline to test our code once it gets pushed goes a long in way in helping our code function better. In this article, I will show how to set up a CI/CD pipeline for an angular application using <a href="https://travis-ci.org/">Travis</a>.</p><h4>Setting up your project</h4><p>First we create our project using <a href="https://github.com/angular/angular-cli/wiki">Angular CLI</a></p><pre>ng new angular-with-ci-cd</pre><p>Once we generate the project using angular-cli we will get a default package.json with scripts that looks like this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbcafb8ad2cb5a3081d86fc900f68aae/href">https://medium.com/media/fbcafb8ad2cb5a3081d86fc900f68aae/href</a></iframe><p>Now you can run the following in your local: <br>1. Lint checks- &gt; ng lint<br>2. Unit tests -&gt; ng test<br>3. End to end tests -&gt; ng e2e</p><h4><strong>Continuous Integration(CI)</strong></h4><p>Now we need to configure our CI setup using <a href="https://travis-ci.org/">Travis</a>. Add a .travis.yml file to the root repository with the below content. In most cases, this is all we <a href="https://medium.com/@getprabuk/58fab1b394e1#55d5">need¹</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80ffa0c6f1656b768be562b7dad28953/href">https://medium.com/media/80ffa0c6f1656b768be562b7dad28953/href</a></iframe><p>But when we push our code, all is not well with our CI even though running the same tests in our local resolved correctly.</p><h4><strong>Fixing Unit Tests</strong></h4><p>The problem with running unit tests this way in CI are:</p><ol><li>It runs in <a href="https://medium.com/@getprabuk/58fab1b394e1#5a1f">watch mode</a>² by default</li><li>It uses a normal chrome browser to run the tests instead of a <a href="https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md">headless one</a>.</li></ol><p>This can be mitigated simply by turning off the watch mode and using a headless browser as configurations while running unit tests. We can achieve this by passing command line options to test</p><pre> ng test -watch false -browsers ChromeHeadless</pre><h4><strong>Fixing E2E Tests</strong></h4><p>When running E2E tests in CI using ng e2e we were greeted with an error unknown error: Chrome failed to start: exited abnormally. This is because we are again trying to use a normal browser instead of headless one. <br>This can be fixed by configuring <a href="http://www.protractortest.org/#/">Protractor</a> to use headless browser by modifying the capabilities option in our E2E tests configuration file e2e/protractor.conf.js.</p><p>But doing so will make our<strong> </strong>E2E tests to <strong><em>always run in headless mode</em></strong> which is not what we wanted. We only want our CI to run in headless mode not in our local. This is a bit tricky to achieve and not as straight-forward as <a href="https://medium.com/@getprabuk/58fab1b394e1#a5c2">unit tests³</a>. To make this work, instead of modifying the original protractor config file create a copy of it (we’ll call it e2e/ci.protractor.conf.js) and modify that newly created file to include the following.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff7574949a6456cc546de4867bc14dd1/href">https://medium.com/media/ff7574949a6456cc546de4867bc14dd1/href</a></iframe><p>To use this configuration file while running in CI, use the ng e2e --protractor-config=&#39;e2e/ci.protractor.conf.js&#39; command. The script in our travis configuration file will now become:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3cea2fd51a896b2bf3af8835a7e3b3a/href">https://medium.com/media/c3cea2fd51a896b2bf3af8835a7e3b3a/href</a></iframe><p>Once we push this change we can see a <a href="https://travis-ci.org/lovubuntu/angular-with-ci-cd/builds/480298158#">green pipeline</a> in Travis.<strong> </strong>Hurray!</p><h4><strong>Refactoring Time</strong></h4><p>Instead of passing the above options via travis configuration file directly, we can move the scripts to our package.json since this will remain the same regardless of CI providers. Also, we can include one more script all_tests which runs all the tests (Lint, Unit, and E2E tests) and that can be used in pre-commit/pre-push <a href="https://medium.com/@getprabuk/58fab1b394e1#5611">hooks⁴</a>. This ensures all the code that enters the shared repository meets the standard.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e68bff4b41cf9f5a487ec1847a61a70/href">https://medium.com/media/2e68bff4b41cf9f5a487ec1847a61a70/href</a></iframe><p>Refactor the scripts of the Travis file as well with the newly created scripts</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4359e31a6b59f448b881312143b0111f/href">https://medium.com/media/4359e31a6b59f448b881312143b0111f/href</a></iframe><p>Let’s make sure that we have not broken anything in the build process with this change by pushing it to our remote. Now we wait for it to turn green… tada!!</p><figure><a href="https://travis-ci.org/lovubuntu/angular-with-ci-cd/builds/480302346"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I9VC4R-A1BGSBWJmBKrrVw.png" /></a><figcaption>Build status after refactoring our CI configuration</figcaption></figure><h4><strong>Continuous Deployment (CD)</strong></h4><p>It’s one thing to see all our tests pass but we will get a complete satisfaction when we see our changes deployed. After all, that is what we worked so hard for. And now that we have completed our CI process it is high time to deploy our changes.</p><p>I am deploying this to <a href="https://pages.github.com/"><em>github pages</em></a> but you can deploy to any of the <a href="https://docs.travis-ci.com/user/deployment/">supported providers</a> from Travis.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8ea0d26d5de19fcc242b675d72d82739/href">https://medium.com/media/8ea0d26d5de19fcc242b675d72d82739/href</a></iframe><p>Once the above gets pushed, it automatically deploys the application every time a commit is pushed to <a href="https://medium.com/@getprabuk/58fab1b394e1#de8e">master⁵</a>. The deployed application can be viewed <a href="https://lovubuntu.github.io/angular-with-ci-cd/">here</a>.</p><p>The complete code can be found in <a href="https://github.com/lovubuntu/angular-with-ci-cd">github</a>. Enjoy coding 😌</p><p><em>Footnotes:</em></p><ol><li>If you want to customize your build then you better look <a href="https://docs.travis-ci.com/user/customizing-the-build/">here</a>. <a href="https://medium.com/@getprabuk/58fab1b394e1#e53e">[*]</a></li><li>Watch mode will wait and check for any file changes and once it detects change it will rerun all the tests and <strong><em>again will wait</em></strong> for the next change. It works extremely well in development but if it happens in CI, then it will think that the tests are still running and will wait eternally. So it should be turned off there. <a href="https://medium.com/@getprabuk/58fab1b394e1#8cae">[*]</a></li><li><a href="http://www.protractortest.org/#/">Protractor</a> and ng e2e has a different set of command line arguments. <a href="https://medium.com/@getprabuk/58fab1b394e1#1ca6">[*]</a></li><li>Adding a git hook to run all_tests will prevents us from introducing a bad commit to our build. It is a nice habit to run tests manually before pushing but till you develop that habit <a href="https://githooks.com/">git hooks</a> comes in handy 😉. <a href="https://medium.com/@getprabuk/58fab1b394e1#3dc6">[*]</a></li><li>If you don’t want to deploy every time a commit gets pushed, create a separate branch (e.g prod branch) and use that as your deployment branch in travis configuration. Develop features in your master branch and once you are done with the feature merge it to production branch. This way you can control your deployment of features while still continue to test features that are yet to be deployed.<a href="https://medium.com/@getprabuk/58fab1b394e1#bf29"> [*]</a></li></ol><figure><a href="https://levelup.gitconnected.com/"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JaoZbi7tTKJ5vL7i2OAYMQ.png" /></a></figure><p><a href="https://gitconnected.com/learn/angular">Learn Angular - Best Angular Tutorials (2019) | gitconnected</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58fab1b394e1" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/angular-6-travis-ci-with-headless-chrome-58fab1b394e1">Angular 6 + Travis CI with Headless Chrome</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Local Development with SSL certificates is no longer a pain - mkcert]]></title>
            <link>https://medium.com/@getprabuk/local-development-with-ssl-certificates-is-no-longer-a-pain-mkcert-68bb32a52740?source=rss-4882131d0b16------2</link>
            <guid isPermaLink="false">https://medium.com/p/68bb32a52740</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[ssl]]></category>
            <category><![CDATA[localhost]]></category>
            <category><![CDATA[angular-6]]></category>
            <dc:creator><![CDATA[Prince Green]]></dc:creator>
            <pubDate>Tue, 08 Jan 2019 10:39:59 GMT</pubDate>
            <atom:updated>2019-01-08T10:46:14.812Z</atom:updated>
            <content:encoded><![CDATA[<p>I came across <a href="https://blog.filippo.io/mkcert-valid-https-certificates-for-localhost/">mkcert</a> recently and the author has rightly mentioned some of the issues we face during the transition from http (development) to https (production).</p><blockquote>“…more and more browser features are being made available only to secure origins, and testing with HTTP hides any mixed content issues that can break a production HTTPS website.”</blockquote><p>Of course, we can create SSL certificates for local development and some examples can be found <a href="https://medium.com/@richardr39/using-angular-cli-to-serve-over-https-locally-70dab07417c8">here</a> and <a href="https://medium.com/@rubenvermeulen/running-angular-cli-over-https-with-a-trusted-certificate-4a0d5f92747a">here</a>. But as you can see, we have to generate a self-signed certificate and then some <a href="https://medium.com/@rubenvermeulen/running-angular-cli-over-https-with-a-trusted-certificate-4a0d5f92747a#4f95">X number of steps</a> to make it work. With the advent of <a href="https://github.com/FiloSottile/mkcert">mkcert</a> that mundane work is long gone.</p><p>Once you install mkcert, all you have to do is to mention the domains that you are supporting and you are done. <br>cd into your project repo. Let’s say for example, if my domain is www.undivided.com then I would generate a certificate by</p><pre>mkcert www.undivided.com localhost 127.0.0.1</pre><p>This will create a new certificate and the key within the same folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ps46eCLNKVYfK_RmWjzcOA.png" /><figcaption>Output of mkcert</figcaption></figure><p>I’m using <a href="https://angular.io/"><em>angular</em></a><em> </em>and to run the development server in SSL mode with the generated certificates, I’ve to run the below command:</p><pre>ng serve --ssl \<br>         --ssl-cert &quot;<a href="http://www.undivided.com+2.pem/">www.undivided.com+2.pem</a>&quot; \<br>         --ssl-key &quot;<a href="http://www.undivided.com+2-key.pem/">www.undivided.com+2-key.pem</a>&quot; </pre><p>Once the server is up and running, head over to <a href="https://www.undivided.com:4200/">https://localhost:4200/</a> and you should see this :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*bi1xOAASN3_viXz6K4w1WA.png" /><figcaption>Secure localhost :)</figcaption></figure><p>And for those power users who wants to use the final domain name in their local development make an entry in the /etc/hosts file for your domain (in our case it is <a href="http://www.undivided/">www.undivided</a>.com).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d92caaf5a9b1049b4df3b60889a533d2/href">https://medium.com/media/d92caaf5a9b1049b4df3b60889a533d2/href</a></iframe><p>Now restart the angular server with the host to run it locally.</p><pre>ng serve --ssl \<br>         --ssl-cert &quot;<a href="http://www.undivided.com+2.pem/">www.undivided.com+2.pem</a>&quot; \<br>         --ssl-key &quot;<a href="http://www.undivided.com+2-key.pem/">www.undivided.com+2-key.pem</a>&quot; \<br>         <em>--host &quot;</em><a href="http://www.undivided.com/"><em>www.undivided.com</em></a><em>&quot;</em></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*IrTB-iMuFLPqJIbibAg63A.png" /><figcaption>Custom hostname with SSL in local</figcaption></figure><p>Voila! Enjoy developing in SSL :)</p><p><em>Hope you enjoyed reading this as much as I enjoyed writing it.</em> <br><em>If you think this will be of help to someone? Do not hesitate to share. If you liked it, tap the </em><strong><em>clap</em></strong><em> below so other people will see this here on Medium. Don’t forget to show some love by </em><strong><em>following the blog!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68bb32a52740" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>