Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Karma failing with CI/CD #336

Open
spraju92 opened this issue Sep 11, 2023 · 0 comments
Open

Karma failing with CI/CD #336

spraju92 opened this issue Sep 11, 2023 · 0 comments

Comments

@spraju92
Copy link

Karma is used to run unit test cases in one of my Angular applications. If you run it locally with the configuration shown below, there are no problems, however if you use CI/CD, you are now seeing the error message "No binary for Chrome browser on your platform. Please set the environment variable "CHROME_BIN"
Karma.conf.js:
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-istanbul-reporter'), require('karma-coverage'), require('@angular-devkit/build-angular/plugins/karma') ], client: { clearContext: false ,// leave Jasmine Spec Runner output visible in browser jasmine: { random: false } }, coverageIstanbulReporter: { dir: require('path').join(__dirname, '../coverage'), reports: ['html', 'lcovonly'], fixWebpackSourcePaths: true }, reporters: ['progress', 'kjhtml'], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: true, browsers: ['Chrome'], singleRun: true, customLaunchers: { ChromeHeadlessCI: { base: 'ChromeHeadless', flags: [ '--no-sandbox' ] } } }); };
And I attempted to set CHROME_BIN with Puppeteer as seen below after going through a few references, but I'm now encountering a different kind of problem. The problem with Puppeteer is that
`11 09 2023 10:49:24.520:ERROR [config]: Error in config file!
Error: Could not find Chrome (ver. 116.0.5845.96). This can occur if either

  1. you did not perform an installation before running the script (e.g. npm install) or
  2. your cache path is incorrectly configured (which is: /opt/app-root/src/.cache/puppeteer).`

And this is the current Karma config file with Puppeteer.
process.env.CHROME_BIN = require('puppeteer').executablePath() module.exports = function (config) { config.set({ basePath: '', frameworks: ['jasmine', '@angular-devkit/build-angular'], plugins: ['karma-jasmine', 'karma-chrome-launcher', require('karma-jasmine-html-reporter'), require('karma-chrome-launcher'), require('karma-coverage-istanbul-reporter'), require('karma-coverage'), require('@angular-devkit/build-angular/plugins/karma') ], client: { clearContext: false ,// leave Jasmine Spec Runner output visible in browser jasmine: { random: false } }, coverageIstanbulReporter: { dir: require('path').join(__dirname, '../coverage'), reports: ['html', 'lcovonly'], fixWebpackSourcePaths: true }, reporters: ['progress', 'kjhtml'], port: 9876, colors: true, logLevel: config.LOG_INFO, autoWatch: true, browsers: ['Chrome', 'ChromeHeadless', 'ChromeHeadlessCI'], singleRun: true, customLaunchers: { ChromeHeadless: { base: 'ChromeHeadless', flags: [ '--headless', '--disable-gpu', '--no-sandbox', '--remote-debugging-port=9222', ] } } }); };
Can somebody help me understand whether there need to be any configuration adjustments made to the appropriate CI/CD in github?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant