[英]Unable to run Jasmine tests through Jenkins pipeline
I've Jasmine tests which are targeted to run on Chrome with following command -我有 Jasmine 测试,其目标是使用以下命令在 Chrome 上运行 -
karma start --specFileRegistry="DiagramComponent/test/DiagramComponent.specConfig.js" --outputFile="test-reports/test-case-report/NodeMappingCanvas.html"
This successfully run tests when I run from terminal on Linux machine but when run through Jenkins pipeline results into error -当我从 Linux 机器上的终端运行时,这成功运行了测试,但是当通过 Jenkins 管道运行时会导致错误 -
ERROR [launcher]: Cannot start Chrome
[exec] Fontconfig warning: "/etc/fonts/fonts.conf", line 86: unknown element "blank"
[exec] [115058:115058:0911/171053.130462:ERROR:browser_main_loop.cc(1512)] Unable to open X display.
Please suggest how I can get rid of this.请建议我如何摆脱这个。
Karma is trying to open a Chrome window and since it's running on an operating system without a windowing environment (Jenkins) it cannot open a window. Karma 正在尝试打开 Chrome 窗口,由于它在没有窗口环境 (Jenkins) 的操作系统上运行,因此无法打开窗口。
You need to configure Karma to use a browser that doesn't run in a window.您需要将 Karma 配置为使用不在窗口中运行的浏览器。 It's called a headless browser.
它被称为无头浏览器。
The most popular choice these days would be to use Headless Chrome.目前最流行的选择是使用 Headless Chrome。 karma-chrome-launcher supports running Headless Chrome.
karma-chrome-launcher支持运行 Headless Chrome。
It should be sufficient to replace browsers: ['Chrome']
with browsers: ['ChromeHeadless']
in your Karma config.在 Karma 配置
browsers: ['ChromeHeadless']
browsers: ['Chrome']
替换为browsers: ['ChromeHeadless']
就足够了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.