|
|
# Confirure unit tests for gitlab runner
|
|
|
|
|
|
1. Create another Karma config file `karma-ci.conf.js` that will be used by gitlab-runner. In this configuration we will use `puppeteer` 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
|
|
|
});
|
|
|
};
|
|
|
```
|
|
|
|
|
|
2. Add `test-ci` command to `package.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"
|
|
|
},
|
|
|
```
|
|
|
|
|
|
3. Push changes to the repository, then you can see a new pipeline:
|
|
|
|
|
|
![passed](uploads/a13c140b8e3b5627a3fd31802001f874/passed.png)
|
|
|
|
|
|
![unit-ci](uploads/6203067d70305afd913aee0cdba4a556/unit-ci.png) |
|
|
\ No newline at end of file |