What settings do i need to use to make sure my unit-tests get run automatically by Jenkins?

Viewed 45

I am making an application in Angular 7 and i have around 50 tests. These pass on my machine. My goal is to make sure the latest version of my application gets build and the tests get run on Jenkins.

The Jenkins server runs on linux i think. I am using the following command to execute the tests:

npm install
ng test --watch=false --code-coverage

I have tried multiple different settings in my karma.conf.js file. I currently tried to use phantomJS on the jenkins server. This is my karma.conf.js:

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', '@angular-devkit/build-angular'],
    plugins: [
      require('karma-jasmine'),
      require('karma-chrome-launcher'),
      require('karma-phantomjs-launcher'),
      require('karma-jasmine-html-reporter'),
      require('karma-coverage-istanbul-reporter'),
      require('@angular-devkit/build-angular/plugins/karma')
    ],
    client: {
      clearContext: false 
    },
    coverageIstanbulReporter: {
      dir: require('path').join(__dirname, '../coverage'),
      reports: ['html', 'lcovonly'],
      fixWebpackSourcePaths: true
    },
    reporters: ['progress', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['PhantomJS'],
    singleRun: false
  });
};

I have also added the karma-phantomjslauncher in the devDependencies

"karma-phantomjs-launcher": "^1.0.4",

I get the following console output from Jenkins:

PhantomJS 2.1.1 (Linux 0.0.0) ERROR
  {
    "message": "TypeError: undefined is not a function (evaluating 'new Array(type.length).fill(undefined)')\nat 
http://localhost:9876/_karma_webpack_/vendor.js:60532:43",
    "str": "TypeError: undefined is not a function (evaluating 'new Array(type.length).fill(undefined)')\nat 
http://localhost:9876/_karma_webpack_/vendor.js:60532:43"
  }

I have no clue on how to fix this, does anybody know where my settings are wrong?

0 Answers
Related