【问题标题】:How to run headless browser testing in docker container如何在 docker 容器中运行无头浏览器测试
【发布时间】:2016-08-11 23:06:35
【问题描述】:

我有一个使用 chimp 运行 mocha 测试的 node.js 应用程序,它在我的本地操作系统中运行时可以正常工作。它使用 Google Chrome 进行 ui 测试。

目前,我正在 dockerizing 这个应用程序...但是,我不确定我需要什么才能在浏览器方面运行 ui 测试。

我使用了来自https://github.com/workflow/docker-chimp/blob/master/Dockerfile 的一些命令来安装无头 chrome 浏览器。

我的测试在“首先”钩子上失败了......但我不知道那在哪里,也不知道为什么会发生......测试在主机操作系统中正常运行。

> pluto_integ_test@1.0.0 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.

如何找出问题所在?

【问题讨论】:

  • 尝试 --debug 标志。另外,请参阅medium.com/lucjuggery/…
  • 解决方案是以特权运行,或者使用 xvfb(更好)

标签: javascript node.js docker mocha.js chimp.js


【解决方案1】:

尝试使用mocha-headless-chrome 包。

npm i mocha-headless-chrome

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

你还需要一些库来在 docker 容器中执行 headless chrome:

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

请参阅details

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-06
    • 2017-09-25
    • 1970-01-01
    • 1970-01-01
    • 2017-10-04
    • 2019-08-25
    • 2017-11-12
    • 1970-01-01
    相关资源
    最近更新 更多