Skip to content

Commit f626114

Browse files
authored
Update tests to wait for the Core to be booted (#62)
1 parent e483250 commit f626114

File tree

25 files changed

+79
-55
lines changed

25 files changed

+79
-55
lines changed

steps/27/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,17 @@ QUnit.test("Should return the translated texts", (assert) => {
8282
### webapp/test/unit/unitTests.qunit.ts \(New\)
8383

8484
We create a new `unitTests.qunit.ts` file under `webapp/test/unit/`.
85-
This script loads and executes our formatter.
85+
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()`.
8686

8787
```ts
8888
/* @sapUiRequire */
8989
QUnit.config.autostart = false;
9090

9191
// import all your QUnit tests here
9292
void Promise.all([
93-
import("ui5/walkthrough/test/unit/model/formatter")
94-
]).then(() => {
93+
import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests
94+
import("ui5/walkthrough/test/unit/model/formatter"),
95+
]).then(([{default: Core}]) => Core.ready()).then(() => {
9596
QUnit.start();
9697
});
9798
```

steps/27/webapp/test/unit/unitTests.qunit.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ QUnit.config.autostart = false;
33

44
// import all your QUnit tests here
55
void Promise.all([
6-
import("ui5/walkthrough/test/unit/model/formatter")
7-
]).then(() => {
6+
import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests
7+
import("ui5/walkthrough/test/unit/model/formatter"),
8+
]).then(([{default: Core}]) => Core.ready()).then(() => {
89
QUnit.start();
910
});

steps/28/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,19 @@ As you can see, the test case reads like a user story, we actually do not need t
132132

133133
We create a new `opaTests.qunit.ts` file under `webapp/test/integration/`.
134134

135-
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.
135+
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()`.
136136

137137
```ts
138-
138+
/* @sapUiRequire */
139139
QUnit.config.autostart = false;
140140

141-
// import all your OPA tests here
141+
// import all your integration tests here
142142
void Promise.all([
143-
import("ui5/walkthrough/test/integration/NavigationJourney")
144-
]).then(() => {
143+
import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests
144+
import("ui5/walkthrough/test/integration/NavigationJourney"),
145+
]).then(([{default: Core}]) => Core.ready()).then(() => {
145146
QUnit.start();
146147
});
147-
148148
```
149149

150150
***

steps/28/webapp/test/integration/opaTests.qunit.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ QUnit.config.autostart = false;
33

44
// import all your integration tests here
55
void Promise.all([
6-
import("ui5/walkthrough/test/integration/NavigationJourney")
7-
]).then(() => {
6+
import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests
7+
import("ui5/walkthrough/test/integration/NavigationJourney"),
8+
]).then(([{default: Core}]) => Core.ready()).then(() => {
89
QUnit.start();
910
});

steps/28/webapp/test/unit/unitTests.qunit.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ QUnit.config.autostart = false;
33

44
// import all your QUnit tests here
55
void Promise.all([
6-
import("ui5/walkthrough/test/unit/model/formatter")
7-
]).then(() => {
6+
import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests
7+
import("ui5/walkthrough/test/unit/model/formatter"),
8+
]).then(([{default: Core}]) => Core.ready()).then(() => {
89
QUnit.start();
910
});

steps/29/webapp/test/integration/opaTests.qunit.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ QUnit.config.autostart = false;
33

44
// import all your integration tests here
55
void Promise.all([
6-
import("ui5/walkthrough/test/integration/NavigationJourney")
7-
]).then(() => {
6+
import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests
7+
import("ui5/walkthrough/test/integration/NavigationJourney"),
8+
]).then(([{default: Core}]) => Core.ready()).then(() => {
89
QUnit.start();
910
});

steps/29/webapp/test/unit/unitTests.qunit.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ QUnit.config.autostart = false;
33

44
// import all your QUnit tests here
55
void Promise.all([
6-
import("ui5/walkthrough/test/unit/model/formatter")
7-
]).then(() => {
6+
import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests
7+
import("ui5/walkthrough/test/unit/model/formatter"),
8+
]).then(([{default: Core}]) => Core.ready()).then(() => {
89
QUnit.start();
910
});

steps/30/webapp/test/integration/opaTests.qunit.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ QUnit.config.autostart = false;
33

44
// import all your integration tests here
55
void Promise.all([
6-
import("ui5/walkthrough/test/integration/NavigationJourney")
7-
]).then(() => {
6+
import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests
7+
import("ui5/walkthrough/test/integration/NavigationJourney"),
8+
]).then(([{default: Core}]) => Core.ready()).then(() => {
89
QUnit.start();
910
});

steps/30/webapp/test/unit/unitTests.qunit.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ QUnit.config.autostart = false;
33

44
// import all your QUnit tests here
55
void Promise.all([
6-
import("ui5/walkthrough/test/unit/model/formatter")
7-
]).then(() => {
6+
import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests
7+
import("ui5/walkthrough/test/unit/model/formatter"),
8+
]).then(([{default: Core}]) => Core.ready()).then(() => {
89
QUnit.start();
910
});

steps/31/webapp/test/integration/opaTests.qunit.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ QUnit.config.autostart = false;
33

44
// import all your integration tests here
55
void Promise.all([
6-
import("ui5/walkthrough/test/integration/NavigationJourney")
7-
]).then(() => {
6+
import("sap/ui/core/Core"), // required to wait until Core has booted to start the QUnit tests
7+
import("ui5/walkthrough/test/integration/NavigationJourney"),
8+
]).then(([{default: Core}]) => Core.ready()).then(() => {
89
QUnit.start();
910
});

0 commit comments

Comments
 (0)