From 5e2296ae81a3bbea8e38a3395cc04849e4487ff5 Mon Sep 17 00:00:00 2001 From: Peter Muessig Date: Wed, 16 Oct 2024 16:55:20 +0200 Subject: [PATCH] Update tests to wait for the Core to be booted --- steps/27/README.md | 7 ++++--- steps/27/webapp/test/unit/unitTests.qunit.ts | 5 +++-- steps/28/README.md | 12 ++++++------ steps/28/webapp/test/integration/opaTests.qunit.ts | 5 +++-- steps/28/webapp/test/unit/unitTests.qunit.ts | 5 +++-- steps/29/webapp/test/integration/opaTests.qunit.ts | 5 +++-- steps/29/webapp/test/unit/unitTests.qunit.ts | 5 +++-- steps/30/webapp/test/integration/opaTests.qunit.ts | 5 +++-- steps/30/webapp/test/unit/unitTests.qunit.ts | 5 +++-- steps/31/webapp/test/integration/opaTests.qunit.ts | 5 +++-- steps/31/webapp/test/unit/unitTests.qunit.ts | 5 +++-- steps/32/webapp/test/integration/opaTests.qunit.ts | 5 +++-- steps/32/webapp/test/unit/unitTests.qunit.ts | 5 +++-- steps/33/webapp/test/integration/opaTests.qunit.ts | 5 +++-- steps/33/webapp/test/unit/unitTests.qunit.ts | 5 +++-- steps/34/webapp/test/integration/opaTests.qunit.ts | 5 +++-- steps/34/webapp/test/unit/unitTests.qunit.ts | 5 +++-- steps/35/webapp/test/integration/opaTests.qunit.ts | 5 +++-- steps/35/webapp/test/unit/unitTests.qunit.ts | 5 +++-- steps/36/webapp/test/integration/opaTests.qunit.ts | 5 +++-- steps/36/webapp/test/unit/unitTests.qunit.ts | 5 +++-- steps/37/webapp/test/integration/opaTests.qunit.ts | 5 +++-- steps/37/webapp/test/unit/unitTests.qunit.ts | 5 +++-- steps/38/webapp/test/integration/opaTests.qunit.ts | 5 +++-- steps/38/webapp/test/unit/unitTests.qunit.ts | 5 +++-- 25 files changed, 79 insertions(+), 55 deletions(-) diff --git a/steps/27/README.md b/steps/27/README.md index edd1bf0a..81addb30 100644 --- a/steps/27/README.md +++ b/steps/27/README.md @@ -82,7 +82,7 @@ QUnit.test("Should return the translated texts", (assert) => { ### webapp/test/unit/unitTests.qunit.ts \(New\) We create a new `unitTests.qunit.ts` file under `webapp/test/unit/`. -This script loads and executes our formatter. +This script loads and executes our formatter test. Before the QUnit test execution can be started we need to wait until the Core has been booted. Therefore, you need to disable the autostart `QUnit.config.autostart = false;`, require the `sap/ui/core/Core` module and use `Core.ready()` to wait until the Core has booted and then you can start the QUnit tests with `QUnit.start()`. ```ts /* @sapUiRequire */ @@ -90,8 +90,9 @@ QUnit.config.autostart = false; // import all your QUnit tests here void Promise.all([ - import("ui5/walkthrough/test/unit/model/formatter") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/unit/model/formatter"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); ``` diff --git a/steps/27/webapp/test/unit/unitTests.qunit.ts b/steps/27/webapp/test/unit/unitTests.qunit.ts index f6c37f20..37b074ca 100644 --- a/steps/27/webapp/test/unit/unitTests.qunit.ts +++ b/steps/27/webapp/test/unit/unitTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your QUnit tests here void Promise.all([ - import("ui5/walkthrough/test/unit/model/formatter") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/unit/model/formatter"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/28/README.md b/steps/28/README.md index e76cea99..a5439534 100644 --- a/steps/28/README.md +++ b/steps/28/README.md @@ -132,19 +132,19 @@ As you can see, the test case reads like a user story, we actually do not need t We create a new `opaTests.qunit.ts` file under `webapp/test/integration/`. -We instruct QUnit to wait longer, allowing us to load our test files asynchronously. Then, we load the `NavigationJourney`, and execute the test functions inside immediately. +This script loads and executes our `NavigationJourney`. Before the QUnit test execution can be started we need to wait until the Core has been booted. Therefore, you need to disable the autostart `QUnit.config.autostart = false;`, require the `sap/ui/core/Core` module and use `Core.ready()` to wait until the Core has booted and then you can start the QUnit tests with `QUnit.start()`. ```ts - +/* @sapUiRequire */ QUnit.config.autostart = false; -// import all your OPA tests here +// import all your integration tests here void Promise.all([ - import("ui5/walkthrough/test/integration/NavigationJourney") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/integration/NavigationJourney"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); - ``` *** diff --git a/steps/28/webapp/test/integration/opaTests.qunit.ts b/steps/28/webapp/test/integration/opaTests.qunit.ts index 385bf4c8..785b3b0e 100644 --- a/steps/28/webapp/test/integration/opaTests.qunit.ts +++ b/steps/28/webapp/test/integration/opaTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your integration tests here void Promise.all([ - import("ui5/walkthrough/test/integration/NavigationJourney") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/integration/NavigationJourney"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/28/webapp/test/unit/unitTests.qunit.ts b/steps/28/webapp/test/unit/unitTests.qunit.ts index f6c37f20..37b074ca 100644 --- a/steps/28/webapp/test/unit/unitTests.qunit.ts +++ b/steps/28/webapp/test/unit/unitTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your QUnit tests here void Promise.all([ - import("ui5/walkthrough/test/unit/model/formatter") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/unit/model/formatter"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/29/webapp/test/integration/opaTests.qunit.ts b/steps/29/webapp/test/integration/opaTests.qunit.ts index 385bf4c8..785b3b0e 100644 --- a/steps/29/webapp/test/integration/opaTests.qunit.ts +++ b/steps/29/webapp/test/integration/opaTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your integration tests here void Promise.all([ - import("ui5/walkthrough/test/integration/NavigationJourney") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/integration/NavigationJourney"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/29/webapp/test/unit/unitTests.qunit.ts b/steps/29/webapp/test/unit/unitTests.qunit.ts index f6c37f20..37b074ca 100644 --- a/steps/29/webapp/test/unit/unitTests.qunit.ts +++ b/steps/29/webapp/test/unit/unitTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your QUnit tests here void Promise.all([ - import("ui5/walkthrough/test/unit/model/formatter") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/unit/model/formatter"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/30/webapp/test/integration/opaTests.qunit.ts b/steps/30/webapp/test/integration/opaTests.qunit.ts index 385bf4c8..785b3b0e 100644 --- a/steps/30/webapp/test/integration/opaTests.qunit.ts +++ b/steps/30/webapp/test/integration/opaTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your integration tests here void Promise.all([ - import("ui5/walkthrough/test/integration/NavigationJourney") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/integration/NavigationJourney"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/30/webapp/test/unit/unitTests.qunit.ts b/steps/30/webapp/test/unit/unitTests.qunit.ts index f6c37f20..37b074ca 100644 --- a/steps/30/webapp/test/unit/unitTests.qunit.ts +++ b/steps/30/webapp/test/unit/unitTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your QUnit tests here void Promise.all([ - import("ui5/walkthrough/test/unit/model/formatter") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/unit/model/formatter"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/31/webapp/test/integration/opaTests.qunit.ts b/steps/31/webapp/test/integration/opaTests.qunit.ts index 385bf4c8..785b3b0e 100644 --- a/steps/31/webapp/test/integration/opaTests.qunit.ts +++ b/steps/31/webapp/test/integration/opaTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your integration tests here void Promise.all([ - import("ui5/walkthrough/test/integration/NavigationJourney") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/integration/NavigationJourney"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/31/webapp/test/unit/unitTests.qunit.ts b/steps/31/webapp/test/unit/unitTests.qunit.ts index f6c37f20..37b074ca 100644 --- a/steps/31/webapp/test/unit/unitTests.qunit.ts +++ b/steps/31/webapp/test/unit/unitTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your QUnit tests here void Promise.all([ - import("ui5/walkthrough/test/unit/model/formatter") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/unit/model/formatter"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/32/webapp/test/integration/opaTests.qunit.ts b/steps/32/webapp/test/integration/opaTests.qunit.ts index 385bf4c8..785b3b0e 100644 --- a/steps/32/webapp/test/integration/opaTests.qunit.ts +++ b/steps/32/webapp/test/integration/opaTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your integration tests here void Promise.all([ - import("ui5/walkthrough/test/integration/NavigationJourney") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/integration/NavigationJourney"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/32/webapp/test/unit/unitTests.qunit.ts b/steps/32/webapp/test/unit/unitTests.qunit.ts index f6c37f20..37b074ca 100644 --- a/steps/32/webapp/test/unit/unitTests.qunit.ts +++ b/steps/32/webapp/test/unit/unitTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your QUnit tests here void Promise.all([ - import("ui5/walkthrough/test/unit/model/formatter") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/unit/model/formatter"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/33/webapp/test/integration/opaTests.qunit.ts b/steps/33/webapp/test/integration/opaTests.qunit.ts index 385bf4c8..785b3b0e 100644 --- a/steps/33/webapp/test/integration/opaTests.qunit.ts +++ b/steps/33/webapp/test/integration/opaTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your integration tests here void Promise.all([ - import("ui5/walkthrough/test/integration/NavigationJourney") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/integration/NavigationJourney"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/33/webapp/test/unit/unitTests.qunit.ts b/steps/33/webapp/test/unit/unitTests.qunit.ts index f6c37f20..37b074ca 100644 --- a/steps/33/webapp/test/unit/unitTests.qunit.ts +++ b/steps/33/webapp/test/unit/unitTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your QUnit tests here void Promise.all([ - import("ui5/walkthrough/test/unit/model/formatter") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/unit/model/formatter"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/34/webapp/test/integration/opaTests.qunit.ts b/steps/34/webapp/test/integration/opaTests.qunit.ts index 385bf4c8..785b3b0e 100644 --- a/steps/34/webapp/test/integration/opaTests.qunit.ts +++ b/steps/34/webapp/test/integration/opaTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your integration tests here void Promise.all([ - import("ui5/walkthrough/test/integration/NavigationJourney") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/integration/NavigationJourney"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/34/webapp/test/unit/unitTests.qunit.ts b/steps/34/webapp/test/unit/unitTests.qunit.ts index f6c37f20..37b074ca 100644 --- a/steps/34/webapp/test/unit/unitTests.qunit.ts +++ b/steps/34/webapp/test/unit/unitTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your QUnit tests here void Promise.all([ - import("ui5/walkthrough/test/unit/model/formatter") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/unit/model/formatter"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/35/webapp/test/integration/opaTests.qunit.ts b/steps/35/webapp/test/integration/opaTests.qunit.ts index 385bf4c8..785b3b0e 100644 --- a/steps/35/webapp/test/integration/opaTests.qunit.ts +++ b/steps/35/webapp/test/integration/opaTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your integration tests here void Promise.all([ - import("ui5/walkthrough/test/integration/NavigationJourney") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/integration/NavigationJourney"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/35/webapp/test/unit/unitTests.qunit.ts b/steps/35/webapp/test/unit/unitTests.qunit.ts index f6c37f20..37b074ca 100644 --- a/steps/35/webapp/test/unit/unitTests.qunit.ts +++ b/steps/35/webapp/test/unit/unitTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your QUnit tests here void Promise.all([ - import("ui5/walkthrough/test/unit/model/formatter") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/unit/model/formatter"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/36/webapp/test/integration/opaTests.qunit.ts b/steps/36/webapp/test/integration/opaTests.qunit.ts index 385bf4c8..785b3b0e 100644 --- a/steps/36/webapp/test/integration/opaTests.qunit.ts +++ b/steps/36/webapp/test/integration/opaTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your integration tests here void Promise.all([ - import("ui5/walkthrough/test/integration/NavigationJourney") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/integration/NavigationJourney"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/36/webapp/test/unit/unitTests.qunit.ts b/steps/36/webapp/test/unit/unitTests.qunit.ts index f6c37f20..37b074ca 100644 --- a/steps/36/webapp/test/unit/unitTests.qunit.ts +++ b/steps/36/webapp/test/unit/unitTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your QUnit tests here void Promise.all([ - import("ui5/walkthrough/test/unit/model/formatter") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/unit/model/formatter"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/37/webapp/test/integration/opaTests.qunit.ts b/steps/37/webapp/test/integration/opaTests.qunit.ts index 385bf4c8..785b3b0e 100644 --- a/steps/37/webapp/test/integration/opaTests.qunit.ts +++ b/steps/37/webapp/test/integration/opaTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your integration tests here void Promise.all([ - import("ui5/walkthrough/test/integration/NavigationJourney") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/integration/NavigationJourney"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/37/webapp/test/unit/unitTests.qunit.ts b/steps/37/webapp/test/unit/unitTests.qunit.ts index f6c37f20..37b074ca 100644 --- a/steps/37/webapp/test/unit/unitTests.qunit.ts +++ b/steps/37/webapp/test/unit/unitTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your QUnit tests here void Promise.all([ - import("ui5/walkthrough/test/unit/model/formatter") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/unit/model/formatter"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/38/webapp/test/integration/opaTests.qunit.ts b/steps/38/webapp/test/integration/opaTests.qunit.ts index 385bf4c8..785b3b0e 100644 --- a/steps/38/webapp/test/integration/opaTests.qunit.ts +++ b/steps/38/webapp/test/integration/opaTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your integration tests here void Promise.all([ - import("ui5/walkthrough/test/integration/NavigationJourney") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/integration/NavigationJourney"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); }); diff --git a/steps/38/webapp/test/unit/unitTests.qunit.ts b/steps/38/webapp/test/unit/unitTests.qunit.ts index f6c37f20..37b074ca 100644 --- a/steps/38/webapp/test/unit/unitTests.qunit.ts +++ b/steps/38/webapp/test/unit/unitTests.qunit.ts @@ -3,7 +3,8 @@ QUnit.config.autostart = false; // import all your QUnit tests here void Promise.all([ - import("ui5/walkthrough/test/unit/model/formatter") -]).then(() => { + import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests + import("ui5/walkthrough/test/unit/model/formatter"), +]).then(([{default: Core}]) => Core.ready()).then(() => { QUnit.start(); });