Jean Alesi
Jean Alesi

Reputation: 165

How to run headless browser testing in docker container

I have a node.js application that runs mocha tests using chimp, and it works normally when running inside my local OS. It uses Google Chrome to do the ui tests.

Currently, I am dockerizing this application... However, I am unsure about what I need in order to run the ui test in terms of browser.

I used some of the commands from https://github.com/workflow/docker-chimp/blob/master/Dockerfile in order to install a headless chrome browser.

My tests fail at the "before all" hook... But I have no idea where that is, nor why it happens.. The tests run normally in the Host OS.

> [email protected] test /PlutoD2D/itest
> chimp --mocha


[chimp] Running...


  1) "before all" hook

  0 passing (1m)
  1 failing

  1)  "before all" hook:
     Error: timeout of 60000ms exceeded. Ensure the done() callback is being called in this test




Mocha failed
npm ERR! Test failed.  See above for more details.

How can I find out what the problem is?

Upvotes: 2

Views: 1996

Answers (1)

dima117
dima117

Reputation: 113

Try to use mocha-headless-chrome package.

npm i mocha-headless-chrome

mocha-headless-chrome -f test-page.html

Also you need some libraries for execute headless chrome in docker container:

apt-get install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget

See the details.

Upvotes: 2

Related Questions