Psdet
Psdet

Reputation: 689

Container circleci/node:10.14-browsers - ERROR: euid != 0,directory /tmp/.X11-unix will not be created

I’m trying to run browser testing on CircleCi using TestCafe. I have followed this documentation. The major problem is that the chrome browser isn't able to open. CircleCi is able to successfully download the image because the spin environment is passed.

I am facing problem in the next step (Container circleci/node:11.6.0-browsers) on CircleCi which throws an error :

$ _XSERVTransmkdir: ERROR: euid != 0,directory /tmp/.X11-unix will not be created.

Job was canceled 

And later on the UI test step throws this error:

$ testcafe chrome:headless uitests/tests/* -r xunit:/tmp/test-results/res.xml -e
ERROR Was unable to open the browser "chrome:headless" due to an error.

Error: Unable to run the browser. The browser path or command template is not specified.
at checkBrowserPath$ (/rp-web/node_modules/testcafe-browser-tools/lib/api/open.js:47:23)
at tryCatch (/rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:72:40)
at Generator.invoke [as _invoke] (/rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:334:22)
at Generator.prototype.(anonymous function) [as next] (/rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:105:21)
at tryCatch (/rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:72:40)
at invoke (/rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:146:20)
at /rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:191:11
at new Promise (<anonymous>)
at new F (/rp-web/node_modules/core-js/library/modules/$.export.js:30:36)
at callInvokeWithMethodAndArg (/rp-web/node_modules/testcafe-browser-tools/node_modules/babel-runtime/regenerator/runtime.js:190:16)

Type "testcafe -h" for help.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Exited with code 1

this is how my yml looks like:

jobs:
   build-and-test:
    working_directory: /repo
    docker:
      - image: node:10.5.0
      - image: circleci/node:11.6-browsers

Also, tried the run command with no sandbox but got the same error:

testcafe chrome:headless uitests/tests/* -r xunit:/tmp/test results/res.xml -e --no-sandbox

I'm successfully able to run things locally but unable to run on CircleCi. Can anyone help with this on how to fix this?

Upvotes: 5

Views: 5232

Answers (1)

Andrey Belym
Andrey Belym

Reputation: 2903

I think removing the "- image: node:10.5.0" line from your config will fix these errors. I've created an example project (https://github.com/AndreyBelym/testcafe-example-circle-ci) and configured CircleCI builds (https://circleci.com/gh/AndreyBelym/testcafe-example-circle-ci) to test my assumption.

If you specify multiple container images in a build job configuration, the first image will be considered as a primary container and all other images as secondary containers. All build steps are executed in the primary container, and secondary containers are started in the background and accessible to the build steps only via the shared network. You can read more about it in Choosing an Executor Type - Using Multiple Docker Images.

Your build job configuration:

jobs:
   build-and-test:
    working_directory: /repo
    docker:
      - image: node:10.5.0
      - image: circleci/node:11.6-browsers

means that you try to run TestCafe in the node:10.5.0 that doesn't have any browsers installed. That's why TestCafe can't find a browser and gives you the "Error: Unable to run the browser. The browser path or command template is not specified." error.

Also because the node:10.5.0 uses a special user account with reduced privileges, the node:11.6.0-browsers gives you the "_XSERVTransmkdir: ERROR: euid != 0" error because it needs administrator privileges to start Xvfb - a virtual X11 server (i.e. virtual desktop).

Upvotes: 5

Related Questions