Я работаю над базовым Angular-проектом и могу запустить тест с кармой и Jasmin на моей Windows с безголовым хромом.Но Дженкинс говорит, что No binary for ChromeHeadless browser on your platform
, поэтому вопрос заключается в том, как настроить ChromeHeadless в конфигурации Jenkins.
Журнал ошибок
Нет двоичного файла для браузера ChromeHeadless наваша платформа.Пожалуйста, установите переменную env CHROME_BIN. Npm ERR! Тест не пройден.
package.json
"devDependencies": {
"@angular-devkit/build-angular": "~0.6.8",
"@angular/cli": "~6.0.8",
"@angular/compiler-cli": "^6.1.0",
"@angular/language-service": "^6.0.3",
"@types/jasmine": "~2.8.6",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.2.1",
"jasmine-core": "^2.9.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "^1.7.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage": "^1.1.2",
"karma-coverage-istanbul-reporter": "~2.0.0",
"karma-jasmine": "~1.1.1",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-phantomjs-launcher": "^1.0.4",
"karma-sonarqube-unit-reporter": "0.0.18",
"protractor": "~5.3.0",
"ts-node": "~5.0.1",
"tslint": "~5.9.1",
"typescript": "^2.9.2"
}
karma.conf.js
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: '',
// captureTimeout: 60000, // it was already there
// browserDisconnectTimeout: 10000,
// browserDisconnectTolerance: 1,
// browserNoActivityTimeout: 60000, //by default 10000
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-coverage'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
// require('@angular/cli/plugins/karma'),
require('@angular-devkit/build-angular/plugins/karma'),
require('karma-sonarqube-unit-reporter'),
// require('karma-phantomjs-launcher')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
// dir: require('path').join(__dirname, '../coverage'),
reports: ['html', 'lcovonly'],
useBrowserName: false,
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml', 'sonarqubeUnit', 'coverage'],
sonarQubeUnitReporter: {
outputFile: '../../target/angular_reports/ut_report.xml',
useBrowserName: false
},
// angularCli: {
// environment: 'dev'
// },
coverageReporter: {
// specify a common output directory
dir: '../../target/angular_reports/coverage',
reporters: [
// reporters not supporting the `file` property
{
type: 'html',
subdir: 'report-html'
},
{
type: 'lcov',
subdir: 'report-lcov'
},
// reporters supporting the `file` property, use `subdir` to directly
// output them in the `dir` directory
{
type: 'cobertura',
subdir: '.',
file: 'cobertura.txt'
},
{
type: 'lcovonly',
subdir: '.',
file: 'report-lcovonly.txt'
},
{
type: 'teamcity',
subdir: '.',
file: 'teamcity.txt'
},
{
type: 'text',
subdir: '.',
file: 'text.txt'
},
{
type: 'text-summary',
subdir: '.',
file: 'text-summary.txt'
},
]
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
// browsers: ['Chrome'],
// browsers: ['ChromeHeadless'],
// browsers: ['Chrome'],
browsers: ['MyHeadlessChrome'],
// browsers: ['Chrome', 'ChromeHeadless', 'MyHeadlessChrome'],
customLaunchers: {
MyHeadlessChrome: {
base: 'ChromeHeadless',
flags: ['--disable-translate', '--disable-extensions', '--remote-debugging-port=9223']
}
},
// singleRun: false
singleRun: true
});
};