Confirure unit tests for gitlab runner
- Create another Karma config file
karma-ci.conf.js
that will be used by gitlab-runner. In this configuration we will usepuppeteer
instead of usual Chrome browser:
karma-ci.conf.js
process.env.CHROME_BIN = require('puppeteer').executablePath();
module.exports = config => {
config.set({
basePath: './js',
frameworks: ['jasmine'],
files: [
'**/*.js'
],
exclude: [
'main.js'
],
preprocessors: {},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
customLaunchers: {
Chrome: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
}
},
singleRun: true,
concurrency: Infinity
});
};
- Add
test-ci
command topackage.json
"scripts": {
"test": "karma start karma.conf.js",
"protractor": "protractor e2e-tests/protractor.conf.js",
"start": "http-server . -a localhost -p 8000 -c-1",
"test-ci": "karma start karma-ci.conf.js"
},
- Push changes to the repository, then you can see a new pipeline: