SAP/karma-ui5

Karma unit test cases for html files not working

shivam-dteenergy opened this issue · 2 comments

Karma.conf.js ->

module.exports = function(config) {
    config.set({
      ui5: {
        path: 'https://openui5.hana.ondemand.com/1.65.1/resources/sap-ui-core.js',
        mode: "html"
      },
      browsers: ['Chrome', 'Chrome_without_security'], 
      customLaunchers: {
        Chrome_without_security: {
          base: 'Chrome',
          flags: ['--disable-web-security', '--disable-site-isolation-trials']
        }
      },
files: [
  { pattern: '**', included: false, served: true, watched: true }
],
reporters: ['progress', 'junit', 'coverage'],
    });
  };

Gruntfile-copy.js ->

 'use strict';

var path = require('path');

module.exports = function(grunt) {
  grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        karma: {
            options: {
              // point all tasks to karma config file
              configFile: 'karma.conf.js'
            },
            unit: {
              // run tests once instead of continuously
              singleRun: true
            }
          }
    });
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-clean');
};

I am trying to run for these two applications (among many). One is shop(standard app) and one custom library. Git repos for both (please use your username) messaged to you

So the folder structure of the project is like this

parent package.json
->shop->webap->test->testsuite.qunit.html
->sap.uism.ui5s1->test->unit->testsuite.qunit.html

package.json of shop application

{
  "name": "nw.epm.refapps.shop",
  "testrunnerSchema.default":"['**/*.qunit.html']",
  "version": "1.0.0",
  "private": true,
  "devDependencies": {
    "--REMOVED--": "4.2.1",
    "grunt": "1.0.3",
    "grunt-cli": "1.3.2"
  },
  "sapui5": {
    "version": "1.71.1",
    "resources": "https://sapui5.hana.ondemand.com/1.71.1/resources",
    "testResources": "https://sapui5.hana.ondemand.com/1.71.1/test-resources",
    "apps": {
      "nw.epm.refapps.shop": {
        "namespace": "nw.epm.refapps.shop",
        "resources": "webapp",
        "testResources": "webapp/test"
      }
    }
    }
}

package.json of uism library

 {
  "name": "sapuismui5s1",
  "version": "1.0.0",
  "private": true,
  "devDependencies": {
    "--REMOVED--": "4.2.1",
    "grunt": "1.0.3",
    "grunt-cli": "1.3.2"
  },
  "sapui5": {
    "version": "1.71.1",
    "resources": "https://sapui5.hana.ondemand.com/1.71.1/resources",
    "testResources": "https://sapui5.hana.ondemand.com/1.71.1/test-resources",
    "libs": {
      "sapuismui5s1": {
        "namespace": "sap.uism.ui5s1",
        "resources": "./src/sap/uism/ui5s1",
        "testResources":"./test/unit"
      }
    },
  }
}

Command executed -> grunt --gruntfile Gruntfile-copy-remove.js karma --verbose --debug

matz3 commented

Could you please also add the output / error messages when running your command?

In general it would be good to have a small example that can be used to reproduce the issue faced. That should also not contain or require any private or internal content.

Just from the config I can see that you are using the new "ui5" namespace, but the old "path" property, which has been changed to url starting with karma-ui5 v1.0.0.

matz3 commented

Closing as there was no response from the author within 3 months.