<p>I have been able to figure out how to get everything to work.</p>

<p>Let's start from the beginning:</p>

<p><strong>Changes to config file</strong></p>

<ol>
<li>Remove the selenium server settings (the docker container starts one on every run, and uses that automatically)</li>
<li>Add 'useAllAngular2AppRoots' otherwise the tests will all fail</li>
</ol>

<p>The resulting config file will be something like this (ignore the params section, that is just an object with additional parameters you can inject into your tests):</p>

<pre><code>// conf.js
var spec_files = "tests/*.specs.js";
exports.config = {
  framework: 'jasmine',
  specs: [spec_files],
  useAllAngular2AppRoots: true,
  multiCapabilities: [{
    browserName: 'chrome'
  }],
  restartBrowserBetweenTests: true,
  params: {
    sleepTime: 0
  }
}
</code></pre>

<p><strong>Setting up the build step in teamcity</strong></p>

<p>Usually when I want to run a build step I do it in a docker container, and execute command line steps inside that container.</p>

<p>To get this to run I could not do this, as we need to inject a few parameters at the end of the run command, so you need to create a docker command, looking like this:</p>

<p><a href="https://i.sstatic.net/7tpa4.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/7tpa4.png" alt="enter image description here"></a></p>

CC BY-SA 4.0
2019-06-15T18:48:46.317Z
2019-06-15T18:48:46.317Z
Miguel Mesquita Alfaiate
<p>I have a project for which I am using Teamcity to automate deployment, and I would also like to automate testing.</p>

<p>It is an angular frontend, and we have some protractor tests.</p>

<p>I would like to run these tests as one of the steps in our build configuration.</p>

<p>I would like to have these tests run inside a docker container instead of the teamcity agent.</p>

<p>I am able to run other steps using docker containers, so I have teamcity and docker working as expected.</p>

<p>My main problem here is being able to run this within the docker container. I would like to have a container that would be able to run without having to rely on external containers, however it seems that the containers I have found and tried using rely on an external selenium instance. Either I am misunderstanding how this should run, or I would like a self contained container to run the tests and drop dead afterwards.</p>

<p>Bear in mind that these tests can be run locally in our development workstations, with selenium and protractor running locally. I would like to achieve the same through a docker container, without that container having to rely on an external selenium server instance.</p>

<p>I have tried the following docker containers:</p>

<ul>
<li><a href="https://hub.docker.com/r/caltha/protractor/" rel="nofollow noreferrer">https://hub.docker.com/r/caltha/protractor/</a></li>
<li><a href="https://hub.docker.com/r/webnicer/protractor-headless/" rel="nofollow noreferrer">https://hub.docker.com/r/webnicer/protractor-headless/</a></li>
</ul>

<p>When I try to run the tests, they both complain selenium server could not be found.</p>

<p>This is my protractor configuration file:</p>

<pre><code>// conf.js
var spec_files = "tests/*.specs.js";
exports.config = {
  framework: 'jasmine',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: [spec_files],
  multiCapabilities: [{
    browserName: 'chrome'
  }],
  baseUrl: 'test',
  restartBrowserBetweenTests: true
}
</code></pre>

<p>The baseUrl parameter is fed into protractor with the following command:</p>

<pre><code>protractor conf.js --baseUrl="http://[Replaced with Environment domain name]:8080"
</code></pre>

<p>What am I missing here?</p>

<docker><testing><teamcity>
Running Protractor tests in docker through teamcity
Miguel Mesquita Alfaiate
# Running Protractor tests in docker through teamcity

(Asked by: username_0 on 2019-06-15)

I have a project for which I am using Teamcity to automate deployment, and I would also like to automate testing.
It is an angular frontend, and we have some protractor tests.
I would like to run these tests as one of the steps in our build configuration.
I would like to have these tests run inside a docker container instead of the teamcity agent.
I am able to run other steps using docker containers, so I have teamcity and docker working as expected.
My main problem here is being able to run this within the docker container. I would like to have a container that would be able to run without having to rely on external containers, however it seems that the containers I have found and tried using rely on an external selenium instance. Either I am misunderstanding how this should run, or I would like a self contained container to run the tests and drop dead afterwards.
Bear in mind that these tests can be run locally in our development workstations, with selenium and protractor running locally. I would like to achieve the same through a docker container, without that container having to rely on an external selenium server instance.
I have tried the following docker containers:

https://hub.docker.com/r/caltha/protractor/
https://hub.docker.com/r/webnicer/protractor-headless/

When I try to run the tests, they both complain selenium server could not be found.
This is my protractor configuration file:
// conf.js
var spec_files = "tests/*.specs.js";
exports.config = {
  framework: 'jasmine',
  seleniumAddress: 'http://localhost:4444/wd/hub',
  specs: [spec_files],
  multiCapabilities: [{
    browserName: 'chrome'
  }],
  baseUrl: 'test',
  restartBrowserBetweenTests: true
}

The baseUrl parameter is fed into protractor with the following command:
protractor conf.js --baseUrl="http://[Replaced with Environment domain name]:8080"

What am I missing here?

**Tags:** docker, testing, teamcity


---

## 1 answers

### Answer by username_0 on 2019-06-15. Score: 0 | Accepted answer

I have been able to figure out how to get everything to work.
Let's start from the beginning:
Changes to config file

Remove the selenium server settings (the docker container starts one on every run, and uses that automatically)
Add 'useAllAngular2AppRoots' otherwise the tests will all fail

The resulting config file will be something like this (ignore the params section, that is just an object with additional parameters you can inject into your tests):
// conf.js
var spec_files = "tests/*.specs.js";
exports.config = {
  framework: 'jasmine',
  specs: [spec_files],
  useAllAngular2AppRoots: true,
  multiCapabilities: [{
    browserName: 'chrome'
  }],
  restartBrowserBetweenTests: true,
  params: {
    sleepTime: 0
  }
}

Setting up the build step in teamcity
Usually when I want to run a build step I do it in a docker container, and execute command line steps inside that container.
To get this to run I could not do this, as we need to inject a few parameters at the end of the run command, so you need to create a docker command, looking like this:


---

