Closed DanielDwyer closed 5 years ago
Hi @DanielDwyer,
there's three different options that come to my mind:
you can add additional dependencies to the Dockerfile as long as you maintain your fork of the docker image, e.g. on your own repo on Docker hub.
To quickly test changes to the Dockerfile without having to change the image name, you can build the blueimp/wdio
image locally:
docker build -t blueimp/wdio .
You could also use blueimp/wdio
as base image and only add the additional dependencies, e.g. with the following Dockerfile:
FROM blueimp/wdio
RUN npm install -g \
request-promise@^4.2.4 \
# Clean up obsolete files:
&& rm -rf \
/tmp/* \
/root/.npm
An alternative way that doesn't require you to to build new Docker images is installing node_modules
on your host machine.
To do so, temporarily remove the read_only: true
property from the wdio
container and change its volumes definition to the single .:/opt
host mount, with the following result:
wdio:
image: blueimp/wdio
init: true
tmpfs:
- /tmp
- /home/wdio/.android
environment:
- WAIT_FOR_HOSTS=
chromedriver:4444
geckodriver:4444
example:8080
- WINDOWS_HOST
- ANDROID_SERIAL
volumes:
- .:/opt
depends_on:
- chromedriver
- geckodriver
- example
Next, simply run npm
inside of the docker container:
docker-compose run --rm --entrypoint npm wdio install request-promise
This will install request-promise
and its dependencies into a local node_modules folder, which will be picked up by WebdriverIO.
Now if you ask me what is the recommended way, I'd say:
node_modules
for testing something locally.
Greetings, this is more of a question than an issue (sorry if this is the incorrect location to ask). Let's say I wanted to add a node package manager module, such as request-promise, to be available when running tests in Firefox. How would I got about doing that?
I have tried adding the module to the list of modules to be installed globally, and require it in the test file (const rp = require('request-promise');), but then when I run tests in Firefox, I get the error: Cannot find module 'request-promise'.
Thanks in advance.