<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Continuous Integration | Bogdan's blog</title>
	<atom:link href="https://blog.bogdancarpean.com/category/continuous-integration/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.bogdancarpean.com</link>
	<description>Code and anything else.</description>
	<lastBuildDate>Fri, 24 Jan 2020 19:19:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>

<image>
	<url>https://blog.bogdancarpean.com/wp-content/uploads/2022/12/icons8-pencil-drawing-96.png</url>
	<title>Continuous Integration | Bogdan's blog</title>
	<link>https://blog.bogdancarpean.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to run Angular tests on CI Docker Container with Chrome</title>
		<link>https://blog.bogdancarpean.com/how-to-run-angular-tests-on-ci-docker-container-with-chrome/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-run-angular-tests-on-ci-docker-container-with-chrome</link>
					<comments>https://blog.bogdancarpean.com/how-to-run-angular-tests-on-ci-docker-container-with-chrome/#respond</comments>
		
		<dc:creator><![CDATA[Bogdan]]></dc:creator>
		<pubDate>Sat, 06 Jan 2018 05:31:33 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Continuous Integration]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[angular tests]]></category>
		<category><![CDATA[angular/cli]]></category>
		<category><![CDATA[atlassian bitbucket pipelines]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[continuous integration]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[docker]]></category>
		<category><![CDATA[node]]></category>
		<guid isPermaLink="false">http://blog.bogdancarpean.com/?p=171</guid>

					<description><![CDATA[<p>In this article, we are going to learn how to run the tests of an Angular solution generated with @angular/cli into a Docker Container without changing any of the initial configuration generated by @angular/cli. This is very important in the context of Continuous Integration workflow when you want to run your tests as you commit [&#8230;]</p>
The post <a href="https://blog.bogdancarpean.com/how-to-run-angular-tests-on-ci-docker-container-with-chrome/">How to run Angular tests on CI Docker Container with Chrome</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></description>
										<content:encoded><![CDATA[<div style="position: relative;">In this article, we are going to learn how to run the tests of an Angular solution generated with <a href="https://cli.angular.io/" target="_blank" rel="noopener noreferrer"><code>@angular/cli</code></a> into a Docker Container without changing any of the initial configuration generated by <a href="https://cli.angular.io/" target="_blank" rel="noopener noreferrer"><code>@angular/cli</code></a>. This is very important in the context of Continuous Integration workflow when you want to run your tests as you commit to the repo.</div>
<p>For this example I&#8217;m gonna use the <a href="https://bitbucket.org/product" target="_blank" rel="noopener noreferrer">Atlassian Bitbucket Pipelines</a> for continuous integration, but is not limited to it, you can use it in any other environment that is using a <a href="https://www.docker.com/" target="_blank" rel="noopener noreferrer">Docker Container</a>, like Bitbucket, to test and build your Angular app.</p>
<p>To be able to test the Angular solution generated with <a href="https://cli.angular.io/" target="_blank" rel="noopener noreferrer"><code>@angular/cli</code></a>, we need a <a href="https://www.docker.com/" target="_blank" rel="noopener noreferrer">Docker Container</a> with <a href="https://nodejs.org/en/" target="_blank" rel="noopener noreferrer">Node</a> to run <code>npm install</code> in order to install the dependencies and then we need an instance of <a href="https://www.google.com/chrome/browser/desktop/index.html" target="_blank" rel="noopener noreferrer"><code>chrome</code></a> to run the tests.</p>
<p>For this, we have two solutions. I prefer the first one in which we take the official Node Docker Container, for the time being, 6.9.4, we install the <code>chrome</code> browser, then run <code>npm install</code> to fetch the dependencies of the project, then finally run our tests.</p>
<p>For Atlassian Bitbucket Pipelines, we are going to use the following code in the commit <code>bitbucket-pipelines.yml</code> file:</p>
<pre class="EnlighterJSRAW" data-enlighter-language="ini">image: node:6.9.4

pipelines:
  default:
    - step:
        caches:
          - node
        script:
          - apt-get update; apt-get install -y gettext-base;
          - echo 'deb http://dl.google.com/linux/chrome/deb/ stable main' &gt; /etc/apt/sources.list.d/chrome.list
          - wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
          - set -x &amp;&amp; apt-get update &amp;&amp; apt-get install -y xvfb google-chrome-stable
          - wget -q -O /usr/bin/xvfb-chrome https://bitbucket.org/atlassian/docker-node-chrome-firefox/raw/ff180e2f16ea8639d4ca4a3abb0017ee23c2836c/scripts/xvfb-chrome
          - ln -sf /usr/bin/xvfb-chrome /usr/bin/google-chrome
          - chmod 755 /usr/bin/google-chrome
          - npm install
          - ./node_modules/@angular/cli/bin/ng -v
          - ./node_modules/@angular/cli/bin/ng test --watch=false</pre>
<p>Please take into consideration that this is the code for a <code>debian linux</code> machine inside the Docker Container, so you have to adapt if you have a different machine.</p>
<p>I said that this solution is my preferred one because I want to test my app against the newest <code>chrome</code> version and I achieve this by installing the latest on each commit I make.</p>
<p>The downside of this solution is that it has to fetch all the updates for the <code>linux</code> machine and install <code>chrome</code> and it will take between 2 and 3 minutes to accomplish so this can become costly if you have a time limit on your Bitbucket account.</p>
<p>The second solution is to take a container from <a href="https://hub.docker.com/" target="_blank" rel="noopener noreferrer">Docker Container Hub</a> containing already Node and Chrome and to run the code starting from <code>npm install</code>. This way you cut in half the runtime, but you are going to test against the version of <code>chrome</code> installed into the Docker Container.</p>
<p>Have fun!</p>The post <a href="https://blog.bogdancarpean.com/how-to-run-angular-tests-on-ci-docker-container-with-chrome/">How to run Angular tests on CI Docker Container with Chrome</a> first appeared on <a href="https://blog.bogdancarpean.com">Bogdan's blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://blog.bogdancarpean.com/how-to-run-angular-tests-on-ci-docker-container-with-chrome/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
