SAP-samples/ui5-typescript-tutorial

Issue to run script karma in ex6

MPMela opened this issue · 6 comments

MPMela commented

Hi,

in ex6, when running "npm run karma" one get the following error message and the OPA test fails:
2024-06-26 19:52:58.544000 Unable to load the component with the name: com.myorg.myapp
Opa timeout after 15 seconds
This is what Opa logged:
Executing OPA check function on controls null - sap.ui.test.Opa5
Check function is:
function() {
if (!mPromiseState.started) {
mPromiseState.started = true;
oPromise.then(function () {
mPromiseState.done = true;
}, function (error) {
mPromiseState.errorMessage = "Error while waiting for promise scheduled on flow" +
(error ? ", details: " + getErrorMessage(error) : "");
});
}
if (mPromiseState.errorMessage) {
throw new Error(mPromiseState.errorMessage);
} else {
return !!mPromiseState.done;
}
} - sap.ui.test.Opa5
Result of check function is: false - sap.ui.test.Opa5
Callstack:
at MainPage._schedulePromiseOnFlow (http://localhost:9876/base/webapp/resources/sap/ui/test/Opa.js:682:16)
at oStartComponentOptions.success (http://localhost:9876/base/webapp/resources/sap/ui/test/Opa5.js:201:42)
at oOptionsPassedToOpa.success (http://localhost:9876/base/webapp/resources/sap/ui/test/Opa5.js:852:24)
at MainPage. (http://localhost:9876/base/webapp/resources/sap/ui/test/Opa.js:612:24)
at opaCheck (http://localhost:9876/base/webapp/resources/sap/ui/test/Opa.js:54:18)
at internalWait (http://localhost:9876/base/webapp/resources/sap/ui/test/Opa.js:48:3)
at http://localhost:9876/base/webapp/resources/sap/ui/test/Opa.js:103:4
Callstack:
at MainPage.iStartMyUIComponent (http://localhost:9876/base/webapp/resources/sap/ui/test/Opa5.js:205:9)
at Object. (http://localhost:9876/base/webapp/test/integration/HelloJourney.js:12:19)
at Object. (http://localhost:9876/base/webapp/resources/sap/ui/test/opaQunit.js:239:21)
at runTest (http://localhost:9876/base/webapp/resources/sap/ui/thirdparty/qunit-2.js:1457:30)
at Test.run (http://localhost:9876/base/webapp/resources/sap/ui/thirdparty/qunit-2.js:1443:6)
at http://localhost:9876/base/webapp/resources/sap/ui/thirdparty/qunit-2.js:1635:12
at Object.advance (http://localhost:9876/base/webapp/resources/sap/ui/thirdparty/qunit-2.js:1120:26) - Opa sap.ui.test.Opa

Please let me know in case you are able to solve tjis.
Thanks and regards,
Marie

akudev commented

Hi @MPMela, well, it does not fail for me. Did you create the code from scratch by following the exercise steps or does it also fail for you when you try from the code in the repository like this?

git clone https://github.com/SAP-samples/ui5-typescript-tutorial.git
cd ui5-typescript-tutorial/exercises/ex6/com.myorg.myapp
npm i
npm run karma

If this also fails, then the code is the same, but our systems seem to be different. I tried on Mac, and you? The OPA tests are run in Chrome... you have Chrome installed? Maybe karma-chrome-launcher cannot find or launch it? Or do you see Chrome open? Can you successfully run other tests using karma-chrome-launcher?

MPMela commented

Hi,
thanks for the answer.
I cloned the repository and launched the test without modification of code.
I'm on Windows. I have Chrome. Chrome opens and seems fine at start. Other tests can be launched fine on my computer. It's really an issue in the OPA test. When running headless or on Chrome I can see that 3 of the tests of Ex6 are OK: the unit tests. The OPA test fails.
You can see above from the error message that the issue is in the HelloJourney.js file.

Best regards,
Marie

akudev commented

Hi @MPMela
I tried again on a Windows PC and it also worked, doing exactly the steps I mentioned above.
This was with Chrome 126, Windows 10 and Node 18 and also with Node 20.

All kinds of things could be special on your system: a browser plugin that interferes with the page, a too old or new (dev) version of Node, some network host settings, firewall settings, ...

Is there any other info you can give, like failed network requests?

What happens if you do the following to run OPA tests in another app?

git clone https://github.com/SAP/openui5-sample-app.git
cd openui5-sample-app
npm i
npm run karma

Regards
Andreas

MPMela commented

Hi @akudev
I updated from node 18 to node 20 and it was not working on the first launch but ran OK on relaunch when everything was loaded.
Then I did as indicated within https://community.sap.com/t5/technology-q-a/opa5-timeout-increase/qaq-p/737461 and increased Opa and Qunit timeouts. Now it works fine.
Thanks and regards,
Marie

akudev commented

Hi @MPMela , so you think this can be closed or is there anything left? Should we maybe in general talk about the Opa timeouts?

MPMela commented

Hi Andreas,
for me it is fine and can be closed.
Thanks and regards,
Marie