SAP/karma-ui5

Controller coverage reported as 0/0 in Karma

DeveloperIRES opened this issue · 2 comments

Hello Team,

My application is ui5 freestyle CAP application and we are using npm middleware fe-mockserver
odata is v2

Issue: Karma is showing 0/0 as coverage for controller code.
Package.json file is as below

{ "name": "bookingadmin", "version": "0.0.1", "description": "A Fiori application.", "keywords": [ "ui5", "openui5", "sapui5" ], "main": "webapp/index.html", "scripts": { "build:cf": "npx ui5 build preload --clean-dest --config ui5-deploy.yaml --include-task=generateManifestBundle generateCachebusterInfo", "deploy-config": "npx -p @sap/ux-ui5-tooling fiori add deploy-config cf", "start-mock": "fiori run --config ./ui5-mock.yaml --open \"index.html\"", "coverage": "nyc qunit", "launch": "npm run -p start-mock coverage", "int-test": "fiori run --config ./ui5-mock.yaml --open \"test/integration/opaTests.qunit.html\"", "watch": "karma start karma.conf.js" }, "devDependencies": { "@sap-ux/ui5-middleware-fe-mockserver": "^2.1.87", "@sap/ui5-builder-webide-extension": "^1.1.7", "@sap/ux-ui5-tooling": "1.9.0", "ui5-task-zipper": "^0.3.1", "@ui5/cli": "^2.11.1", "@ui5/fs": "^2.0.6", "@ui5/logger": "^2.0.1", "@ui5/middleware-code-coverage": "^1.0.3", "karma": "5.1.0", "karma-chrome-launcher": "3.1.0", "karma-coverage": "2.0.2", "karma-ui5": "2.2.0", "karma-webdriver-launcher": "1.0.8", "express": "4.16.3" }, "ui5": { "dependencies": [ "@sap/ux-ui5-tooling", "@sap/ui5-builder-webide-extension", "ui5-task-zipper", "@sap-ux/ui5-middleware-fe-mockserver" ] }, "dependencies": { }, "author": "", "license": "ISC" }

Karma configuration file is as below:

`module.exports = function(config) {
"use strict";

//require("./webapp/test/app.js ");
config.set({
	preprocessors: {
		'./webapp/**/*.js': [
			'coverage'
		]
	},
	frameworks: [
		'ui5'
	],
	coverageReporter: {
		includeAllSources: true,
		dir: './target/coverage',
		reporters: [
			{
				type: 'lcov',
				subdir: 'report',

			}
		]
	},
	browserConsoleLogOptions: {
		level: '',
		terminal: true
	},
	reporters: [
		'progress', 'coverage'
	],
	ui5: {
		//url: "https://sapui5.hana.ondemand.com/1.102.3",
		mode: "html",
        configPath: "ui5-mock.yaml",
		testpage: "./webapp/test/integration/opaTests.qunit.html"
	},
	browsers: [
		'Chrome'
	],
	singleRun: false
});

};`

ui5-mock.yaml looks like below:
specVersion: "2.5" metadata: name: bookingadmin type: application server: customMiddleware: - name: fiori-tools-proxy afterMiddleware: compression configuration: ignoreCertError: false # If set to true, certificate errors will be ignored. E.g. self-signed certificates will be accepted ui5: path: - /resources - /test-resources url: https://ui5.sap.com - name: sap-fe-mockserver beforeMiddleware: csp configuration: mockFolder: webapp/localService

mockfolder points to localservice folder and has config.json, looks like below:
[ { "urlPath": "/facility-data-extension-api", "metadataPath": "./metadata.xml", "mockdataPath": "./data", "generateMockData": false } ]

@matz3 Could you please help?

matz3 commented

Missing coverage results is usually caused by incorrect relative paths within the tests. See #527 for a similar issue.