question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use with testcafe docker image

See original GitHub issue

I am curious if there is any way to include this library when running testcafe from within docker?

I have attempted to create a new docker image based off testcafe/testcafe, but ran into permissions-related issues when attempting to install testcafe-react-selectors via npm from within my new Dockerfile.

Another approach I made that I really am not entirely keen on involved essentially copying the Dockerfile from the testcafe github and adding multiple steps to basically ADD the testcafe release tar.gz, install gulp, build testcafe, copy the required directories to /opt/testcafe within the image and then finally install testcafe-react-selectors seperately. Not fun.

It’s entirely possible I’m missing something amazingly simple, but I would appreciate any advice you could give about being able to completely contain both testcafe and this library within a single-entrypoint docker image.

Thanks!

EDIT - Just to give you an example of the truly horrible hoops I jumped through…

FROM alpine:edge

RUN apk --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ add \
  nodejs nodejs-npm chromium firefox xwininfo xvfb dbus eudev ttf-freefont fluxbox

ADD https://github.com/DevExpress/testcafe/archive/v0.16.2.tar.gz /opt

RUN npm install -g gulp && \
  mkdir -p /opt/testcafe && \
  cd /opt/testcafe-0.16.2 && \
  npm install && \
  gulp build && \
  cp -r docker /opt/testcafe && \
  cp -r lib /opt/testcafe && \
  cp -r bin /opt/testcafe && \
  cp -r package.json /opt/testcafe && \
  cd /opt/testcafe && \
  npm install --production && \
  npm install testcafe-react-selectors && \
  npm cache clean && \
  rm -fr /tmp/* && \
  rm -fr /opt/testcafe-0.16.2 && \
  chmod +x /opt/testcafe/docker/testcafe-docker.sh && \
  adduser -D user

USER user
EXPOSE 1337 1338
ENTRYPOINT ["/opt/testcafe/docker/testcafe-docker.sh"]

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
remigarciacommented, Jan 31, 2019

I had to slightly edit @sobolevn solution to add the /usr/lib/node_modules to NODE_PATH. If not, I was running in the following error :

ERROR Cannot prepare tests due to an error.

Error: Cannot find module 'testcafe'
    at Object.<anonymous> (/opt/testcafe/node_modules/testcafe-react-selectors/lib/index.js:8:17)
    at Object.origExt [as .js] (/usr/lib/node_modules/testcafe/src/compiler/test-file/api-based.js:76:21)
    at Object.<anonymous> (/tests/homepage.test.js:2:1)
    at Function._compile [as _execAsModule] (/usr/lib/node_modules/testcafe/src/compiler/test-file/api-based.js:50:13)
    at ESNextTestFileCompiler._execAsModule [as compile] (/usr/lib/node_modules/testcafe/src/compiler/test-file/api-based.js:144:42)
    at compile (/usr/lib/node_modules/testcafe/src/compiler/index.js:50:42)

My resulting Dockerfile is the following :

FROM testcafe/testcafe

USER root

ENV NODE_PATH=/opt:/usr/lib/node_modules:/opt/testcafe/node_modules

# Installing custom dependencies:
RUN cd /opt/testcafe && npm install \
  testcafe-react-selectors

USER user
0reactions
Dmitry-Ostashevcommented, Jun 8, 2020

@lgriotti The cd command should change the current directory to the directory containing your package.json.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use the TestCafe Docker Image | Advanced Guides
TestCafe provides a preconfigured Docker image with Chromium and Firefox installed. Therefore, you can avoid manual installation of browsers and the testing ...
Read more >
testcafe/testcafe - Docker Image - Docker Hub
A Node.js tool to automate end-to-end web testing. ... This is the repository of the official TestCafe Docker image. Learn more about using...
Read more >
Get a Jump-Start on Your Testing With TestCafe and Docker
TestCafe keeps the Docker image up to date every time there's a new release. You can also use the images to test out...
Read more >
Chapter 13 - TestCafe Docker Image
Transcripted Summary. In this chapter, we will be talking about using the TestCafe Docker Image and how we can run our tests inside...
Read more >
TESTCAFE DOCKER Image - YouTube - YouTube
How to download and install Docker: https://docs.docker.com/docker-for-windows/install/ User TestCafe Docker Image : ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found