I'm using Karma to test an Angular4 project using ChromeHeadless and all works fine locally. I've then tried to get this running on AWS CodeBuild. The initial problem was that the CodeBuild VM does not include chrome headless and so I included the Puppeteer npm package and set the ENV Var accordingly in the Karma conf. This still works fine locally, but on AWS CodeBuild I get the error ...
puppeteer/.local-chromium/linux-526987/chrome-linux/chrome: error while loading shared libraries: libXss.so.1: cannot open shared object file: No such file or directory
The build is triggered from standard buildspec.yml executing maven mvn -B package
. The angular build/test is done from maven using the eislett/frontend-maven-plugin (v1.4).
Puppeteer v1.0.0 Node v6.10.1 Karma v1.7.1 AWS CodeBuild - Ubuntu / Java / OpenJDK 8
I've seen other posts about additional installs onto the CI machines but CodeBuild spins up a clean VM on each run so thats not an option. Any suggestions!?
You can use the AWS CodeBuild console, AWS CLI, or AWS SDK to set up, run, and monitor builds directly with CodeBuild. Not what you're looking for? To use AWS CodePipeline to run CodeBuild, see Use CodePipeline with CodeBuild.
I finally (after over a year!) got this working (without puppeteer).
buildspec.yml - install chrome stable
phases:
pre_build:
commands:
- curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
- echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list
- apt-get -y update
- apt-get -y install google-chrome-stable
karma.conf.js - specify port, hostname, listenaddress, disable random, extend timeouts & tolerances
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/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
},
captureTimeout: 210000,
browserDisconnectTolerance: 3,
browserDisconnectTimeout : 210000,
browserNoActivityTimeout : 210000,
reporters: ['progress', 'kjhtml'],
port: 9876,
listenAddress: 'localhost',
hostname: 'localhost',
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadlessNoSandbox'],
customLaunchers: {
ChromeHeadlessNoSandbox: {
base: 'ChromeHeadless',
flags: [
'--headless',
'--no-sandbox',
'--password-store=basic',
'--enable-logging',
'--v=1'
],
},
},
singleRun: true
});
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With