Skip to content

Commit

Permalink
Update tests to wait for the Core to be booted (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
petermuessig authored Oct 23, 2024
1 parent e483250 commit f626114
Show file tree
Hide file tree
Showing 25 changed files with 79 additions and 55 deletions.
7 changes: 4 additions & 3 deletions steps/27/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,17 @@ 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 */
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();
});
```
Expand Down
5 changes: 3 additions & 2 deletions steps/27/webapp/test/unit/unitTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
12 changes: 6 additions & 6 deletions steps/28/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

```

***
Expand Down
5 changes: 3 additions & 2 deletions steps/28/webapp/test/integration/opaTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/28/webapp/test/unit/unitTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/29/webapp/test/integration/opaTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/29/webapp/test/unit/unitTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/30/webapp/test/integration/opaTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/30/webapp/test/unit/unitTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/31/webapp/test/integration/opaTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/31/webapp/test/unit/unitTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/32/webapp/test/integration/opaTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/32/webapp/test/unit/unitTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/33/webapp/test/integration/opaTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/33/webapp/test/unit/unitTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/34/webapp/test/integration/opaTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/34/webapp/test/unit/unitTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/35/webapp/test/integration/opaTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/35/webapp/test/unit/unitTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/36/webapp/test/integration/opaTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/36/webapp/test/unit/unitTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/37/webapp/test/integration/opaTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/37/webapp/test/unit/unitTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/38/webapp/test/integration/opaTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
5 changes: 3 additions & 2 deletions steps/38/webapp/test/unit/unitTests.qunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

0 comments on commit f626114

Please sign in to comment.