SAP/karma-ui5

Karma run failed in Jenkins

johnlu-sh opened this issue · 2 comments

Hi colleagues,

I face an issue when trying to run karma test in jenkins. It was always successful, but someday it suddenly failed until now.

Error in jenkins is:

[2021-01-15T04:00:08.981Z] 15 01 2021 04:00:08.032:ERROR [plugin]: Error during loading "/home/jenkins/agent/workspace/cost-accounting-ui_master/skfManagementUI/node_modules/karma-ui5" plugin:

[2021-01-15T04:00:08.981Z]   Unexpected token {

[2021-01-15T04:00:08.981Z] 15 01 2021 04:00:08.359:ERROR [karma-server]: Server start failed on port 9876: Error: No provider for "framework:ui5"! (Resolving: framework:ui5)

[2021-01-15T04:00:08.981Z] npm info lifecycle skfManagementUI@0.0.1~karma: Failed to exec karma script

[2021-01-15T04:00:08.981Z] npm ERR! code ELIFECYCLE

[2021-01-15T04:00:08.981Z] npm ERR! errno 130

[2021-01-15T04:00:08.981Z] npm ERR! skfManagementUI@0.0.1 karma: `rimraf coverage && karma start karma.conf.js && npm run lint`

[2021-01-15T04:00:08.981Z] npm ERR! Exit status 130

[2021-01-15T04:00:08.981Z] npm ERR! 

[2021-01-15T04:00:08.981Z] npm ERR! Failed at the skfManagementUI@0.0.1 karma script.

[2021-01-15T04:00:08.981Z] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

[2021-01-15T04:00:08.981Z] 

[2021-01-15T04:00:08.981Z] npm ERR! A complete log of this run can be found in:

[2021-01-15T04:00:08.981Z] npm ERR!     /home/node/.npm/_logs/2021-01-15T04_00_08_618Z-debug.log

karma.conf.js is:

module.exports = function (config) {
  config.set({
    frameworks: ["ui5"],
    ui5: {
      type: 'application',
      htmlrunner: false,
      url: 'https://sapui5.hana.ondemand.com/1.63.1/',
      testpage: "webapp/test/unit/unitTests.qunit.html",
      config: {
        theme: 'sap_belize',
        language: 'EN',
        animation: false,
        compatVersion: 'edge',
        async: true,
        resourceroots: {
          'skfManagementUI': './webapp'
        }
      },
      tests: ['skfManagementUI/test/unit/AllTests.js']
      },
    browsers: ["ChromeHeadlessNoSandbox"],
    failOnEmptyTestSuite: false,
    browserNoActivityTimeout: 60000,
    browserDisconnectTimeout: 60000,
    browserDisconnectTolerance : 2,
    captureTimeout: 180000,
    proxyValidateSSL: false,
    singleRun: true,
    browserConsoleLogOptions: {
      level: "error"
    },
    // you can define custom flags
     customLaunchers: {
    ChromeHeadlessNoSandbox: {
         base: 'ChromeHeadless',
     flags: ['--disable-web-security', '--disable-gpu', '--no-sandbox']
        }
    },    
      // coverage reporter generates the coverage
      reporters: ['progress', 'coverage','junit'],
    
      preprocessors: {
      // source files, that you wanna generate coverage for
      // do not include tests or libraries
      // (these files will be instrumented by Istanbul)
      'webapp/controller/*.js': ['coverage'],
      'webapp/utils/*.js': ['coverage']
      },
     coverageReporter: {
      // specify a common output directory
      dir: './webapp/target/coverage',
      includeAllSources: true,
      reporters: [
      {
        type: 'cobertura',
        subdir: 'cobertura',
        file: 'cobertura-coverage.xml'
      }, 
      {
        type: 'lcov',
        subdir: 'report'
      },
      {
        type: 'html',
        subdir: 'report-html',
        file: 'qunitcoverage.html'
      }
       ]
      },
      junitReporter: {
        outputDir: '.webapp/target/karma',
        outputFile: 'TEST-com.sap.ui5.selenium.junit.xml',
        suite: '',
        useBrowserName: false
      },
  });
};

package.json is:

{
  "name": "skfManagementUI",
  "version": "0.0.1",
  "description": "",
  "devDependencies": {
    "@sap/grunt-sapui5-bestpractice-build": "1.4.1",
    "@sap/grunt-sapui5-bestpractice-test": "2.0.1",
    "@ui5/cli": "^2.2.6",
    "@ui5/uiveri5": "latest",
    "cors-anywhere": "latest",
    "cross-var": "^1.1.0",
    "eslint": "^6.7.2",
    "grunt": "^0.4.5",
    "grunt-bower-task": "^0.4.0",
    "grunt-cli": "^1.2.0",
    "grunt-connect-rewrite": "^0.2.1",
    "grunt-contrib-compress": "1.3.0",
    "grunt-contrib-connect": "^0.11.2",
    "grunt-contrib-copy": "^1.0.0",
    "grunt-contrib-less": "^1.2.0",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-eslint": "^19.0.0",
    "grunt-karma": "^2.0.0",
    "grunt-middleware-proxy": "^1.0.7",
    "grunt-openui5": "^0.8.0",
    "grunt-replace": "^1.0.1",
    "include-all": "^0.1.6",
    "karma": "^4.4.1",
    "karma-chrome-launcher": "^3.1.0",
    "karma-cli": "latest",
    "karma-coverage": "^2.0.1",
    "karma-html-reporter": "0.2.7",
    "karma-junit-reporter": "^2.0.1",
    "karma-openui5": "^0.2.3",
    "karma-phantomjs-launcher-nonet": "^0.1.3",
    "karma-qunit": "^1.2.1",
    "karma-ui5": "^2.3.2",
    "karma-webdriver-launcher": "^1.0.8",
    "load-grunt-tasks": "^3.4.0",
    "local-web-server": "^4.0.0",
    "mbt": "1.0.4",
    "openui5-preload": "^2.3.1",
    "path": "^0.12.7",
    "qunit": "^2.9.2",
    "qunitjs": "^2.3.0",
    "rimraf": "^3.0.2",
    "whitesource": "latest"
  },
  "scripts": {
    "test": "npm run lint && npm run karma",
    "lint": "eslint -c ./eslintrc.json webapp/utils webapp/controller -f json -o eslint.jslint.json",
    "serve": "ui5 serve",
    "karma": "npm cache clear --force && rimraf coverage && karma start karma.conf.js && npm run lint"
  },
  "dependencies": {
    "openui5-fhir": "2.0.4"
  }
}

Do you have any idea on this?

BR,
John

matz3 commented

What's the Node.js version? Unexpected token might be a hint for an outdated version.
Please note that karma-ui5 v2.x requires Node v10.x or higher.

As we've not released any update recently and your package.json references the latest version (^2.3.2) I don't see how this package could be the problem.
I rather think the error comes from a dependency.
Maybe debug logging via --log-level=debug gives you some more insights about the source of the error.

I check the node version, is 8.4.
I use the new dock image which has a higher node version, now the issue solved.
Thanks a lot.