Reputation: 1456
I'm working on Angular project and I'm able to run the test with karma and Jasmin on my Windows local machine with headless chrome. But Jenkins says that No binary for ChromeHeadless browser on your platform, so the question is how to configure the ChromeHeadless in Jenkins configuration.
i know that i can relove the problem by adding puppeteer to my karma conf but i don't want to use puppetter on my project.
could you please tell me how i can resolve this problem without using pupetter?
this is my karma conf :
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
//process.env.CHROME_BIN = require('puppeteer').executablePath()
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, './coverage'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' },
{ type: 'lcovonly' }
]
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
browserNoActivityTimeout: 1000000000,
browserDisconnectTimeout : 1000000000,
});
};
Upvotes: 0
Views: 1921
Reputation: 121
Seems it's not possible to set this in the karma.conf itself. Instead try to set the ENV variable CHROME_BIN to the respective path. For instance, we use Chromium instead of Google Chrome in a docker container and have set
FROM node:16-alpine
ENV CHROME_BIN="/usr/bin/chromium-browser"
...
in our DOCKERFILE. This path is specific to the alpine-base image we use. So the path might be different in your case.
Or, if you run karma from Intellij, add the same env-variable to your karma environment, as explained here: https://intellij-support.jetbrains.com/hc/en-us/community/posts/5991195077010-CHROME-BIN-not-set-for-single-karma-test-run
Upvotes: 1