From 2b74a5bc726d40352a007f8de78382a834b553d8 Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Mon, 15 Jul 2019 21:29:32 +0200 Subject: [PATCH 1/9] [INTERNAL] Add error handling integration tests --- test/integration.test.js | 26 ++++++++++++++++--- .../karma-empty-testsuite.conf.js | 19 ++++++++++++++ .../karma-testsuite-promise-reject.conf.js | 19 ++++++++++++++ .../package.json | 7 +++++ .../ui5.yaml | 5 ++++ .../test/empty-testsuite/testsuite.qunit.html | 9 +++++++ .../test/empty-testsuite/testsuite.qunit.js | 10 +++++++ .../testsuite.qunit.html | 9 +++++++ .../testsuite.qunit.js | 7 +++++ 9 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 test/integration/application-ui5-tooling-error-handling/karma-empty-testsuite.conf.js create mode 100644 test/integration/application-ui5-tooling-error-handling/karma-testsuite-promise-reject.conf.js create mode 100644 test/integration/application-ui5-tooling-error-handling/package.json create mode 100644 test/integration/application-ui5-tooling-error-handling/ui5.yaml create mode 100644 test/integration/application-ui5-tooling-error-handling/webapp/test/empty-testsuite/testsuite.qunit.html create mode 100644 test/integration/application-ui5-tooling-error-handling/webapp/test/empty-testsuite/testsuite.qunit.js create mode 100644 test/integration/application-ui5-tooling-error-handling/webapp/test/testsuite-promise-reject/testsuite.qunit.html create mode 100644 test/integration/application-ui5-tooling-error-handling/webapp/test/testsuite-promise-reject/testsuite.qunit.js diff --git a/test/integration.test.js b/test/integration.test.js index 5f6b257d..8fa08f8c 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -4,19 +4,37 @@ const execa = require("execa"); const registerIntegrationTest = async (configPath) => { it(configPath, async () => { + const fullConfigPath = path.join(__dirname, configPath); + const integrationTest = require(fullConfigPath); const args = [ "start", - path.join(__dirname, configPath) + fullConfigPath ]; if (process.argv[process.argv.length - 1] === "--browsers=IE") { // Allow switching to IE by passing a CLI arg args.push("--browsers=IE"); } - await execa("karma", args, { + const karmaProcess = await execa("karma", args, { cwd: __dirname, - stdio: "inherit", - preferLocal: true // allow executing local karma binary + preferLocal: true, // allow executing local karma binary + reject: false }); + // eslint-disable-next-line no-console + console.log(karmaProcess.all); + + if (integrationTest.shouldFail && !karmaProcess.failed) { + throw new Error("Karma execution should have failed!"); + } + if (!integrationTest.shouldFail && karmaProcess.failed) { + throw new Error("Karma execution should not have failed!"); + } + + if (integrationTest.assertions) { + integrationTest.assertions({ + expect, + log: karmaProcess.all + }); + } }); }; diff --git a/test/integration/application-ui5-tooling-error-handling/karma-empty-testsuite.conf.js b/test/integration/application-ui5-tooling-error-handling/karma-empty-testsuite.conf.js new file mode 100644 index 00000000..f198176d --- /dev/null +++ b/test/integration/application-ui5-tooling-error-handling/karma-empty-testsuite.conf.js @@ -0,0 +1,19 @@ +module.exports = function(config) { + "use strict"; + + require("../karma-base.conf")(config); + config.set({ + + frameworks: ["ui5"], + + ui5: { + testpage: "webapp/test/empty-testsuite/testsuite.qunit.html" + } + + }); +}; + +module.exports.shouldFail = true; +module.exports.assertions = ({expect, log}) => { + expect(log).toMatch(/No tests \(TBD\)/); +}; diff --git a/test/integration/application-ui5-tooling-error-handling/karma-testsuite-promise-reject.conf.js b/test/integration/application-ui5-tooling-error-handling/karma-testsuite-promise-reject.conf.js new file mode 100644 index 00000000..0a5c801e --- /dev/null +++ b/test/integration/application-ui5-tooling-error-handling/karma-testsuite-promise-reject.conf.js @@ -0,0 +1,19 @@ +module.exports = function(config) { + "use strict"; + + require("../karma-base.conf")(config); + config.set({ + + frameworks: ["ui5"], + + ui5: { + testpage: "webapp/test/testsuite-promise-reject/testsuite.qunit.html" + } + + }); +}; + +module.exports.shouldFail = true; +module.exports.assertions = ({expect, log}) => { + expect(log).toMatch(/Error from testsuite/); +}; diff --git a/test/integration/application-ui5-tooling-error-handling/package.json b/test/integration/application-ui5-tooling-error-handling/package.json new file mode 100644 index 00000000..3da38d38 --- /dev/null +++ b/test/integration/application-ui5-tooling-error-handling/package.json @@ -0,0 +1,7 @@ +{ + "name": "application-ui5-tooling-error-handling", + "version": "1.0.0", + "dependencies": { + "@openui5/sap.ui.core": "*" + } +} diff --git a/test/integration/application-ui5-tooling-error-handling/ui5.yaml b/test/integration/application-ui5-tooling-error-handling/ui5.yaml new file mode 100644 index 00000000..4a0e0b4d --- /dev/null +++ b/test/integration/application-ui5-tooling-error-handling/ui5.yaml @@ -0,0 +1,5 @@ +--- +specVersion: "1.0" +type: application +metadata: + name: test.app diff --git a/test/integration/application-ui5-tooling-error-handling/webapp/test/empty-testsuite/testsuite.qunit.html b/test/integration/application-ui5-tooling-error-handling/webapp/test/empty-testsuite/testsuite.qunit.html new file mode 100644 index 00000000..2b3fe8c4 --- /dev/null +++ b/test/integration/application-ui5-tooling-error-handling/webapp/test/empty-testsuite/testsuite.qunit.html @@ -0,0 +1,9 @@ + + + + Testsuite + + + + + diff --git a/test/integration/application-ui5-tooling-error-handling/webapp/test/empty-testsuite/testsuite.qunit.js b/test/integration/application-ui5-tooling-error-handling/webapp/test/empty-testsuite/testsuite.qunit.js new file mode 100644 index 00000000..0f0abbc7 --- /dev/null +++ b/test/integration/application-ui5-tooling-error-handling/webapp/test/empty-testsuite/testsuite.qunit.js @@ -0,0 +1,10 @@ +/* global window, parent, location */ + +window.suite = function() { + "use strict"; + + // eslint-disable-next-line + var oSuite = new parent.jsUnitTestSuite(); + + return oSuite; +}; diff --git a/test/integration/application-ui5-tooling-error-handling/webapp/test/testsuite-promise-reject/testsuite.qunit.html b/test/integration/application-ui5-tooling-error-handling/webapp/test/testsuite-promise-reject/testsuite.qunit.html new file mode 100644 index 00000000..2b3fe8c4 --- /dev/null +++ b/test/integration/application-ui5-tooling-error-handling/webapp/test/testsuite-promise-reject/testsuite.qunit.html @@ -0,0 +1,9 @@ + + + + Testsuite + + + + + diff --git a/test/integration/application-ui5-tooling-error-handling/webapp/test/testsuite-promise-reject/testsuite.qunit.js b/test/integration/application-ui5-tooling-error-handling/webapp/test/testsuite-promise-reject/testsuite.qunit.js new file mode 100644 index 00000000..68c7dcca --- /dev/null +++ b/test/integration/application-ui5-tooling-error-handling/webapp/test/testsuite-promise-reject/testsuite.qunit.js @@ -0,0 +1,7 @@ +/* global window, parent, location */ + +window.suite = function() { + "use strict"; + + return Promise.reject(new Error("Error from testsuite")); +}; From 3d7c65e279d10bd24aecc5dd8eaeb03da02c9f67 Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Tue, 16 Jul 2019 09:25:23 +0200 Subject: [PATCH 2/9] [INTERNAL] Fix linting issues --- .../webapp/test/empty-testsuite/testsuite.qunit.js | 2 +- .../webapp/test/testsuite-promise-reject/testsuite.qunit.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/application-ui5-tooling-error-handling/webapp/test/empty-testsuite/testsuite.qunit.js b/test/integration/application-ui5-tooling-error-handling/webapp/test/empty-testsuite/testsuite.qunit.js index 0f0abbc7..4b46d4bc 100644 --- a/test/integration/application-ui5-tooling-error-handling/webapp/test/empty-testsuite/testsuite.qunit.js +++ b/test/integration/application-ui5-tooling-error-handling/webapp/test/empty-testsuite/testsuite.qunit.js @@ -1,4 +1,4 @@ -/* global window, parent, location */ +/* global window, parent */ window.suite = function() { "use strict"; diff --git a/test/integration/application-ui5-tooling-error-handling/webapp/test/testsuite-promise-reject/testsuite.qunit.js b/test/integration/application-ui5-tooling-error-handling/webapp/test/testsuite-promise-reject/testsuite.qunit.js index 68c7dcca..fc2d4a24 100644 --- a/test/integration/application-ui5-tooling-error-handling/webapp/test/testsuite-promise-reject/testsuite.qunit.js +++ b/test/integration/application-ui5-tooling-error-handling/webapp/test/testsuite-promise-reject/testsuite.qunit.js @@ -1,4 +1,4 @@ -/* global window, parent, location */ +/* global window */ window.suite = function() { "use strict"; From 0677d89412c945405e770ffe04332c5a3585cf2f Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Mon, 29 Jul 2019 15:33:58 +0200 Subject: [PATCH 3/9] [FIX] Client-side Error handling --- lib/client/.eslintrc.js | 5 ++-- lib/client/browser.js | 24 +++++++++++++++---- lib/client/discovery.js | 15 ++++-------- .../karma-empty-testsuite.conf.js | 2 +- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/lib/client/.eslintrc.js b/lib/client/.eslintrc.js index b167b5f6..6f3fc3e5 100644 --- a/lib/client/.eslintrc.js +++ b/lib/client/.eslintrc.js @@ -3,7 +3,6 @@ module.exports = { "browser": true }, "globals": { - "sap": "readonly", - "karma": "readonly" + "sap": "readonly" } -} \ No newline at end of file +} diff --git a/lib/client/browser.js b/lib/client/browser.js index 39c6a11a..de83b943 100644 --- a/lib/client/browser.js +++ b/lib/client/browser.js @@ -4,6 +4,18 @@ require("./discovery.js"); (function(window) { const karma = window.__karma__; + function reportSetupFailure(description, error) { + karma.info({total: 1}); + karma.result({ + description: description, + suite: [], + success: false, + log: error ? [error] : [], + time: 0 + }); + karma.complete({}); + } + function setFullSize(element) { element.style.height = "100%"; element.style.padding = "0"; @@ -62,6 +74,7 @@ require("./discovery.js"); + "Please set a testpage in the config or via CLI.\n" + "For more details: https://github.com/SAP/karma-ui5#defining-testpage"] ); + // reportSetupFailure(); // TODO return; } @@ -75,6 +88,7 @@ require("./discovery.js"); + "\n\n" + "Please explicitly configure a \"testpage\" in your karma config or via CLI:\n" + "https://github.com/SAP/karma-ui5#defining-testpage"]); + // reportSetupFailure(); // TODO return; } @@ -84,13 +98,15 @@ require("./discovery.js"); config.testpage = prependBase(config.testpage); window.findTests(config.testpage).then(function(testpages) { + if (!testpages || testpages.length === 0) { + reportSetupFailure("Could not resolve any testpages!"); + return; + } runTests(testpages.map(function(testpage) { return testpage["fullpage"]; })); - }, function(e) { - // console.error("fail"); - karma.log("error", e.message); - // TODO: report error + }, function(err) { + reportSetupFailure("Error resolving testsuite: " + err.fullpage, err.error); }); function getTestsuites(files) { diff --git a/lib/client/discovery.js b/lib/client/discovery.js index dbc5e120..d317627f 100644 --- a/lib/client/discovery.js +++ b/lib/client/discovery.js @@ -2,6 +2,8 @@ const Promise = require("es6-promise").Promise; const assign = require("lodash.assign"); (function(window) { + const karma = window.__karma__; + /* * Simulate the same JSUnit Testsuite API as the TestRunner to collect the available test pages per suite */ @@ -80,11 +82,12 @@ const assign = require("lodash.assign"); simple: bPass }, oTestPageConfig)); }, function(oError) { - karma.log("error", ["failed to load page '" + oTestPageConfig.fullpage + "'"]); + karma.log("error", ["Failed to load page " + oTestPageConfig.fullpage]); + karma.log("error", [oError]); if (frame.parentNode) { frame.parentNode.removeChild(frame); } - resolve(assign({error: oError}, oTestPageConfig)); + reject(assign({error: oError}, oTestPageConfig)); }); }; @@ -110,11 +113,6 @@ const assign = require("lodash.assign"); resolve(oTestPageConfig); } }); - }).catch(function(e) { - const text = e.message; - karma.log("error", ["Failed to load page '" + oTestPageConfig.fullpage + "': " + text]); - // resolve(assign({error: text}, oTestPageConfig)); - return; }); } @@ -154,9 +152,6 @@ const assign = require("lodash.assign"); }). then( function(aPages) { return sequence(aPages); - }). - catch( function() { - return []; }); } diff --git a/test/integration/application-ui5-tooling-error-handling/karma-empty-testsuite.conf.js b/test/integration/application-ui5-tooling-error-handling/karma-empty-testsuite.conf.js index f198176d..22b9ac3d 100644 --- a/test/integration/application-ui5-tooling-error-handling/karma-empty-testsuite.conf.js +++ b/test/integration/application-ui5-tooling-error-handling/karma-empty-testsuite.conf.js @@ -15,5 +15,5 @@ module.exports = function(config) { module.exports.shouldFail = true; module.exports.assertions = ({expect, log}) => { - expect(log).toMatch(/No tests \(TBD\)/); + expect(log).toMatch(/Could not resolve any testpages/); }; From 8a23a27a42d122232fa2bfb9020049a2e7c21cc5 Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Fri, 23 Aug 2019 16:09:20 +0200 Subject: [PATCH 4/9] Fix error handling --- lib/client/discovery.js | 2 +- .../karma-initial-testsuite-not-found.conf.js | 19 +++++++++++++++++++ .../karma-testpage-not-found.conf.js | 19 +++++++++++++++++++ .../testpage-not-found/testsuite.qunit.html | 9 +++++++++ .../testpage-not-found/testsuite.qunit.js | 12 ++++++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 test/integration/application-ui5-tooling-error-handling/karma-initial-testsuite-not-found.conf.js create mode 100644 test/integration/application-ui5-tooling-error-handling/karma-testpage-not-found.conf.js create mode 100644 test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-not-found/testsuite.qunit.html create mode 100644 test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-not-found/testsuite.qunit.js diff --git a/lib/client/discovery.js b/lib/client/discovery.js index d317627f..23bf0019 100644 --- a/lib/client/discovery.js +++ b/lib/client/discovery.js @@ -112,7 +112,7 @@ const assign = require("lodash.assign"); } else { resolve(oTestPageConfig); } - }); + }).catch(reject); }); } diff --git a/test/integration/application-ui5-tooling-error-handling/karma-initial-testsuite-not-found.conf.js b/test/integration/application-ui5-tooling-error-handling/karma-initial-testsuite-not-found.conf.js new file mode 100644 index 00000000..1ee5bcad --- /dev/null +++ b/test/integration/application-ui5-tooling-error-handling/karma-initial-testsuite-not-found.conf.js @@ -0,0 +1,19 @@ +module.exports = function(config) { + "use strict"; + + require("../karma-base.conf")(config); + config.set({ + + frameworks: ["ui5"], + + ui5: { + testpage: "webapp/test/path-does-not-exist/testsuite.qunit.html" + } + + }); +}; + +module.exports.shouldFail = true; +module.exports.assertions = ({expect, log}) => { + expect(log).toMatch(/Error resolving testsuite/); +}; diff --git a/test/integration/application-ui5-tooling-error-handling/karma-testpage-not-found.conf.js b/test/integration/application-ui5-tooling-error-handling/karma-testpage-not-found.conf.js new file mode 100644 index 00000000..bef7bb92 --- /dev/null +++ b/test/integration/application-ui5-tooling-error-handling/karma-testpage-not-found.conf.js @@ -0,0 +1,19 @@ +module.exports = function(config) { + "use strict"; + + require("../karma-base.conf")(config); + config.set({ + + frameworks: ["ui5"], + + ui5: { + testpage: "webapp/test/testpage-not-found/testsuite.qunit.html" + } + + }); +}; + +module.exports.shouldFail = true; +module.exports.assertions = ({expect, log}) => { + expect(log).toMatch(/TBD/); +}; diff --git a/test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-not-found/testsuite.qunit.html b/test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-not-found/testsuite.qunit.html new file mode 100644 index 00000000..2b3fe8c4 --- /dev/null +++ b/test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-not-found/testsuite.qunit.html @@ -0,0 +1,9 @@ + + + + Testsuite + + + + + diff --git a/test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-not-found/testsuite.qunit.js b/test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-not-found/testsuite.qunit.js new file mode 100644 index 00000000..b63a2ced --- /dev/null +++ b/test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-not-found/testsuite.qunit.js @@ -0,0 +1,12 @@ +/* global window, parent */ + +window.suite = function() { + "use strict"; + + // eslint-disable-next-line + var oSuite = new parent.jsUnitTestSuite(); + + oSuite.addTestPage("/does/not/exist.qunit.html"); + + return oSuite; +}; From 2d0b7cc9bd53158777a3bf8e9e9b78b9ce6b213b Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Fri, 30 Aug 2019 09:45:46 +0200 Subject: [PATCH 5/9] Add error handling in case QUnit is not available --- lib/client/browser.js | 46 ++++++++++++++----- .../karma-testpage-QUnit-not-loaded.conf.js | 19 ++++++++ .../karma-testpage-not-found.conf.js | 2 +- .../testpage-QUnit-not-loaded/test.qunit.html | 13 ++++++ .../testsuite.qunit.html | 9 ++++ .../testsuite.qunit.js | 12 +++++ 6 files changed, 89 insertions(+), 12 deletions(-) create mode 100644 test/integration/application-ui5-tooling-error-handling/karma-testpage-QUnit-not-loaded.conf.js create mode 100644 test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-QUnit-not-loaded/test.qunit.html create mode 100644 test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-QUnit-not-loaded/testsuite.qunit.html create mode 100644 test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-QUnit-not-loaded/testsuite.qunit.js diff --git a/lib/client/browser.js b/lib/client/browser.js index de83b943..1c653495 100644 --- a/lib/client/browser.js +++ b/lib/client/browser.js @@ -136,16 +136,7 @@ require("./discovery.js"); let timer = null; let testResult = {}; - if (QUnit.begin) { - QUnit.begin(function(args) { - totalNumberOfTest += args.totalTests; - karma.info({total: totalNumberOfTest}); - }); - } - - QUnit.done(function() { - // Test page done - + function testFinished() { // Merge test page coverage into global coverage object mergeCoverage(testWindow.contentWindow.__coverage__); @@ -159,7 +150,40 @@ require("./discovery.js"); coverage: coverageMap ? coverageMap.toJSON() : undefined }); } - }); + } + + if (!QUnit) { + const log = []; + if (!testWindow.contentWindow.document.querySelector("script")) { + // Page doesn't have any script => probably 404 + log.push("Error while loading testpage"); + } else { + // QUnit couldn't be loaded + log.push("Missing QUnit for testpage"); + } + // Report a test failure + totalNumberOfTest += 1; + karma.info({total: totalNumberOfTest}); + karma.result( { + description: qunitHtmlFile, + suite: [], + success: false, + log: log, + time: 0 + }); + + testFinished(); + return; + } + + if (QUnit.begin) { + QUnit.begin(function(args) { + totalNumberOfTest += args.totalTests; + karma.info({total: totalNumberOfTest}); + }); + } + + QUnit.done(testFinished); QUnit.testStart(function(test) { timer = new Date().getTime(); diff --git a/test/integration/application-ui5-tooling-error-handling/karma-testpage-QUnit-not-loaded.conf.js b/test/integration/application-ui5-tooling-error-handling/karma-testpage-QUnit-not-loaded.conf.js new file mode 100644 index 00000000..893b0189 --- /dev/null +++ b/test/integration/application-ui5-tooling-error-handling/karma-testpage-QUnit-not-loaded.conf.js @@ -0,0 +1,19 @@ +module.exports = function(config) { + "use strict"; + + require("../karma-base.conf")(config); + config.set({ + + frameworks: ["ui5"], + + ui5: { + testpage: "webapp/test/testpage-QUnit-not-loaded/testsuite.qunit.html" + } + + }); +}; + +module.exports.shouldFail = true; +module.exports.assertions = ({expect, log}) => { + expect(log).toMatch(/Missing QUnit for testpage/); +}; diff --git a/test/integration/application-ui5-tooling-error-handling/karma-testpage-not-found.conf.js b/test/integration/application-ui5-tooling-error-handling/karma-testpage-not-found.conf.js index bef7bb92..92fbc783 100644 --- a/test/integration/application-ui5-tooling-error-handling/karma-testpage-not-found.conf.js +++ b/test/integration/application-ui5-tooling-error-handling/karma-testpage-not-found.conf.js @@ -15,5 +15,5 @@ module.exports = function(config) { module.exports.shouldFail = true; module.exports.assertions = ({expect, log}) => { - expect(log).toMatch(/TBD/); + expect(log).toMatch(/Error while loading testpage/); }; diff --git a/test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-QUnit-not-loaded/test.qunit.html b/test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-QUnit-not-loaded/test.qunit.html new file mode 100644 index 00000000..f32ac76f --- /dev/null +++ b/test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-QUnit-not-loaded/test.qunit.html @@ -0,0 +1,13 @@ + + + + + QUnit Test + + + + + +
+ + diff --git a/test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-QUnit-not-loaded/testsuite.qunit.html b/test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-QUnit-not-loaded/testsuite.qunit.html new file mode 100644 index 00000000..2b3fe8c4 --- /dev/null +++ b/test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-QUnit-not-loaded/testsuite.qunit.html @@ -0,0 +1,9 @@ + + + + Testsuite + + + + + diff --git a/test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-QUnit-not-loaded/testsuite.qunit.js b/test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-QUnit-not-loaded/testsuite.qunit.js new file mode 100644 index 00000000..5ed5b1c3 --- /dev/null +++ b/test/integration/application-ui5-tooling-error-handling/webapp/test/testpage-QUnit-not-loaded/testsuite.qunit.js @@ -0,0 +1,12 @@ +/* global window, parent */ + +window.suite = function() { + "use strict"; + + // eslint-disable-next-line + var oSuite = new parent.jsUnitTestSuite(), + sContextPath = location.pathname.substring(0, location.pathname.lastIndexOf("/") + 1); + oSuite.addTestPage(sContextPath + "test.qunit.html"); + + return oSuite; +}; From 93142e56f99d76dcd3c4c3b9464412de9af0a613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20O=C3=9Fwald?= <1410947+matz3@users.noreply.github.com> Date: Fri, 30 Aug 2019 13:41:34 +0200 Subject: [PATCH 6/9] Update lib/client/browser.js Co-Authored-By: Merlin Beutlberger --- lib/client/browser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/browser.js b/lib/client/browser.js index 1c653495..1ac2dcd8 100644 --- a/lib/client/browser.js +++ b/lib/client/browser.js @@ -159,7 +159,7 @@ require("./discovery.js"); log.push("Error while loading testpage"); } else { // QUnit couldn't be loaded - log.push("Missing QUnit for testpage"); + log.push("Missing QUnit framework"); } // Report a test failure totalNumberOfTest += 1; From edda8407078765112b684b392204300999478c07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20O=C3=9Fwald?= <1410947+matz3@users.noreply.github.com> Date: Fri, 30 Aug 2019 14:03:34 +0200 Subject: [PATCH 7/9] Update test/integration/application-ui5-tooling-error-handling/karma-testpage-QUnit-not-loaded.conf.js --- .../karma-testpage-QUnit-not-loaded.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/application-ui5-tooling-error-handling/karma-testpage-QUnit-not-loaded.conf.js b/test/integration/application-ui5-tooling-error-handling/karma-testpage-QUnit-not-loaded.conf.js index 893b0189..df9f96c0 100644 --- a/test/integration/application-ui5-tooling-error-handling/karma-testpage-QUnit-not-loaded.conf.js +++ b/test/integration/application-ui5-tooling-error-handling/karma-testpage-QUnit-not-loaded.conf.js @@ -15,5 +15,5 @@ module.exports = function(config) { module.exports.shouldFail = true; module.exports.assertions = ({expect, log}) => { - expect(log).toMatch(/Missing QUnit for testpage/); + expect(log).toMatch(/Missing QUnit framework/); }; From e4c59eaad3c48972b35d93ad153834182362083b Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Tue, 3 Sep 2019 14:53:06 +0200 Subject: [PATCH 8/9] [FIX] Add Access Denied error handling for IE --- lib/client/browser.js | 18 ++++++++++++++---- test/integration.test.js | 5 +++-- .../testsuite.qunit.html | 4 ++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lib/client/browser.js b/lib/client/browser.js index 1ac2dcd8..331d1033 100644 --- a/lib/client/browser.js +++ b/lib/client/browser.js @@ -132,13 +132,23 @@ require("./discovery.js"); function runTestPage(i) { const qunitHtmlFile = testpages[i]; windowUtil(qunitHtmlFile, function(testWindow) { - const QUnit = testWindow.contentWindow.QUnit; let timer = null; let testResult = {}; + let QUnit, accessError = false; + try { + QUnit = testWindow.contentWindow.QUnit; + } catch (err) { + console.error(err); + if (err.name === "TypeError" && err.message === "Permission denied") { + accessError = true; + } + } function testFinished() { // Merge test page coverage into global coverage object - mergeCoverage(testWindow.contentWindow.__coverage__); + if (!accessError) { + mergeCoverage(testWindow.contentWindow.__coverage__); + } // Run next test or trigger completion if (i < testpages.length - 1) { @@ -154,8 +164,8 @@ require("./discovery.js"); if (!QUnit) { const log = []; - if (!testWindow.contentWindow.document.querySelector("script")) { - // Page doesn't have any script => probably 404 + if (accessError || !testWindow.contentWindow.document.querySelector("script")) { + // Access Error (IE) or page doesn't have any script => probably 404 log.push("Error while loading testpage"); } else { // QUnit couldn't be loaded diff --git a/test/integration.test.js b/test/integration.test.js index 8fa08f8c..c231b662 100644 --- a/test/integration.test.js +++ b/test/integration.test.js @@ -19,8 +19,9 @@ const registerIntegrationTest = async (configPath) => { preferLocal: true, // allow executing local karma binary reject: false }); - // eslint-disable-next-line no-console - console.log(karmaProcess.all); + + console.log(configPath); // eslint-disable-line no-console + console.log(karmaProcess.all); // eslint-disable-line no-console if (integrationTest.shouldFail && !karmaProcess.failed) { throw new Error("Karma execution should have failed!"); diff --git a/test/integration/application-ui5-tooling-error-handling/webapp/test/testsuite-promise-reject/testsuite.qunit.html b/test/integration/application-ui5-tooling-error-handling/webapp/test/testsuite-promise-reject/testsuite.qunit.html index 2b3fe8c4..fea94de6 100644 --- a/test/integration/application-ui5-tooling-error-handling/webapp/test/testsuite-promise-reject/testsuite.qunit.html +++ b/test/integration/application-ui5-tooling-error-handling/webapp/test/testsuite-promise-reject/testsuite.qunit.html @@ -2,6 +2,10 @@ Testsuite + + + + From 01048f4e03736811651852e5cac66bea0e2a7db3 Mon Sep 17 00:00:00 2001 From: Matthias Osswald Date: Tue, 3 Sep 2019 15:46:08 +0200 Subject: [PATCH 9/9] Fix ESLint errors --- lib/client/browser.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/client/browser.js b/lib/client/browser.js index 331d1033..6823f030 100644 --- a/lib/client/browser.js +++ b/lib/client/browser.js @@ -134,13 +134,15 @@ require("./discovery.js"); windowUtil(qunitHtmlFile, function(testWindow) { let timer = null; let testResult = {}; - let QUnit, accessError = false; + let QUnit; + let accessError = false; try { QUnit = testWindow.contentWindow.QUnit; } catch (err) { - console.error(err); if (err.name === "TypeError" && err.message === "Permission denied") { accessError = true; + } else { + throw err; } }