I don't know how to run a selenium server with my NodeJS application, whose files are located in the ./bundle
folder of the custom e2e:latest
docker image.
I think I have to add the selenium server and webdriver chrome into the Dockerfile for the e2e:latest
image, don't I?
This is what I have done so far:
I've created a java:8-jre based docker image with NodeJS and nightwatchJS:
Dockerfile
FROM java:8-jre ## Node.js setup RUN curl -sL https://deb.nodesource.com/setup_4.x | bash - RUN apt-get install -y nodejs ## Nightwatch RUN npm install -g nightwatch
This image is then used for the test:
gitlab-ci.yml
build: stage: build tags: - deploy script: - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY - meteor npm install --production - meteor build $PACKAGE_PATH --directory # Maybe something like...? - docker build -t $CI_REGISTRY_IMAGE:e2e . nightwatch: image: e2e:latest stage: e2e tags: - e2e before_script: - cd ./bundle script: - nightwatch
The configuration looks like this:
nightwatch.conf.js
module.exports = { 'src_folders' : ['test/e2e'], 'output_folder' : 'reports', 'custom_commands_path' : '', 'custom_assertions_path': '', 'page_objects_path' : '', 'globals_path' : '', 'test_runner' : { 'type' : 'mocha', 'options': { 'ui' : 'bdd', 'reporter': 'list' } }, 'selenium': { 'start_process': false, 'server_path' : '', 'log_path' : '', 'host' : '127.0.0.1', 'port' : 4444, 'cli_args' : { 'webdriver.chrome.driver': './bin/chromedriver' } }, 'test_settings': { 'default': { 'launch_url' : 'http://localhost', 'selenium_port': 4444, 'selenium_host': 'localhost', 'silent' : true, 'screenshots' : { 'enabled': true, 'path' : 'reports/error-screenshots' }, 'desiredCapabilities': { 'browserName' : 'chrome', 'javascriptEnabled': true, 'acceptSslCerts' : true } }, 'chrome': { 'desiredCapabilities': { 'browserName' : 'chrome', 'javascriptEnabled': true, 'acceptSslCerts' : true } } } }
1 Answers
Answers 1
Not sure whether this is suitable for Gitlab CI but take a look at Selenoid project. This is a small (6 Mb) binary that launches browsers in separate Docker containers or by starting Webdriver process directly. So if container approach is not suitable for your needs try to pack Selenoid + e.g. Chromedriver + Chrome to the same container with Node.js. No need to install Java when using Selenoid.
0 comments:
Post a Comment