
karma
was the go-to testrunner for executing Unit- and Integration-tests of UI5 applications. For end-to-end tests, wdi5
has become the default tool.karma
being deprecated, a void opened for a successor for running QUnit- and OPA-tests within the existing UI5 test tech stack - until wdio-qunit-service
arrived, allowing you to run Unit-, Integration- and end-to-end tests on the same stack.npm i && npm run test
and see for yourself ✌️karma
wdio-qunit-service
is the awesome work by longtime community member Mauricio Lauffer. As Mauricio puts it himself in the README
, "QUnit Service is a drop-in replacement for those using Karma JS to run their QUnit tests".wdi5
, following the respective naming convention:wdio-qunit-service
→ human readable "QUnit Service"wdio-ui5-service
→ human readable "wdi5"wdi5
for running end-to-end tests.wdio-qunit-service
, nor by "QUnit service" - the Webdriver.IO-extension is perfectly capable of running OPA tests as well, as they are based on QUnit!karma
dependency and using the same test runner for executing all Unit-, Integration- and end-to-end tests.karma
to "Qunit Service" is as easy declaring qunit
as a required service in the config file and putting a 7 (!) lines of JS code in a .test.(j|t)s
file.wdi5
and "QUnit Service"$> yo easy-ui5 app
wdi5
in the directory your app was created in:$> cd <your app dir>
$> npm init wdi5@latest
wdi5
config for you at webapp/test/e2e/wdio.conf.js
- which in turn is a Webdriver.IO-config file that can be re-used for executing the QUnit- and OPA-tests via wdio-qunit-service
!webapp/test/e2e/wdio.conf.js
to the unit test folder webapp/test/unit/
.qunit
to the services
array in ~line 134: services: ["ui5", "qunit"]
of webapp/test/unit/wdio.conf.js
.exports.config = {
// ...
services: ["ui5", "qunit"],
// ...
}
webapp/test/unit/unitTests.test.js
with this content:describe("QUnit test page", () => {
it("should pass QUnit tests", async () => {
await browser.url("http://localhost:8080/test/unit/unitTests.qunit.html");
const qunitResults = await browser.getQUnitResults();
expect(qunitResults).toBeTruthy();
});
});
webapp/test/unit/wdio.conf.js
(here: Chrome), opens the URL http://localhost:8080/test/unit/unitTests.qunit.html, and waits for the Unit Tests to run and finish via await browser.getQUnitResults()
).
└── webapp
└── test
├── e2e
│ ├── sample.test.js
│ └── wdio.conf.js
└── unit
├── unitTests.test.js
└── wdio.conf.js
$> npm start
for starting the UI5 app.$> npx wdio run ./webapp/test/unit/wdio.conf.js
...wdi5
.Webdriver.IO and wdio-qunit-service running Unit tests
webapp/test/unit/wdio.conf.js
into webapp/test/
and name it wdio.conf.shared.js
.wdio.conf.{e2e,integration,unit}.js
into each respective folder.const { config } = require("../wdio.conf.shared");
exports.config = config;
.
└── webapp
└── test
├── e2e
│ └── wdio.conf.e2e.js
├── integration
│ └── wdio.conf.integration.js
├── unit
│ └── wdio.conf.unit.js
└── wdio.conf.shared.js
wdio-qunit-service
/ wdio
the same way as it is for the QUnit unit tests:webapp/test/integration/integrationTests.test.js
:describe("QUnit test page", () => {
it("should pass QUnit tests", async () => {
await browser.url(
"http://localhost:8080/test/integration/opaTests.qunit.html"
);
const qunitResults = await browser.getQUnitResults();
expect(qunitResults).toBeTruthy();
});
});
.
└── webapp
├── test
│ ├── e2e
│ │ ├── sample.test.js
│ │ └── wdio.conf.e2e.js
│ ├── integration
│ │ ├── integrationTests.test.
│ │ └── wdio.conf.integration.js
│ ├── unit
│ │ ├── unitTests.test.js
│ │ └── wdio.conf.unit.js
│ └── wdio.conf.shared.js
└── view
package.json
with npm
scripts for running each test scope:{
//...
"scripts": {
//...
"test:unit": "wdio run ./webapp/test/unit/wdio.conf.unit.js",
"test:integration": "wdio run ./webapp/test/integration/wdio.conf.integration.js",
"test:e2e": "npm run wdi5",
"wdi5": "wdio run ./webapp/test/e2e/wdio.conf.e2e.js"
}
//...
}
wdio-qunit-service
!wdio-qunit-service
and wdi5
are Open Source and permit commercial use with their Apache 2.0 license.wdi5
-tests.You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
7 | |
7 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 |