End to End Testing Angular with Protractor/Selenium in Containers
Solution: Using the
docker-compose.yml below, I was able to run end-to-end testing on the Angular application.
test-app: # hack to allow selenium hub to reach app
... # nearly identical configurations as app service
Nested Problem/Solution: After setting up the selenium hub and node, the selenium service needed to reach a running Angular application. Usually, when the docker-compose’s default network takes care of this, but I needed the
depends_on: selenium-hub to ensure that the
selenium-hub service is running when I run the tests manually from within the container using it’s shell. The
depends_on setting seems to allow
app to reach
selenium-hub, but not the other way around. Adding
depends_on: app to
selenium-hub, would create a circular dependency. So the hack was to create another container that is running the identical Angular application,
test-app service, for the
selenium-hub selenium service to test against.