Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
js-frontend-tutorial js-frontend-tutorial
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • ci-general
  • js-frontend-tutorialjs-frontend-tutorial
  • Wiki
  • Confirure unit tests for gitlab runner

Last edited by Taras Gaidukov Jul 11, 2019
Page history

Confirure unit tests for gitlab runner

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
    });
};
  1. 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"
 },
  1. Push changes to the repository, then you can see a new pipeline:

passed

unit-ci

Clone repository
  • A sample project
  • Build docker image
  • Configure GitLab CI
  • Configure e2e tests for gitlab runner
  • Configure e2e tests on local machine
  • Configure unit tests on local machine
  • Confirure unit tests for gitlab runner
  • Register gitlab runner
  • What is Continuous Integration
  • Home