REserve — Testing UI5 — Probing the tests

Declaring the tests

<!DOCTYPE html>
<html>
<head>
<title>QUnit TestSuite for OpenUI5 Todo App</title>
<script src="../resources/sap/ui/qunit/qunit-redirect.js"></script>
<script>
/**
* Add test pages to this test suite function.
*/

function suite() {
var oSuite = new parent.jsUnitTestSuite(),
sContextPath = location.pathname.substring(0, location.pathname.lastIndexOf("/") + 1);
oSuite.addTestPage(sContextPath + "unit/unitTests.qunit.html"); var xhr = new XMLHttpRequest();
xhr.open("GET", "integration/AllJourneys.json", false);
xhr.send(null);
JSON.parse(xhr.responseText).forEach(function (name) {
oSuite.addTestPage(sContextPath + "integration/opaTests.qunit.html?journey=" + name);
});
return oSuite;
}
</script>
</head>
<body>
</body>
</html>

Test suite extraction

(function () {
'use strict'
/* global suite */ const pages = [] function jsUnitTestSuite () {} jsUnitTestSuite.prototype.addTestPage = function (url) {
if (!url.startsWith('/')) {
url = '/' + url
}
pages.push(url)
}
window.jsUnitTestSuite = jsUnitTestSuite window.addEventListener('load', function () {
suite()
const xhr = new XMLHttpRequest()
xhr.open('POST', '/_/addTestPages')
xhr.send(JSON.stringify(pages))
})
}())
{
// Substitute qunit-redirect to extract test pages
match: '/resources/sap/ui/qunit/qunit-redirect.js',
file: join(__dirname, './inject/qunit-redirect.js')
}, {
// Endpoint to receive test pages
match: '/_/addTestPages',
custom: endpoint((url, data) => {
job.testPageUrls = data
stop(url)
})
}
/* ... */
server
.on('ready', async ({ url, port }) => {
job.port = port
if (!job.logServer) {
console.log(`Server running at ${url}`)
}
await start('/test/testsuite.qunit.html')
})

Next step

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store