Skip to content

Commit

Permalink
[FEATURE] Integrate execution without htmlrunner
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
The `useMockServer` option has been removed.
A MockServer needs to be started from the test code.
  • Loading branch information
romaniam authored and matz3 committed Mar 12, 2019
1 parent 1557198 commit e991ac6
Show file tree
Hide file tree
Showing 21 changed files with 342 additions and 429 deletions.
5 changes: 0 additions & 5 deletions .npmignore

This file was deleted.

26 changes: 0 additions & 26 deletions Gruntfile.js

This file was deleted.

29 changes: 0 additions & 29 deletions lib-openui5/index.js

This file was deleted.

25 changes: 25 additions & 0 deletions lib/client/autorun.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(function (window) {

var karma = window.__karma__;
var config = karma.config;
var ui5config = (config && config.ui5) || {};
var ui5configTests = ui5config.tests;

if (!ui5configTests) {
// No tests defined - skipping autorun...
// Tests must be loaded manually
return;
}

// Prevent Karma from running prematurely.
karma.loaded = function () { };

sap.ui.getCore().attachInit(function () {
sap.ui.require(ui5configTests, function () {
// Finally, start Karma to run the tests.
karma.start();
});

});

})(window);
File renamed without changes.
7 changes: 7 additions & 0 deletions lib/client/sap-ui-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(function(window) {
var config = window.__karma__.config,
ui5config = (config && config.ui5) || {},
bootstrapConfig = ui5config.config || {};

window["sap-ui-config"] = bootstrapConfig;
})(window);
24 changes: 24 additions & 0 deletions lib/framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,23 @@ class Framework {
return path.split("/").slice(0, -1).concat(replacement).join("/")
}

checkLegacy(config) {
if(config.openui5 || config.client.openui5) {
throw Error("Please migrate your configuration https://github.com/SAP/karma-ui5");
}
}

initWithoutHTMLRunner(config) {
config.client.ui5.config = config.ui5.config;
config.client.ui5.tests = config.ui5.tests;
if(config.ui5.tests) {
config.files.unshift(this.createPluginFilesPattern(`${__dirname}/client/autorun.js`));
}
config.files.unshift(this.createPluginFilesPattern(`${config.ui5.url}/resources/sap-ui-core.js`));
config.files.unshift(this.createPluginFilesPattern(`${__dirname}/client/sap-ui-config.js`));

}

init(config) {
this.config = config;
this.config.basePath = config.basePath || "";
Expand All @@ -94,6 +111,13 @@ class Framework {
test: "test"
};

this.checkLegacy(config);

if(this.config.ui5.htmlrunner === false) {
this.initWithoutHTMLRunner(config);
return this;
}

const webappFolder = this.config.ui5.paths.webapp,
srcFolder = this.config.ui5.paths.src,
testFolder = this.config.ui5.paths.test;
Expand Down
Loading

0 comments on commit e991ac6

Please sign in to comment.