I am new to CI/CD and Jenkins. I am working on setting up CI/CD for an Angular application. It uses the default test runner which is Karma. I have a step that runs the tests in ChromeHeadless mode. My Jenkins pipeline is as below
pipeline {
agent any
tools {nodejs "node"}
environment {
NO_PROXY="localhost, 0.0.0.0/4201, 0.0.0.0/9876"
}
stages {
stage('Install') {
steps {
sh 'rm -rf node_modules'
sh 'rm package-lock.json'
sh 'rm -rf dist'
sh 'npm install --legacy-peer-deps'
}
}
stage('Test') {
steps {
sh 'npm run test-headless'
}
}
}
}
And in the package.json I have a script as below:
"test-headless": "ng test --browsers ChromeHeadless"
The config is as below:
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('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, './coverage/instone'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadless'],
customLaunchers: {
ChromeHeadless: {
base: 'Chrome',
flags: [
'--headless',
'--disable-gpu',
'--no-sandbox',
'--remote-debugging-port=9222'
]
}
},
singleRun: true,
restartOnFileChange: true
});
};
However I am getting the below error
I'd appreciate any assistance.