Coder Social home page Coder Social logo

berzerk-interactive / docker-protractor-headless Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jciolek/docker-protractor-headless

0.0 2.0 0.0 4 KB

Protractor end to end testing for AngularJS - dockerised and headless with real Chrome.

Shell 100.00%

docker-protractor-headless's Introduction

Docker image of Protractor with headless Chrome

Protractor end to end testing for AngularJS - dockerised with headless real Chrome.

Why headless Chrome?

PhantomJS is discouraged by Protractor creators and for a good reason. It's basically a bag of problems.

What is headless Chrome anyway?

To be perfectly honest - it is a real chrome running on xvfb. Therefore you have every confidence that the tests are run on the real thing.

Usage

docker run -it --privileged --rm --net=host -v /dev/shm:/dev/shm -v $(pwd):/protractor webnicer/protractor-headless [protractor options]

This will run protractor in your current directory, so you should run it in your tests root directory. It is useful to create a script, for example /usr/local/bin/protractor.sh such as this:

#!/bin/bash

docker run -it --privileged --rm --net=host -v /dev/shm:/dev/shm -v $(pwd):/protractor webnicer/protractor-headless $@

The script will allow you to run dockerised protractor like so:

protractor.sh [protractor options]

Why mapping /dev/shm?

Docker has hardcoded value of 64MB for /dev/shm. Because of that you can encounter an error session deleted becasue of page crash on memory intensive pages. The easiest way to mitigate that problem is share /dev/shm with the host.

This needs to be done till docker build gets the option --shm-size.

Why --privileged?

Chrome uses sandboxing, therefore if you try and run Chrome within a non-privileged container you will receive the following message:

"Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted".

The --privileged flag gives the container almost the same privileges to the host machine resources as other processes running outside the container, which is required for the sandboxing to run smoothly.

Why --net=host?

This options is required only if the dockerised Protractor is run against localhost on the host. Imagine this sscenario: you run an http test server on your local machine, let's say on port 8000. You type in your browser http://localhost:8000 and everything goes smoothly. Then you want to run the dockerised Protractor against the same localhost:8000. If you don't use --net=host the container will receive the bridged interface and its own loopback and so the localhost within the container will refer to the container itself. Using --net=host you allow the container to share host's network stack and properly refer to the host when Protractor is run against localhost.

docker-protractor-headless's People

Contributors

jciolek avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.