karmaExecuteTests always fails in Stage: Additional Unit Tests for SAPUI5 MTA project

Pre-condition:

  1. Generate SAPUI5 MTA project using ‘bash> yo fiori-project’ in SAP BTP Business Application Studio
  2. Pass karma test locally using ‘karma start’
  3. Setup pipeline using https://github.com/SAP/jenkins-library.git
    Issue: karma test failed in pipeline with npm error.

Configuration 1:

  1. By default, npm script is defined as below in $PROJECT_ROOTuipackage.json.
    "scripts": {
    "test": "karma start",
    }

Configuration 2:

  1. Add custom configuration for karmaExecuteTests in .piper/config.yml
    stages:
    karmaExecuteTests:
    runCommand: ‘npm run test’
  2. npm script is defined as below in $PROJECT_ROOTuipackage.json
    "scripts": {
    "test": "karma start",
    }

Error message is as below:
ERROR: (karmaExecuteTests) Step execution failed (category: test). Error: running command ‘npm’ failed: cmd.Run() failed: exit status 1