Nightwatch: [contribution] Docker + Nightwatch + Chromedriver + Screen recording support

Created on 13 Nov 2016  路  10Comments  路  Source: nightwatchjs/nightwatch

Hi,
first, thanks to @beatfactor and all the Nightwatch.js contributors. This is an excellent software that makes writing reliable e2e tests easy and maintainable.

I'd like to share a collection of Docker images and one NodeJs library, that we use to integrate Nightwatch.js in our dockerized Continuous Integration environment:

The setup is as easy as this docker-compose.yml file, this nightwatch.json file and this Nightwatch.js globals file.

Running tests has Docker (+ Docker Compose) as the only requirement (no Java, NodeJS or any other runtime environment required on the test machine) and is done with a simple Docker Compose command:

docker-compose run --rm nightwatch

This runs the specified Nightwatch.js tests against the current version of Chromium.
Chromium runs in a separate Docker container with Chromedriver, (optional) VNC debugging support and an exposed Xfvb server.

The setup automatically creates screen recordings (MP4 video files via FFMPEG x11grab) of individual test modules and keeps those with failing test cases.

The whole setup doesn't require any Java Runtime Environment in the Docker containers and therefore has much smaller (< 50%) Docker image sizes than the official Docker Selenium setup.
image. More than half the image size is due to the inclusion of ffmpeg, which is required for the screen recording capabilities:

REPOSITORY                         TAG      IMAGE ID       CREATED        SIZE
blueimp/nightwatch                 latest   98e69f595621   13 hours ago   76.4 MB
blueimp/chromedriver               latest   868ca3dc1f7e   17 hours ago   391.5 MB
selenium/standalone-chrome-debug   latest   df941c594b0a   3 weeks ago    865.3 MB

Most helpful comment

Thanks for this, but the Mailing List is the appropriate place for discussions and will benefit more from having this posted there. The GitHub Issues list is only meant for submitting bugs and feature requests.

All 10 comments

Thanks for this, but the Mailing List is the appropriate place for discussions and will benefit more from having this posted there. The GitHub Issues list is only meant for submitting bugs and feature requests.

Understood.
I think the Wiki would be the best place for this, but I was not sure about the procedure to add something there or if it would be accepted.

Hey I am new to docker can you please give some steps for using this image
if i do docker pull blueimp/nightwatch and then docker run -it blueimp/nightwatch
I am getting below error
There was an error while starting the test runner:

Error: Cannot read source folder: /home/node/examples/tests
at /usr/lib/node_modules/nightwatch/lib/runner/run.js:200:21
at /usr/lib/node_modules/nightwatch/lib/runner/walk.js:97:18
at FSReqWrap.oncomplete (fs.js:82:15)

Sorry if it is irrelevant question but as i am new to this finding difficult to get this going.

Thanks in Advance!

The easiest way to set this up is to clone the repo here and first run docker-compose run --rm nightwatch to see if it works for you (hint: One of the tests is set to fail on purpose for video record testing).
Next you can replace the config in the test folder with your own implementation.

Hey Thanks for your reply it means a lot to me.
When i have cloned your project the test are running fine
but when i am trying it for mine i am getting

There was an error while starting the test runner:

Error: Cannot read source folder: /home/node/examples/tests
at /usr/lib/node_modules/nightwatch/lib/runner/run.js:200:21
at /usr/lib/node_modules/nightwatch/lib/runner/walk.js:97:18
at FSReqWrap.oncomplete (fs.js:82:15)

Steps i followed
copy docker,docker-compose,entrypoint.sh and wait-for.sh in my project
copied nightwatch.json in my test and changed the configuration then
ran docker-compose run --rm nightwatch
and got the above error.
so not able to figure out from where this /home/node/examples/tests is coming from

#

Nightwatch.js Dockerfile

#

Just use this as a docker file
FROM alpine:3.4

MAINTAINER Sebastian Tschan mail@blueimp.net

RUN apk --no-cache add \
# Install tini, a tiny but valid init for containers:
tini \
# Install NodeJS:
nodejs-lts \
# Install ffmpeg for video recording:
ffmpeg \
&& npm install -g \
# Install Nightwatch.js:
#nightwatch@'<1.0' \
nightwatch \
# Clean up obsolete files:
&& rm -rf \
/tmp/* \
/root/.npm

RUN adduser -D -u 1000 node

USER node
WORKDIR /home/node
COPY wait-for.sh /usr/local/bin/wait-for.sh
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
COPY ./tests/ /home/node

CMD sh /usr/local/bin/entrypoint.sh

Also in Docker compose file
nightwatch:
image: blueimp/nightwatch:0.9
depends_on:
- chromedriver
- app
environment:
- WAIT_FOR_HOSTS=app:80 chromedriver:4444 chromedriver:6060
volumes:
- ./test:/home/node/examples

hi @blueimp it is a great framework, I use it and it works. awesome.
but, I was wondering how to include the video attachment into report *.json, since I would like to add it to my html report.
I did some research, but still found nothing.

Does anyone have an update on this? The blueimp/nightwatch repository appears to have been deprecated and the document links are broken. @blueimp

@brendantschuy I can't provide any support, but you can check out the latest version of my NightwatchJS Docker setup before the deprecation via the previous commit ID:
https://github.com/blueimp/nightwatch/tree/8572509f6dbc7ae0cc378f490a60cfdb2c606313

Was this page helpful?
0 / 5 - 0 ratings

Related issues

antogyn picture antogyn  路  4Comments

sgleonardoopitz picture sgleonardoopitz  路  3Comments

Pieras2 picture Pieras2  路  3Comments

aking1012 picture aking1012  路  4Comments

dakebl picture dakebl  路  4Comments