VSTS 托管 Linux 使用 Karma 和 ChromeHeadless 进行预览
VSTS Hosted Linux Preview with Karma and ChromeHeadless
我的堆栈如下:Angular6、业力,Puppeteer with ChromeHeadless. I am trying to set-up a CI build on VSTS Hosted Linux Preview。但是,当我 运行 在构建机器上进行单元测试时,出现以下错误。
Cannot start ChromeHeadless /opt/vsts/work/1/s/node_modules/puppeteer/.local-chromium/linux-555668/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory
如果我切换到 Hosted VS2017 构建,那么它工作正常。这可能是因为它预装了 Chrome。我已经尝试将 Chrome 安装到 Linux 构建机器,但仍然没有成功。不幸的是,对于这个特定的构建,我需要使用 Linux 框,所以我无法切换到 Windows Hosted VS2017 框。
我的 karma.conf.js 文件如下所示:
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html
process.env.CHROME_BIN = require('puppeteer').executablePath();
module.exports = function (config) {
config.set({
browsers: ['ChromeNoSandbox'],
customLaunchers: {
ChromeNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox', '--headless'],
},
},
singleRun: true,
});
};
谢谢,
添加一个Shell脚本任务:
脚本:
sudo apt-get update
sudo apt-get -qq -y install libpangocairo-1.0-0 libx11-xcb1 libxcomposite1 libxcursor1 libxdamage1 libxi6 libxtst6 libnss3 libcups2 libxss1 libxrandr2 libgconf2-4 libasound2 libatk1.0-0 libgtk-3-0
我的堆栈如下:Angular6、业力,Puppeteer with ChromeHeadless. I am trying to set-up a CI build on VSTS Hosted Linux Preview。但是,当我 运行 在构建机器上进行单元测试时,出现以下错误。
Cannot start ChromeHeadless /opt/vsts/work/1/s/node_modules/puppeteer/.local-chromium/linux-555668/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory
如果我切换到 Hosted VS2017 构建,那么它工作正常。这可能是因为它预装了 Chrome。我已经尝试将 Chrome 安装到 Linux 构建机器,但仍然没有成功。不幸的是,对于这个特定的构建,我需要使用 Linux 框,所以我无法切换到 Windows Hosted VS2017 框。
我的 karma.conf.js 文件如下所示:
// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html
process.env.CHROME_BIN = require('puppeteer').executablePath();
module.exports = function (config) {
config.set({
browsers: ['ChromeNoSandbox'],
customLaunchers: {
ChromeNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox', '--headless'],
},
},
singleRun: true,
});
};
谢谢,
添加一个Shell脚本任务:
脚本:
sudo apt-get update
sudo apt-get -qq -y install libpangocairo-1.0-0 libx11-xcb1 libxcomposite1 libxcursor1 libxdamage1 libxi6 libxtst6 libnss3 libcups2 libxss1 libxrandr2 libgconf2-4 libasound2 libatk1.0-0 libgtk-3-0