teracyhq / docker-files

Teracy docker-files project to build common Docker images
https://hub.docker.com/r/teracy/
MIT License
92 stars 55 forks source link

angular-cli: cannot find Chrome binary #25

Closed niklas-dahl closed 7 years ago

niklas-dahl commented 7 years ago

Hey, I wanted to use your teracy/angular-cli image to run angular-cli e2e tests.

i did the following steps:

  1. docker run --rm -it -v $(pwd):/opt -w /opt teracy/angular-cli /bin/bash
  2. ng new test123
  3. cd test123
  4. ng e2e

ng e2e fails with the following error:

** NG Live Development Server is running on http://localhost:49152 **
Hash: 6648ff5c35778096f3ee
Time: 8065ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 158 kB {4} [initial] [rendered]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 3.62 kB {3} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 9.77 kB {4} [initial] [rendered]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.37 MB [initial] [rendered]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
webpack: Compiled successfully.
[07:41:40] I/file_manager - creating folder /opt/test123/node_modules/protractor/node_modules/webdriver-manager/selenium
[07:41:41] I/downloader - curl -o /opt/test123/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.28.zip https://chromedriver.storage.googleapis.com/2.28/chromedriver_linux64.zip
[07:41:41] I/update - chromedriver: unzipping chromedriver_2.28.zip
[07:41:41] I/update - chromedriver: setting permissions to 0755 for /opt/test123/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.28
[07:41:41] I/launcher - Running 1 instances of WebDriver
[07:41:41] I/direct - Using ChromeDriver directly...
[07:41:41] E/launcher - unknown error: cannot find Chrome binary
  (Driver info: chromedriver=2.28.455506 (18f6627e265f442aeec9b6661a49fe819aeeea1f),platform=Linux 3.16.0-4-amd64 x86_64)
[07:41:41] E/launcher - WebDriverError: unknown error: cannot find Chrome binary
  (Driver info: chromedriver=2.28.455506 (18f6627e265f442aeec9b6661a49fe819aeeea1f),platform=Linux 3.16.0-4-amd64 x86_64)
    at WebDriverError (/opt/test123/node_modules/selenium-webdriver/lib/error.js:27:5)
    at Object.checkLegacyResponse (/opt/test123/node_modules/selenium-webdriver/lib/error.js:505:15)
    at parseHttpResponse (/opt/test123/node_modules/selenium-webdriver/lib/http.js:509:13)
    at doSend.then.response (/opt/test123/node_modules/selenium-webdriver/lib/http.js:440:13)
    at process._tickCallback (internal/process/next_tick.js:109:7)
From: Task: WebDriver.createSession()
    at Function.createSession (/opt/test123/node_modules/selenium-webdriver/lib/webdriver.js:777:24)
    at Function.createSession (/opt/test123/node_modules/selenium-webdriver/chrome.js:709:29)
    at Direct.getNewDriver (/opt/test123/node_modules/protractor/lib/driverProviders/direct.ts:90:25)
    at Runner.createBrowser (/opt/test123/node_modules/protractor/lib/runner.ts:225:39)
    at q.then.then (/opt/test123/node_modules/protractor/lib/runner.ts:391:27)
    at _fulfilled (/opt/test123/node_modules/protractor/node_modules/q/q.js:834:54)
    at self.promiseDispatch.done (/opt/test123/node_modules/protractor/node_modules/q/q.js:863:30)
    at Promise.promise.promiseDispatch (/opt/test123/node_modules/protractor/node_modules/q/q.js:796:13)
    at /opt/test123/node_modules/protractor/node_modules/q/q.js:556:49
    at runSingle (/opt/test123/node_modules/protractor/node_modules/q/q.js:137:13)
    at flush (/opt/test123/node_modules/protractor/node_modules/q/q.js:125:13)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)
[07:41:41] E/launcher - Process exited with error code 199

Any Idea what could be the issue? Thanks!

hoatle commented 7 years ago

let me check on this

hoatle commented 7 years ago

@niklas-dahl I can reproduce the problem, the problem is that by default Chrome tests did not work within Docker container, you need to configure karma and protractor for running tests within Docker container.

--no-sandbox option must be used for Chrome to get it running within Docker container.

and to run unit tests: $ ng test --browsers Chrome_no_sandbox, e2e tests: ng e2e.

You should refer to https://github.com/teracyhq/angular-boilerplate for best practices and working config.

hoatle commented 7 years ago

I've updated the docs here too https://github.com/teracyhq/docker-files/tree/master/angular-cli#tests-with-chrome

niklas-dahl commented 7 years ago

Thanks, I got e2e working, but the karma tests are failing.

I create an example repository to isolate the problem: https://gitlab.com/niklas-dahl/angular-cli-e2e-test

The failing buid log: https://gitlab.com/niklas-dahl/angular-cli-e2e-test/builds/13618871

hoatle commented 7 years ago

https://gitlab.com/niklas-dahl/angular-cli-e2e-test/blob/master/package.json#L9 should be "test": "ng test --browsers Chrome_no_sandbox", as I mentioned on my comment above.

niklas-dahl commented 7 years ago

oh my bad, yeah it is working now, thanks a lot :D

hoatle commented 7 years ago

you're welcome, don't hesitate to ask us any questions :)

niklas-dahl commented 7 years ago

hmm the karma test is not terminating.. https://gitlab.com/niklas-dahl/angular-cli-e2e-test/builds/13621811

any idea?

hoatle commented 7 years ago

by defaul, karma test runs and watches. To disable watch, you should use this on CI system instead:

$ ng test --browsers Chrome_no_sandbox -w false
hoatle commented 7 years ago

@niklas-dahl you should look into this example project, I'm updating to get it run on gitlab-ci, too https://github.com/acme101/angular-hello-world https://gitlab.com/acme101/angular-hello-world

hoatle commented 7 years ago

@niklas-dahl gitlab-ci done, check it out: https://gitlab.com/acme101/angular-hello-world/pipelines