diff --git a/.gitignore b/.gitignore index c760ecae..72548411 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,5 @@ deploy_key # Custom directories dist/ + +**/reports/test_report.json \ No newline at end of file diff --git a/README.md b/README.md index c40649a9..004eaa0b 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ - [failOnEmptyTestPage](#failonemptytestpage) - [config](#config) - [tests](#tests) + - [logAssertions](#logassertions) + - [logHTMLFilePath](#loghtmlfilepath) - [API](#api) - [helper](#helper) - [configureIframeCoverage](#configureiframecoverage) @@ -419,6 +421,32 @@ ui5: { } ``` +### logAssertions +Type: `Boolean` +Default: `false` + +If set to `true`, the framework would report the result of the assertions. + +Example: +```js +ui5: { + logAssertions: true +} +``` + +### logHTMLFilePath +Type: `Boolean` +Default: `true` + +If set to `false`, the `log.suite[0]` of the test log would be the feature name. Otherwise it would be the path of the testsuite. + +Example: +```js +ui5: { + logHTMLFilePath: false +} +``` + ## API ### helper diff --git a/lib/client/browser.js b/lib/client/browser.js index ec2d0286..5b12c2df 100644 --- a/lib/client/browser.js +++ b/lib/client/browser.js @@ -267,9 +267,8 @@ require("./discovery.js"); }); QUnit.log(function(details) { + let msg = ""; if (!details.result) { - let msg = ""; - if (details.message) { msg += details.message + "\n"; } @@ -286,12 +285,35 @@ require("./discovery.js"); testResult.success = false; testResult.errors.push(msg); } + if (config.logAssertions) { + const testSuiteWithHTMLFilePath = [ + qunitHtmlFile, + details.module, + details.name, + details.message + ]; + const testSuite = testSuiteWithHTMLFilePath.slice(1); + const result = { + description: details.message, + suite: details.module && + config.logHTMLFilePath ? + testSuiteWithHTMLFilePath : + testSuite || + [], + success: details.result, + log: msg, + time: new Date().getTime() - timer + }; + karma.result(result); + } }); QUnit.testDone(function(test) { + const testSuiteWithHTMLFilePath = [qunitHtmlFile, test.module, test.name]; + const testSuite = testSuiteWithHTMLFilePath.slice(1); const result = { description: test.name, - suite: test.module && [qunitHtmlFile, test.module] || [], + suite: test.module && config.logHTMLFilePath ? testSuiteWithHTMLFilePath : testSuite || [], success: testResult.success, log: testResult.errors || [], time: new Date().getTime() - timer diff --git a/lib/framework.js b/lib/framework.js index 1604b156..6544e426 100644 --- a/lib/framework.js +++ b/lib/framework.js @@ -118,6 +118,10 @@ class Framework { // Relevant options (e.g. testpage, config, tests) will be written to the client section. this.config.client.ui5 = {}; this.config.client.ui5.useIframe = true; // for now only allow using iframes in HTML mode + this.config.client.ui5.logAssertions = config.ui5 && config.ui5.logAssertions || false; + this.config.client.ui5.logHTMLFilePath = ! config.ui5 || + config.ui5.logHTMLFilePath || + config.ui5.logHTMLFilePath === undefined && true; this.config.ui5 = config.ui5 || {}; this.config.middleware = config.middleware || []; this.config.files = config.files || []; @@ -139,7 +143,9 @@ class Framework { } const incompatibleFrameworks = ["qunit", "sinon"]; - const hasIncompatibleFrameworks = (frameworks) => frameworks.some((fwk) => incompatibleFrameworks.includes(fwk)); + const hasIncompatibleFrameworks = (frameworks) => frameworks.some((fwk) => + incompatibleFrameworks.includes(fwk) + ); if (this.config.ui5.mode === "html" && hasIncompatibleFrameworks(this.config.frameworks || [])) { this.logger.log("error", ErrorMessage.incompatibleFrameworks(this.config.frameworks) ); throw new Error(ErrorMessage.failure()); diff --git a/test/integration/application-log-assertion-with-cucumber-report/karma-reporter/index.js b/test/integration/application-log-assertion-with-cucumber-report/karma-reporter/index.js new file mode 100644 index 00000000..265fc59d --- /dev/null +++ b/test/integration/application-log-assertion-with-cucumber-report/karma-reporter/index.js @@ -0,0 +1,31 @@ +"use strict"; + +const writer = require("./writer"); + +const CucumberReporter = function(baseReporterDecorator, config, logger, helper) { + const log = logger.create("reporter.testReporter"); + const reporterConfig = config.testReporter || {}; + const out = reporterConfig.out; + const specs = []; + + baseReporterDecorator(this); + + this.adapters = [function(msg) { + process.stdout.write.bind(process.stdout)(msg); + }]; + + this.onSpecComplete = function(browser, result) { + specs.push(result); + }; + + this.onRunComplete = function() { + const jsonResult = JSON.stringify(specs, null, 2) + "\n"; + writer(helper, out, log, jsonResult); + }; +}; + +CucumberReporter.$inject = ["baseReporterDecorator", "config", "logger", "helper"]; + +module.exports = { + "reporter:testReporter": ["type", CucumberReporter] +}; diff --git a/test/integration/application-log-assertion-with-cucumber-report/karma-reporter/writer.js b/test/integration/application-log-assertion-with-cucumber-report/karma-reporter/writer.js new file mode 100644 index 00000000..dfe91d8c --- /dev/null +++ b/test/integration/application-log-assertion-with-cucumber-report/karma-reporter/writer.js @@ -0,0 +1,16 @@ +"use strict"; + +const path = require("path"); +const fs = require("fs"); + +module.exports = function(helper, out, log, jsonResult) { + helper.mkdirIfNotExists(path.dirname(out), function() { + fs.writeFile(out, jsonResult, function(err) { + if (err) { + log.error("Cannot write JSON\n\t" + err.message); + } else { + log.info("JSON written to %s", out); + } + }); + }); +}; diff --git a/test/integration/application-log-assertion-with-cucumber-report/karma.conf.js b/test/integration/application-log-assertion-with-cucumber-report/karma.conf.js new file mode 100644 index 00000000..b19c0b4d --- /dev/null +++ b/test/integration/application-log-assertion-with-cucumber-report/karma.conf.js @@ -0,0 +1,64 @@ +const customCucumberReporter = require("./karma-reporter/index"); +const customKarmaUI5 = require("../../../lib/index"); + +module.exports = function(config) { + "use strict"; + + require("../karma-base.conf")(config); + config.set({ + plugins: [ + "karma-chrome-launcher", + "karma-coverage", + customKarmaUI5, + customCucumberReporter + ], + + ui5: { + type: "application", + mode: "html", + testpage: "webapp/test/GherkinTestRunner.html", + url: "http://localhost:" + config.localUI5ServerPort, + logAssertions: true, + logHTMLFilePath: false + }, + + frameworks: ["ui5"], + + preprocessors: { + "{webapp,webapp/!(test)}/*.js": ["coverage"] + }, + testReporter: { + out: "application-log-assertion-with-cucumber-report/reports/test_report.json" + }, + + coverageReporter: { + includeAllSources: true, + reporters: [ + { + type: "json", + dir: "coverage", + subdir: "json" + } + ], + check: { + each: { + statements: 100, + branches: 100, + functions: 100, + lines: 100 + } + } + }, + autoWatch: false, + singleRun: true, + + reporters: ["progress", "coverage", "testReporter"] + + }); +}; + +module.exports.assertions = function({expect, log}) { + const features = require("./reports/test_report.json"); + expect(features).toHaveLength(21); + expect(features[0].suite[0]).toBe("Feature: Clicking Buttons Is a Life Saving Activity"); +}; diff --git a/test/integration/application-log-assertion-with-cucumber-report/webapp/test/GherkinTestRunner.html b/test/integration/application-log-assertion-with-cucumber-report/webapp/test/GherkinTestRunner.html new file mode 100644 index 00000000..93674544 --- /dev/null +++ b/test/integration/application-log-assertion-with-cucumber-report/webapp/test/GherkinTestRunner.html @@ -0,0 +1,23 @@ + + + + + Using Gherkin with OPA5 + + + + + + + +
+
+ + + + diff --git a/test/integration/application-log-assertion-with-cucumber-report/webapp/test/GherkinTestRunner.js b/test/integration/application-log-assertion-with-cucumber-report/webapp/test/GherkinTestRunner.js new file mode 100644 index 00000000..ae04cf07 --- /dev/null +++ b/test/integration/application-log-assertion-with-cucumber-report/webapp/test/GherkinTestRunner.js @@ -0,0 +1,21 @@ +/* global QUnit */ +window.QUnit = { + config: { + autostart: false + } +}; + +sap.ui.require([ + "sap/ui/test/gherkin/opa5TestHarness", + // Code coverage will be calculated for all modules loaded after the harness + "GherkinWithOPA5/Steps" +], function(opa5TestHarness, Steps) { + "use strict"; + + opa5TestHarness.test({ + featurePath: "GherkinWithOPA5.Requirements1", + steps: Steps + }); + + QUnit.start(); +}); diff --git a/test/integration/application-log-assertion-with-cucumber-report/webapp/test/Requirements1.feature b/test/integration/application-log-assertion-with-cucumber-report/webapp/test/Requirements1.feature new file mode 100644 index 00000000..71211cee --- /dev/null +++ b/test/integration/application-log-assertion-with-cucumber-report/webapp/test/Requirements1.feature @@ -0,0 +1,23 @@ +Feature: Clicking Buttons Is a Life Saving Activity + Clicking buttons saves lemmings' lives. For the mere cost of a cheap home PC you + can save thousands of lemmings daily by clicking buttons all day long. + + Background: + Given I have started the app + And I can see the life saving button + + Scenario: Click a button, save a life! + Given I check how many lemmings have been saved already + When I click on the life saving button + Then I save a lemming's life + + Scenario: The saved lemming has a name + When I click on the life saving button + Then I see Alice at the end of the list of named lemmings + + @wip + Scenario: Lemmings don't really throw themselves off cliffs + Given there was a documentary of lemmings throwing themselves off a cliff + Given this film greatly affected people's perception of lemmings + Given this part of the film was faked + Then we expect the myth of suicide lemmings to persist despite its falsity diff --git a/test/integration/application-log-assertion-with-cucumber-report/webapp/test/Steps.js b/test/integration/application-log-assertion-with-cucumber-report/webapp/test/Steps.js new file mode 100644 index 00000000..218eaf24 --- /dev/null +++ b/test/integration/application-log-assertion-with-cucumber-report/webapp/test/Steps.js @@ -0,0 +1,49 @@ +sap.ui.define([ + "sap/base/Log", + "sap/ui/test/gherkin/StepDefinitions", + "sap/ui/test/Opa5" +], function(Log, StepDefinitions, Opa5) { + "use strict"; + + + const Steps = StepDefinitions.extend("GherkinWithOPA5.Steps", { + init: function() { + this.register(/^I have started the app$/i, function() { + Opa5.assert.strictEqual(true, true); + }); + + this.register(/^I can see the life saving button$/i, function() { + Opa5.assert.strictEqual("Save a Lemming", "Save a Lemming", + "Verified that we can see the life saving button"); + }); + + this.register(/^I check how many lemmings have been saved already$/i, function() { + Opa5.assert.strictEqual(true, true); + }); + + this.register(/^I click on the life saving button\s*(\d*)?(?:\s*times)?$/i, function(sNumTimes) { + Opa5.assert.strictEqual(true, true); + }); + + this.register(/^I save a lemming's life$/i, function() { + Opa5.assert.strictEqual(1, 1, "Verified correct number of lemmings saved"); + }); + + this.register(/^I can see the following named lemmings:$/i, function(aDataTable) { + aDataTable.forEach(function(sLemmingName, iLemmingId) { + Opa5.assert.strictEqual(sLemmingName, sLemmingName, "Verified lemming: " + sLemmingName); + }); + }); + + this.register(/^I see (\w+) at the end of the list of named lemmings$/i, function(sName) { + Opa5.assert.strictEqual(sName, sName, "Verified lemming: " + sName); + }); + }, + + closeApplication: function() { + Log.info("Closing application"); + } + }); + + return Steps; +}); diff --git a/test/integration/application-log-assertion-with-cucumber-report/webapp/test/manifest.json b/test/integration/application-log-assertion-with-cucumber-report/webapp/test/manifest.json new file mode 100644 index 00000000..85cf4bb2 --- /dev/null +++ b/test/integration/application-log-assertion-with-cucumber-report/webapp/test/manifest.json @@ -0,0 +1,26 @@ +{ + "sap.app": { + "id": "sap.ui.core.sample.gherkin.GherkinWithOPA5", + "applicationVersion": { + "version": "1.0.0" + } + }, + "sap.ui5": { + "config": { + "sample": { + "iframe": "GherkinTestRunner.html", + "stretch": true, + "files": [ + "GherkinTestRunner.html", + "GherkinTestRunner.js", + "Requirements1.feature", + "Requirements2.feature", + "Steps.js", + "Website.html", + "WebsiteCode.js", + "manifest.json" + ] + } + } + } +} \ No newline at end of file diff --git a/test/integration/application-log-assertion/karma-reporter/index.js b/test/integration/application-log-assertion/karma-reporter/index.js new file mode 100644 index 00000000..265fc59d --- /dev/null +++ b/test/integration/application-log-assertion/karma-reporter/index.js @@ -0,0 +1,31 @@ +"use strict"; + +const writer = require("./writer"); + +const CucumberReporter = function(baseReporterDecorator, config, logger, helper) { + const log = logger.create("reporter.testReporter"); + const reporterConfig = config.testReporter || {}; + const out = reporterConfig.out; + const specs = []; + + baseReporterDecorator(this); + + this.adapters = [function(msg) { + process.stdout.write.bind(process.stdout)(msg); + }]; + + this.onSpecComplete = function(browser, result) { + specs.push(result); + }; + + this.onRunComplete = function() { + const jsonResult = JSON.stringify(specs, null, 2) + "\n"; + writer(helper, out, log, jsonResult); + }; +}; + +CucumberReporter.$inject = ["baseReporterDecorator", "config", "logger", "helper"]; + +module.exports = { + "reporter:testReporter": ["type", CucumberReporter] +}; diff --git a/test/integration/application-log-assertion/karma-reporter/writer.js b/test/integration/application-log-assertion/karma-reporter/writer.js new file mode 100644 index 00000000..dfe91d8c --- /dev/null +++ b/test/integration/application-log-assertion/karma-reporter/writer.js @@ -0,0 +1,16 @@ +"use strict"; + +const path = require("path"); +const fs = require("fs"); + +module.exports = function(helper, out, log, jsonResult) { + helper.mkdirIfNotExists(path.dirname(out), function() { + fs.writeFile(out, jsonResult, function(err) { + if (err) { + log.error("Cannot write JSON\n\t" + err.message); + } else { + log.info("JSON written to %s", out); + } + }); + }); +}; diff --git a/test/integration/application-log-assertion/karma.conf.js b/test/integration/application-log-assertion/karma.conf.js new file mode 100644 index 00000000..ec286318 --- /dev/null +++ b/test/integration/application-log-assertion/karma.conf.js @@ -0,0 +1,62 @@ +const customCucumberReporter = require("./karma-reporter/index"); +const customKarmaUI5 = require("../../../lib/index"); + +module.exports = function(config) { + "use strict"; + + require("../karma-base.conf")(config); + config.set({ + plugins: [ + "karma-chrome-launcher", + "karma-coverage", + customKarmaUI5, + customCucumberReporter + ], + + ui5: { + type: "application", + mode: "html", + testpage: "webapp/test/GherkinTestRunner.html", + url: "http://localhost:" + config.localUI5ServerPort, + logAssertions: true + }, + + frameworks: ["ui5"], + + preprocessors: { + "{webapp,webapp/!(test)}/*.js": ["coverage"] + }, + testReporter: { + out: "application-log-assertion/reports/test_report.json" + }, + + coverageReporter: { + includeAllSources: true, + reporters: [ + { + type: "json", + dir: "coverage", + subdir: "json" + } + ], + check: { + each: { + statements: 100, + branches: 100, + functions: 100, + lines: 100 + } + } + }, + autoWatch: false, + singleRun: true, + + reporters: ["progress", "coverage", "testReporter"] + + }); +}; + +module.exports.assertions = function({expect, log}) { + const features = require("./reports/test_report.json"); + expect(features).toHaveLength(21); +}; diff --git a/test/integration/application-log-assertion/webapp/test/GherkinTestRunner.html b/test/integration/application-log-assertion/webapp/test/GherkinTestRunner.html new file mode 100644 index 00000000..93674544 --- /dev/null +++ b/test/integration/application-log-assertion/webapp/test/GherkinTestRunner.html @@ -0,0 +1,23 @@ + + + + + Using Gherkin with OPA5 + + + + + + + +
+
+ + + + diff --git a/test/integration/application-log-assertion/webapp/test/GherkinTestRunner.js b/test/integration/application-log-assertion/webapp/test/GherkinTestRunner.js new file mode 100644 index 00000000..ae04cf07 --- /dev/null +++ b/test/integration/application-log-assertion/webapp/test/GherkinTestRunner.js @@ -0,0 +1,21 @@ +/* global QUnit */ +window.QUnit = { + config: { + autostart: false + } +}; + +sap.ui.require([ + "sap/ui/test/gherkin/opa5TestHarness", + // Code coverage will be calculated for all modules loaded after the harness + "GherkinWithOPA5/Steps" +], function(opa5TestHarness, Steps) { + "use strict"; + + opa5TestHarness.test({ + featurePath: "GherkinWithOPA5.Requirements1", + steps: Steps + }); + + QUnit.start(); +}); diff --git a/test/integration/application-log-assertion/webapp/test/Requirements1.feature b/test/integration/application-log-assertion/webapp/test/Requirements1.feature new file mode 100644 index 00000000..71211cee --- /dev/null +++ b/test/integration/application-log-assertion/webapp/test/Requirements1.feature @@ -0,0 +1,23 @@ +Feature: Clicking Buttons Is a Life Saving Activity + Clicking buttons saves lemmings' lives. For the mere cost of a cheap home PC you + can save thousands of lemmings daily by clicking buttons all day long. + + Background: + Given I have started the app + And I can see the life saving button + + Scenario: Click a button, save a life! + Given I check how many lemmings have been saved already + When I click on the life saving button + Then I save a lemming's life + + Scenario: The saved lemming has a name + When I click on the life saving button + Then I see Alice at the end of the list of named lemmings + + @wip + Scenario: Lemmings don't really throw themselves off cliffs + Given there was a documentary of lemmings throwing themselves off a cliff + Given this film greatly affected people's perception of lemmings + Given this part of the film was faked + Then we expect the myth of suicide lemmings to persist despite its falsity diff --git a/test/integration/application-log-assertion/webapp/test/Steps.js b/test/integration/application-log-assertion/webapp/test/Steps.js new file mode 100644 index 00000000..2617eb3e --- /dev/null +++ b/test/integration/application-log-assertion/webapp/test/Steps.js @@ -0,0 +1,48 @@ +sap.ui.define([ + "sap/base/Log", + "sap/ui/test/gherkin/StepDefinitions", + "sap/ui/test/Opa5" +], function(Log, StepDefinitions, Opa5) { + "use strict"; + + const Steps = StepDefinitions.extend("GherkinWithOPA5.Steps", { + init: function() { + this.register(/^I have started the app$/i, function() { + Opa5.assert.strictEqual(true, true); + }); + + this.register(/^I can see the life saving button$/i, function() { + Opa5.assert.strictEqual("Save a Lemming", "Save a Lemming", + "Verified that we can see the life saving button"); + }); + + this.register(/^I check how many lemmings have been saved already$/i, function() { + Opa5.assert.strictEqual(true, true); + }); + + this.register(/^I click on the life saving button\s*(\d*)?(?:\s*times)?$/i, function(sNumTimes) { + Opa5.assert.strictEqual(true, true); + }); + + this.register(/^I save a lemming's life$/i, function() { + Opa5.assert.strictEqual(1, 1, "Verified correct number of lemmings saved"); + }); + + this.register(/^I can see the following named lemmings:$/i, function(aDataTable) { + aDataTable.forEach(function(sLemmingName, iLemmingId) { + Opa5.assert.strictEqual(sLemmingName, sLemmingName, "Verified lemming: " + sLemmingName); + }); + }); + + this.register(/^I see (\w+) at the end of the list of named lemmings$/i, function(sName) { + Opa5.assert.strictEqual(sName, sName, "Verified lemming: " + sName); + }); + }, + + closeApplication: function() { + Log.info("Closing application"); + } + }); + + return Steps; +}); diff --git a/test/integration/application-log-assertion/webapp/test/manifest.json b/test/integration/application-log-assertion/webapp/test/manifest.json new file mode 100644 index 00000000..85cf4bb2 --- /dev/null +++ b/test/integration/application-log-assertion/webapp/test/manifest.json @@ -0,0 +1,26 @@ +{ + "sap.app": { + "id": "sap.ui.core.sample.gherkin.GherkinWithOPA5", + "applicationVersion": { + "version": "1.0.0" + } + }, + "sap.ui5": { + "config": { + "sample": { + "iframe": "GherkinTestRunner.html", + "stretch": true, + "files": [ + "GherkinTestRunner.html", + "GherkinTestRunner.js", + "Requirements1.feature", + "Requirements2.feature", + "Steps.js", + "Website.html", + "WebsiteCode.js", + "manifest.json" + ] + } + } + } +} \ No newline at end of file diff --git a/test/integration/application-proxy/karma.conf.js b/test/integration/application-proxy/karma.conf.js index fc43815a..4a8fdb59 100644 --- a/test/integration/application-proxy/karma.conf.js +++ b/test/integration/application-proxy/karma.conf.js @@ -43,5 +43,8 @@ module.exports.assertions = function({expect, log}) { const coverage = require("./coverage/json/coverage-final.json"); const files = Object.keys(coverage); expect(files).toHaveLength(1); - expect(files[0]).toEndWith("application-proxy/webapp/foo.js"); + const sWindowsExpect = "application-proxy\\webapp\\foo.js"; + const sLinuxExpect = "application-proxy/webapp/foo.js"; + const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect); + expect(sActual).toEndWith(sLinuxExpect); }; diff --git a/test/integration/application-script-mode/karma.conf.js b/test/integration/application-script-mode/karma.conf.js index e460d4f3..70f08c13 100644 --- a/test/integration/application-script-mode/karma.conf.js +++ b/test/integration/application-script-mode/karma.conf.js @@ -58,5 +58,9 @@ module.exports.assertions = function({expect, log}) { const coverage = require("./coverage/json/coverage-final.json"); const files = Object.keys(coverage); expect(files).toHaveLength(1); - expect(files[0]).toEndWith("application-script-mode/webapp/foo.js"); + + const sWindowsExpect = "application-script-mode\\webapp\\foo.js"; + const sLinuxExpect = "application-script-mode/webapp/foo.js"; + const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect); + expect(sActual).toEndWith(sLinuxExpect); }; diff --git a/test/integration/application-tooling-script-mode/karma.conf.js b/test/integration/application-tooling-script-mode/karma.conf.js index c749ee38..fc625d72 100644 --- a/test/integration/application-tooling-script-mode/karma.conf.js +++ b/test/integration/application-tooling-script-mode/karma.conf.js @@ -57,5 +57,9 @@ module.exports.assertions = function({expect, log}) { const coverage = require("./coverage/json/coverage-final.json"); const files = Object.keys(coverage); expect(files).toHaveLength(1); - expect(files[0]).toEndWith("application-tooling-script-mode/webapp/foo.js"); + + const sWindowsExpect = "application-tooling-script-mode\\webapp\\foo.js"; + const sLinuxExpect = "application-tooling-script-mode/webapp/foo.js"; + const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect); + expect(sActual).toEndWith(sLinuxExpect); }; diff --git a/test/integration/application-ui5-tooling-iframe/karma.conf.js b/test/integration/application-ui5-tooling-iframe/karma.conf.js index 8debd2dd..b0f0b9c7 100644 --- a/test/integration/application-ui5-tooling-iframe/karma.conf.js +++ b/test/integration/application-ui5-tooling-iframe/karma.conf.js @@ -40,7 +40,10 @@ module.exports = function(config) { module.exports.assertions = function({expect, log}) { const coverage = require("./coverage/json/coverage-final.json"); + const sWindowsExpect = "application-ui5-tooling-iframe\\webapp\\foo.js"; + const sLinuxExpect = "application-ui5-tooling-iframe/webapp/foo.js"; const files = Object.keys(coverage); expect(files).toHaveLength(1); - expect(files[0]).toEndWith("application-ui5-tooling-iframe/webapp/foo.js"); + const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect); + expect(sActual).toEndWith(sLinuxExpect); }; diff --git a/test/integration/application-ui5-tooling/karma.conf.js b/test/integration/application-ui5-tooling/karma.conf.js index 74ad9486..586d032b 100644 --- a/test/integration/application-ui5-tooling/karma.conf.js +++ b/test/integration/application-ui5-tooling/karma.conf.js @@ -39,5 +39,9 @@ module.exports.assertions = function({expect, log}) { const coverage = require("./coverage/json/coverage-final.json"); const files = Object.keys(coverage); expect(files).toHaveLength(1); - expect(files[0]).toEndWith("application-ui5-tooling/webapp/foo.js"); + + const sWindowsExpect = "application-ui5-tooling\\webapp\\foo.js"; + const sLinuxExpect = "application-ui5-tooling/webapp/foo.js"; + const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect); + expect(sActual).toEndWith(sLinuxExpect); }; diff --git a/test/integration/library-custompath/karma.conf.js b/test/integration/library-custompath/karma.conf.js index 3f9ca77e..57aa2862 100644 --- a/test/integration/library-custompath/karma.conf.js +++ b/test/integration/library-custompath/karma.conf.js @@ -47,5 +47,9 @@ module.exports.assertions = function({expect, log}) { const coverage = require("./coverage/json/coverage-final.json"); const files = Object.keys(coverage); expect(files).toHaveLength(1); - expect(files[0]).toEndWith("library-custompath/src/main/js/sap/test/lib/library.js"); + + const sWindowsExpect = "library-custompath\\src\\main\\js\\sap\\test\\lib\\library.js"; + const sLinuxExpect = "library-custompath/src/main/js/sap/test/lib/library.js"; + const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect); + expect(sActual).toEndWith(sLinuxExpect); }; diff --git a/test/integration/library-proxy/karma.conf.js b/test/integration/library-proxy/karma.conf.js index 8b70a79e..a82293bf 100644 --- a/test/integration/library-proxy/karma.conf.js +++ b/test/integration/library-proxy/karma.conf.js @@ -43,5 +43,9 @@ module.exports.assertions = function({expect, log}) { const coverage = require("./coverage/json/coverage-final.json"); const files = Object.keys(coverage); expect(files).toHaveLength(1); - expect(files[0]).toEndWith("library-proxy/src/sap/test/lib/library.js"); + + const sWindowsExpect = "library-proxy\\src\\sap\\test\\lib\\library.js"; + const sLinuxExpect = "library-proxy/src/sap/test/lib/library.js"; + const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect); + expect(sActual).toEndWith(sLinuxExpect); }; diff --git a/test/integration/library-script-mode/karma.conf.js b/test/integration/library-script-mode/karma.conf.js index 8583ca50..e6cc1ba9 100644 --- a/test/integration/library-script-mode/karma.conf.js +++ b/test/integration/library-script-mode/karma.conf.js @@ -53,5 +53,9 @@ module.exports.assertions = function({expect, log}) { const coverage = require("./coverage/json/coverage-final.json"); const files = Object.keys(coverage); expect(files).toHaveLength(1); - expect(files[0]).toEndWith("library-script-mode/src/sap/test/lib/library.js"); + + const sWindowsExpect = "library-script-mode\\src\\sap\\test\\lib\\library.js"; + const sLinuxExpect = "library-script-mode/src/sap/test/lib/library.js"; + const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect); + expect(sActual).toEndWith(sLinuxExpect); }; diff --git a/test/integration/library-tooling-script-mode/karma.conf.js b/test/integration/library-tooling-script-mode/karma.conf.js index 1cdd018f..9efd57b3 100644 --- a/test/integration/library-tooling-script-mode/karma.conf.js +++ b/test/integration/library-tooling-script-mode/karma.conf.js @@ -51,5 +51,9 @@ module.exports.assertions = function({expect, log}) { const coverage = require("./coverage/json/coverage-final.json"); const files = Object.keys(coverage); expect(files).toHaveLength(1); - expect(files[0]).toEndWith("library-tooling-script-mode/src/sap/test/lib/library.js"); + + const sWindowsExpect = "library-tooling-script-mode\\src\\sap\\test\\lib\\library.js"; + const sLinuxExpect = "library-tooling-script-mode/src/sap/test/lib/library.js"; + const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect); + expect(sActual).toEndWith(sLinuxExpect); }; diff --git a/test/integration/library-ui5-tooling-multiple-testsuites/karma.conf.js b/test/integration/library-ui5-tooling-multiple-testsuites/karma.conf.js index e3ab619b..f5fdada3 100644 --- a/test/integration/library-ui5-tooling-multiple-testsuites/karma.conf.js +++ b/test/integration/library-ui5-tooling-multiple-testsuites/karma.conf.js @@ -42,5 +42,9 @@ module.exports.assertions = function({expect, log}) { const coverage = require("./coverage/json/coverage-final.json"); const files = Object.keys(coverage); expect(files).toHaveLength(1); - expect(files[0]).toEndWith("library-ui5-tooling-multiple-testsuites/src/sap/test/lib/library.js"); + + const sWindowsExpect = "library-ui5-tooling-multiple-testsuites\\src\\sap\\test\\lib\\library.js"; + const sLinuxExpect = "library-ui5-tooling-multiple-testsuites/src/sap/test/lib/library.js"; + const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect); + expect(sActual).toEndWith(sLinuxExpect); }; diff --git a/test/integration/library-ui5-tooling/karma.conf.js b/test/integration/library-ui5-tooling/karma.conf.js index 963669f0..cf6657c5 100644 --- a/test/integration/library-ui5-tooling/karma.conf.js +++ b/test/integration/library-ui5-tooling/karma.conf.js @@ -1,3 +1,4 @@ + module.exports = function(config) { "use strict"; @@ -38,5 +39,9 @@ module.exports.assertions = function({expect, log}) { const coverage = require("./coverage/json/coverage-final.json"); const files = Object.keys(coverage); expect(files).toHaveLength(1); - expect(files[0]).toEndWith("library-ui5-tooling/src/sap/test/lib/library.js"); + + const sWindowsExpect = "library-ui5-tooling\\src\\sap\\test\\lib\\library.js"; + const sLinuxExpect = "library-ui5-tooling/src/sap/test/lib/library.js"; + const sActual = files[0] && files[0].replace(sWindowsExpect, sLinuxExpect); + expect(sActual).toEndWith(sLinuxExpect); }; diff --git a/test/unit/framework.test.js b/test/unit/framework.test.js index 24bd4035..81650952 100644 --- a/test/unit/framework.test.js +++ b/test/unit/framework.test.js @@ -1035,7 +1035,8 @@ describe("Error logging", () => { const config = { frameworks: ["foo", "ui5"] }; - await expect(framework.init({config, logger})).rejects.toThrow(ErrorMessage.failure()); // some unrelated exception + await expect(framework.init({config, logger})).rejects. + toThrow(ErrorMessage.failure()); // some unrelated exception expect(framework.logger.message).not.toBe(ErrorMessage.incompatibleFrameworks(["foo", "ui5"])); });