<?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 ALQH on Medium]]></title>
        <description><![CDATA[Stories by ALQH on Medium]]></description>
        <link>https://medium.com/@angielohqh?source=rss-2604ff53d42a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*tf5WOLSB3rbPlrOs.</url>
            <title>Stories by ALQH on Medium</title>
            <link>https://medium.com/@angielohqh?source=rss-2604ff53d42a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 19:26:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@angielohqh/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[GO : Function Types are Bridge to Interfaces]]></title>
            <link>https://medium.com/@angielohqh/go-function-types-are-bridge-to-interfaces-a0a8f52cb82f?source=rss-2604ff53d42a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0a8f52cb82f</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[ALQH]]></dc:creator>
            <pubDate>Tue, 31 May 2022 08:19:04 GMT</pubDate>
            <atom:updated>2022-05-31T08:19:19.113Z</atom:updated>
            <content:encoded><![CDATA[<p>In Chapter 7 of <a href="https://www.oreilly.com/library/view/learning-go/9781492077206/">Learning Go</a>, it talks about “function types are bridge to interface”, with a very short mention of GO’s very own http module as an example.</p><p>In this article, I’ll attempt to expand on that point with end-to-end illustration of GO’s http module.</p><p>In a nutshell, the bridge allows the ability to either pass in a type that meets the interface, or a function.</p><p>Let’s start by looking at the interface in question. The <em>Handler</em> interface defines how it can process a HTTP server request.</p><pre>// net/http server.go</pre><pre>type Handler interface {<br>    ServeHTTP(ResponseWriter, *Request)<br>}</pre><p>An example of a handler that implements this interface is the file handler:</p><pre>// net/http fs.go</pre><pre>type filehandler struct {<br>   root Filesystem<br>}</pre><pre>func (f *filehandler) ServeHTTP(w ResponseWriter, r *Request) {<br>    ...<br>}</pre><pre>func FileServer(root Filesystem) Handler {<br>    return &amp;filehandler{root}<br>}</pre><p>This interface is used as the parameter to register a handler for a route in GO.</p><pre>// net/http server.go</pre><pre>func Handle(pattern string, handler Handler) {<br>    DefaultServeMux.Handle(pattern, handler)<br>}</pre><p>In a GO web app, registering a route thus looks like the following:</p><pre>package main</pre><pre>import (<br>    &quot;net/http&quot;<br>)</pre><pre>func main() {<br>    http.Handle(&quot;/assets&quot;, http.FileServer(http.Dir(&quot;public&quot;)))<br>}</pre><p>But sometimes, you don’t want to create a type, just to implement <em>ServeHTTP </em>method. For example, to add an endpoint to for <em>/hello, </em>using this approach, we have to write it as:</p><pre>type HelloHandler struct {}</pre><pre>func (h *HelloHandler) ServeHTTP(w ResponseWriter, r *Request) {<br>    w.Write(&quot;Hello World&quot;)<br>}</pre><pre>func main() {<br>    http.Handle(&quot;/hello&quot;, &amp;HelloHandler{})<br>}</pre><p>That’s a lot more than just somehow registering the following function straight as a handler.</p><pre>func SayHello(w ResponseWriter, r *Request) {<br>   w.Write(&quot;Hello World&quot;)<br>}</pre><p>This is where <em>HandlerFunc</em> comes in. It creates a bridge between ability to use a function as a handler and the <em>Handler </em>interface.</p><p>Before we go into <em>HandlerFunc</em>, its worth to note that in GO, any type, including function type can have methods. In this case, <em>HandlerFunc </em>has a method <em>ServeHTTP</em> which means <em>HandlerFunc</em> satisfies the requirements of the <em>Handler </em>interface</p><pre>// net/http server.go<br><br>type HandlerFunc func(ResponseWriter, *Request)</pre><pre>func (f HandlerFunc) ServeHTTP(w ResponseWriter, r *Request) {<br>    f(w, r)<br>}</pre><p>GO http server has a method to register a path with a function as the handler</p><pre>// net/http server.go</pre><pre>func HandleFunc(pattern string, handler func(w ResponseWriter, r *Request)) {<br>    DefaultServeMux.HandleFunc(pattern, handler)<br>}</pre><p>Within the serve mux, it then type convert the passed in handler function into a <em>HandlerFunc, </em>which satisfies the <em>Handler</em> interface!</p><pre>func (mux *ServeMux) HandleFunc(pattern string, handler func(w ResponseWriter, r *Request)) {<br>   if handler == nil {<br>       panic(&quot;http: nil handler&quot;)<br>   }<br>   mux.Handle(pattern, HandlerFunc(handler))<br>}</pre><p>Now, we can register a function to a route by:</p><pre>func main() {<br>    http.Handle(&quot;/assets&quot;, http.FileServer(http.Dir(&quot;public&quot;)))   <br>    http.HandleFunc(&quot;/hello&quot;, SayHello)<br>}</pre><pre>func SayHello(w ResponseWriter, r *Request) {<br>   w.Write(&quot;Hello World&quot;)<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0a8f52cb82f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Implications of Java Stream Lazy Seeking and Optimisation]]></title>
            <link>https://medium.com/@angielohqh/the-implications-of-java-stream-lazy-seeking-and-optimisation-519fcf785bb3?source=rss-2604ff53d42a------2</link>
            <guid isPermaLink="false">https://medium.com/p/519fcf785bb3</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[javastreams]]></category>
            <dc:creator><![CDATA[ALQH]]></dc:creator>
            <pubDate>Sun, 17 Oct 2021 04:05:30 GMT</pubDate>
            <atom:updated>2021-10-17T04:05:30.650Z</atom:updated>
            <content:encoded><![CDATA[<p>Java Streams are seeking for opportunities to optimise. This is done by deferring the execution of the stream until when the results of the stream is needed (terminal operation). A stream chain consists of intermediary operations like <em>filter</em> and <em>map </em>(ones that returns a stream that you can further chain onto), while terminal operations are like <em>collect </em>and <em>findFirst</em>.</p><p>This has implications and if not understood, can lead to incorrect usage that surfaces itself in certain scenarios. In this article, I will draw on two examples that occurrences that really happened.</p><p>Let’s see if you can spot the issue!</p><h3>Example 1: Trying to update a value for matching items</h3><p>In trying to perform bulk subscription of a topic to users, this code snippet retrieved the topic id and a list of users, and tries to add the topic to the user’s subscription list.</p><pre>allUsers.stream()<br>  .filter(user -&gt; listOfUserIds.contain(user.getId))<br>  .peek(user -&gt; user.getSubscriptions().add(topicName))<br>  .findFirst();</pre><p>Symptoms: Some of the users were not subscribed to the topic, but there was a user that was subscribed successfully.</p><p>Can you describe why?</p><p>Let’s peel back and look at the chain as follows:</p><figure><img alt="Stream chain — filter and peek as intermediate operation, find first as terminal operation" src="https://cdn-images-1.medium.com/max/1024/1*5y9PXmJa5QFommPjR0i9rA.png" /></figure><p>The terminal operation in this chain is <em>findFirst</em>, and because streams are lazy seeking, it short circuit the stream when one result is retrieved (since we are only interested in the first item). Therefore, it is not guaranteed that all the items in that chain that matches the filter criteria has a chance to be peeked! In our scenario, only one user manage to add that topic to their subscription list!</p><p>Argument of whether or not to use <em>peek</em> or not to modify state aside, probably the intention of the writer of the code on using <em>findFirst</em> was because they needed to terminate the stream operation for it to compile / work and perhaps not knowing the implications behind that. Maybe they intended to use the <em>foreach</em> terminal operation instead (but was not aware of it?)</p><pre>// fixed<br>allUsers.stream()<br>  .filter(user -&gt; listOfUserIds.contain(user.getId))<br>  .forEach(user -&gt; user.getSubscriptions().add(topicName));</pre><h3>Example 2: Sorting nullable values</h3><p>Sometimes, we want to sort values and streams facilitate this operation. In this case, the writer aim to sort the subscription period by the end date, with <em>null</em> being the value if there is no end date to the subscription.</p><pre>allUsers.getSubscriptions().stream()<br>   .sorted(Comparator.comparing(Subscription::getEndDate))<br>   .findFirst().orElse(null);</pre><p>Symptom: All users have ongoing subscription (ie no end date) but only for some users, <em>Comparator.comparing</em> throws <em>Nullpointer</em> when trying to retrieve the subscription that ended earliest.</p><p>The immediate question was within the <em>Comparator.comparing </em>jdk documentation, it states that it will throw <em>Nullpointer</em> if the value is null (not conditional to anything), so why does it throw error only on some users and not others when all of them have subscriptions that are ongoing?</p><p>Can you describe why?</p><p>Because streams are lazy and seeking for ways to optimise, for a list of data that has only one item, <em>sorted</em> can be skipped, because there is no need to sort anything. Therefore, <em>Comparator.comparing </em>doesn’t need to be performed. Only when the user has multiple subscriptions, that the <em>sort</em> need to be performed, and in this case, it throws the <em>Nullpointer</em> exception.</p><p>If you’re not careful, and the test cases are simple, you can risk that false sense of security that your code has no problem.</p><h3>Parting Words</h3><p>Be aware that streams are lazy and seeking opportunity for optimisation. If you stick to the guidelines of writing streams on state modification, parallelism and ensuring the correctness of each chain, you should hopefully be able to avoid mishaps like this.</p><h3>References</h3><ul><li><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/stream/package-summary.html">JDK Java Streams documentation</a></li><li><a href="https://learning.oreilly.com/library/view/java-8-in/9781617291999/kindle_split_015.html">Chapter 4: Introducing Streams — Java 8 in Action</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=519fcf785bb3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Terraform: Dynamically look up VPC requirements for AWS Glue Connection]]></title>
            <link>https://medium.com/@angielohqh/terraform-dynamically-look-up-vpc-requirements-for-aws-glue-connection-298662d10d89?source=rss-2604ff53d42a------2</link>
            <guid isPermaLink="false">https://medium.com/p/298662d10d89</guid>
            <category><![CDATA[aws-glue-connection]]></category>
            <category><![CDATA[aws-glue]]></category>
            <category><![CDATA[terraform]]></category>
            <dc:creator><![CDATA[ALQH]]></dc:creator>
            <pubDate>Thu, 27 May 2021 05:24:39 GMT</pubDate>
            <atom:updated>2021-05-27T05:24:39.213Z</atom:updated>
            <content:encoded><![CDATA[<p>Been playing around with AWS Glue recently to pull file from AWS S3 and put it into AWS RDS. I think a good example of AWS Glue is <a href="https://github.com/cohuebn/cory-learns-glue">https://github.com/cohuebn/cory-learns-glue</a> which have some nifty examples for tests and terraforms.</p><p>Anyway, to connect to AWS RDS is that AWS Glue job will need to be able to connect into the VPC of the database, one of the things it needs is the appropriate IAM policies (especially for those about VPC and network interfaces) and the other is the vpc requirements.</p><p>In terraform, if my database is part of my deployed solution, then I can’t hardcode that VPC requirements. But Terraform has quite a bit of tools that will allow you to figure it out!</p><p>First I fetch the database to get the availability zone to use.</p><pre>data &quot;aws_db_instance&quot; &quot;my_database&quot; {<br>   db_instance_identifier = &quot;my-database-name&quot;<br>}</pre><p>Then I query the database’s subnet group and subnet ids in the subnet group. Note that I use the Terraform’s for_each which will mean that <em>data.aws_subnet.my_database_subnets</em> becomes a list.</p><pre>data &quot;aws_db_subnet_group&quot; &quot;my_database_subnet_group&quot; {<br>   name = data.aws_db_instance.my_database.db_subnet_group<br>}</pre><pre>data &quot;aws_subnet&quot; &quot;my_database_subnets&quot; {<br>   for_each = data.aws_db_subnet_group.my_database_subnet_group.subnet_ids<br>   id       = each.value<br>}</pre><p>Finally, when I create my AWS Glue Connection, I loop through the list of subnets and using <em>filter</em> in the for loop, I match by the availability zone of the database, then select the first one.</p><pre>resource &quot;aws_glue_connection&quot; &quot;glue_connection&quot; {<br>  connection_properties = {<br>   # All your connection properties here<br>  }<br><br>  name = &quot;my-glue-connection&quot;<br><br>  physical_connection_requirements {<br>    availability_zone      = data.aws_db_instance.my_database.availability_zone<br>    security_group_id_list = [aws_security_group.example.id]<br>    subnet_id              = [for subnet in data.aws_subnet.my_database_subnets : subnet.id if subnet.availability_zone == data.aws_db_instance.my_database.availability_zone][0]<br>  }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=298662d10d89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Merging with 3-way Vimdiff]]></title>
            <link>https://medium.com/@angielohqh/git-merging-with-3-way-vimdiff-5c59d9c62268?source=rss-2604ff53d42a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5c59d9c62268</guid>
            <category><![CDATA[vim]]></category>
            <category><![CDATA[git-config]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[vimdiff]]></category>
            <category><![CDATA[git-merge]]></category>
            <dc:creator><![CDATA[ALQH]]></dc:creator>
            <pubDate>Tue, 05 Jan 2021 01:30:47 GMT</pubDate>
            <atom:updated>2021-01-05T01:30:47.213Z</atom:updated>
            <content:encoded><![CDATA[<p>I love to use vimdiff because it is lightweight and is geared towards keyboard shortcuts that speeds up the merging process for me. However, I don’t quite particularly like the merge view that Vimdiff offers, where you have the 3 versions on the top and a “merged” view on the bottom where you pick one of the three. I much prefer the <a href="https://meldmerge.org/">Meld</a> approach where you have a left and right and the middle pane is what you want to bring in.</p><p>Essentially, what I want is:</p><p>| BASE | MERGED | REMOTE |</p><p>where</p><ul><li>LOCAL is the file currently have locally</li><li>REMOTE is the file currently from the reference that I’m trying to apply</li><li>MERGED is the final output of the merge process</li></ul><p>See the <a href="https://git-scm.com/docs/git-mergetool">Git Mergetool Documentation</a> for more info.</p><p>Drawing from the examples given in <a href="https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_external_merge_tools">Git Configuration — Customizing Git </a>, I customised my gitconfig as below:</p><pre>// ~/.gitconfig</pre><pre>[merge]<br>   tool = vimdiff<br>[difftool &quot;vimdiff&quot;]<br>    cmd = vimdiff \&quot;$LOCAL\&quot; \&quot;$REMOTE\&quot;<br>[mergetool &quot;vimdiff&quot;]<br>    cmd = vimdiff \&quot;$LOCAL\&quot; \&quot;$MERGED\&quot; \&quot;$REMOTE\&quot;</pre><p><em>Looks like I have to specify the difftool because it somewhat picks up my mergetool vimdiff configuration if I don’t.</em></p><h3>Additional Step:</h3><p>I like to go one step further to force myself to read it in detail and manually acknowledge the changes. I find that I could easily skip pass parts and not read it properly if things were done automatically for me, causing some grievances down the line when I realised and have to rebase the process. Therefore, I prefer if my “MERGED” copy does not have git’s attempt to merge the changes. Essentially, I need the “BASE” version as the start of the “MERGED”. To do so, I copied the “BASE” to “MERGED” first before launching the vimdiff:</p><pre>[mergetool &quot;vimdiff&quot;]<br>    cmd = cp \&quot;$BASE\&quot; \&quot;$MERGED\&quot; &amp;&amp; vimdiff \&quot;$LOCAL\&quot; \&quot;$MERGED\&quot; \&quot;$REMOTE\&quot;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5c59d9c62268" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cypress Setup on Gitpod.io]]></title>
            <link>https://medium.com/@angielohqh/cypress-setup-on-gitpod-io-583b0427c730?source=rss-2604ff53d42a------2</link>
            <guid isPermaLink="false">https://medium.com/p/583b0427c730</guid>
            <category><![CDATA[gitpod]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[cypressio]]></category>
            <category><![CDATA[cloud-code-workspace]]></category>
            <dc:creator><![CDATA[ALQH]]></dc:creator>
            <pubDate>Sun, 06 Sep 2020 05:19:27 GMT</pubDate>
            <atom:updated>2020-09-06T05:19:27.552Z</atom:updated>
            <content:encoded><![CDATA[<p>We will cover how to setup Cypress tests in Gitpod cloud code workspace.</p><h3>What is Gitpod?</h3><p>Cloud code workspace is gaining traction recently. They are a very convenient way to standup a code workspace with its own running environment. This enables you to quickly standup a development environment to test a branch, review a PR, play with libraries, or just to do development. You can share the workspace, or make it available to others to reproduce the same development environment. For someone who have a relatively mid-tier personal machine that is used for so many things other than development like I do, this is viable alternative because it allows me to delegate away that burden from my little machine.</p><p>Providers of this option includes <a href="https://codenvy.com/">Code Envy</a>, <a href="https://codeanywhere.com/">Code Anywhere</a>, <a href="https://github.com/features/codespaces">Github Codespace</a>, <a href="https://gitpod.io/">Gitpod</a> and <a href="https://codetasty.com/">Code Tasty</a>. Of the ones, I’ve given <a href="https://gitpod.io/">Gitpod</a> a wheel as it was one of the easiest to setup, offer a generous free tier, and comes with a nice looking IDE (or one which very closely resemble VS Code).</p><h3>What is Cypress?</h3><p><a href="https://cypress.io/">Cypress</a> enables you to write UI tests. They have tools to automate browsers, similar to the functionalities that Selenium provide, but arguably more reliable. They also have nice dashboards and you can watch the test run step by step.</p><h3>Creating New Gitpod Workspace</h3><p>First, we want to create a Gitpod workspace. Following the <a href="https://www.gitpod.io/docs/getting-started/">getting started guide</a>, copy the link of the repository you created, or an existing repository and append it to the link format as below:</p><pre>https://gitpod.io/#&lt;your repo url&gt;</pre><h3>Configuring Cypress Dependencies</h3><p>Then, we want to configure our Gitpod environment to install all the dependencies required. Gitpod allows us to specify a Dockerfile to setup our environment. Following the <a href="https://www.gitpod.io/docs/config-docker/">Gitpod Dockerfile guide</a>, we will create a <em>.gitpod.yml</em> file in the root directory and specify to use the <em>.gitpod.Dockerfile </em>as our Dockerfile.</p><p>Create a new <em>.gitpod.yml</em> and in the file add:</p><pre>image:<br>    file: .gitpod.Dockerfile</pre><p>Next, we want to add in the dependencies required by Cypress. For this, we will be using the ones given for Ubuntu on <a href="https://docs.cypress.io/guides/getting-started/installing-cypress.html#System-requirements">Cypress’s installation guide</a>. One of the dependencies will trigger the keyboard configuration, and to avoid the prompt, we will set the DEBIAN_ENVIRONMENT variable for that install instruction to <em>noninteractive</em>. For more information about this environment variable and distinguishing how it is specified, please refer to the <a href="https://serverfault.com/questions/618994/when-building-from-dockerfile-debian-ubuntu-package-install-debconf-noninteract">ServerFault answer</a> as well as <a href="https://docs.docker.com/engine/faq/#why-is-debian_frontendnoninteractive-discouraged-in-dockerfiles">Docker FAQ</a> that discourages setting the variable via ENV. It’s interesting that <a href="https://github.com/cypress-io/cypress-docker-images/blob/master/base/ubuntu19-node12.14.1/Dockerfile">cypress-base Ubuntu docker configuration</a> didn’t follow this recommendation, and hard-sets your local date time to New York….</p><p>Create a new <em>.gitpod.Dockerfile</em> and in the file add:</p><pre>FROM gitpod/workspace-full</pre><pre>RUN sudo apt-get update</pre><pre># Install Cypress-base dependencies<br>RUN sudo apt-get install -y \<br>    libgtk2.0-0 \<br>    libgtk-3-0</pre><pre>RUN sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq \<br>    libgbm-dev \<br>    libnotify-dev</pre><pre>RUN sudo apt-get install -y \<br>    libgconf-2-4 \<br>    libnss3 \<br>    libxss1</pre><pre>RUN sudo apt-get install -y \<br>    libasound2 \<br>    libxtst6 \<br>    xauth \<br>    xvfb</pre><p>Add and commit the two files. Push the changes to your repository.</p><p>To apply these changes, you will need to recreate a new workspace by following the first step above, which will setup a new Gitpod workspace with the container as specified by the <em>.gitpod.Dockerfile</em>.</p><p>You can delete this workspace as all your changes have been pushed.</p><h3>Configuring Cypress Test</h3><p>After you have initialise the npm package, add cypress as a dev dependency.</p><pre>npm install cypress --save-dev</pre><h3>Running Cypress Test</h3><p>We will create a sample test, as per the Cypress’s <a href="https://docs.cypress.io/guides/getting-started/writing-your-first-test.html#Step-4-Make-an-assertion">Writing Your First Test guide</a>.</p><p>By default, Cypress looks for test case under the <em>cypress/integration</em> folder. You can configure this in your <em>cypress.json</em> if you want it to be different. Please refer to <a href="https://docs.cypress.io/guides/references/configuration.html#Folders-Files">Folders / Files Configuration</a> for more details.</p><p>Create a new file in <em>cypress/integration/sample.spec.js. </em>We are just going to steal a sample snippet from the tutorial:</p><pre>describe(&#39;My First Test&#39;, () =&gt; {<br>    it(&#39;Gets, types and asserts&#39;, () =&gt; {        <br>        cy.visit(&#39;https://example.cypress.io&#39;)      <br>        cy.contains(&#39;type&#39;).click() </pre><pre>        // Should be on a new URL which includes &#39;/commands/actions&#39;     <br>        cy.url().should(&#39;include&#39;, &#39;/commands/actions&#39;)</pre><pre>        // Get an input, type into it and verify that the value has been updated <br>        cy.get(&#39;.action-email&#39;)<br>          .type(&#39;fake@email.com&#39;)<br>          .should(&#39;have.value&#39;, &#39;fake@email.com&#39;)   <br>    }) <br>})</pre><p>Ordinarily, you will be able to run <em>cypress open</em> to show Cypress dashboard and run see the test run step by step. However, the preview browser in Gitpod (at the time of this writing) doesn’t seem to allow extensions to be installed and the preview browser will open with message that the browser was not launched by Cypress. For more information about browsers and extension configuration for cypress, have a read of this <a href="https://github.com/cypress-io/cypress/issues/1239">Github issue</a>.</p><p>We still can run it headless, and by default, it will run with Electron headless.</p><pre>npx cypress run</pre><h3>Optional: Configuring Chrome and Firefox Headless</h3><p>You can also configure to install browsers to run cypress with Chrome and Firefox headless. Following the <a href="https://github.com/cypress-io/cypress-docker-images/tree/master/browsers">Cypress browser Docker image</a>, we add the following in the existing <em>.gitpod.Dockerfile.</em></p><pre># Install Cypress-browser dependencies</pre><pre>RUN sudo apt-get install -y \<br>    fonts-liberation \<br>    libappindicator3-1 \<br>    xdg-utils</pre><pre>ENV CHROME_VERSION 81.0.4044.113</pre><pre>RUN sudo wget -O /usr/src/google-chrome-stable_current_amd64.deb &quot;http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}-1_amd64.deb&quot;</pre><pre>RUN sudo dpkg -i /usr/src/google-chrome-stable_current_amd64.deb<br>RUN sudo apt-get install -f -y &amp;&amp; \<br>    sudo rm -f /usr/src/google-chrome-stable_current_amd64.deb<br>RUN google-chrome --version</pre><pre>RUN sudo apt-get install mplayer -y</pre><pre>ARG FIREFOX_VERSION=75.0</pre><pre>RUN sudo wget --no-verbose -O /tmp/firefox.tar.bz2 https://download-installer.cdn.mozilla.net/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/firefox-$FIREFOX_VERSION.tar.bz2</pre><pre>RUN sudo tar -C /opt -xjf /tmp/firefox.tar.bz2 \<br>    &amp;&amp; sudo rm /tmp/firefox.tar.bz2 \<br>    &amp;&amp; sudo ln -fs /opt/firefox/firefox /usr/bin/firefox</pre><pre>RUN echo  &quot; node version:    $(node -v) \n&quot; \<br>    &quot;npm version:     $(npm -v) \n&quot; \<br>    &quot;yarn version:    $(yarn -v) \n&quot; \<br>    &quot;debian version:  $(cat /etc/debian_version) \n&quot; \<br>    &quot;Chrome version:  $(google-chrome --version) \n&quot; \<br>    &quot;Firefox version: $(firefox --version) \n&quot; \<br>    &quot;git version:     $(git --version) \n&quot; \<br>    &quot;whoami:          $(whoami) \n&quot;</pre><p>After recreating your Gitpod workspace, reinstalling the npm dependencies, you can now run the test using Chrome or Firefox</p><pre>npx cypress run --browser chrome<br>npx cypress run --browser firefox</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=583b0427c730" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>