openui5
openui5 copied to clipboard
Global sap.ui.test.OpaBuilder returns undefined
For whatever reason, I'm trying to access global sap.ui.test.OpaBuilder and it returns undefined.
OpenUI5 version: All.
Browser/version (+device/version): Any browser.
URL (minimal example if possible): https://openui5.hana.ondemand.com/test-resources/sap/m/demokit/cart/webapp/test/integration/opaTestsComponent.qunit.html
Steps to reproduce the problem:
- Open DevTools
- Go to console
- Type
sap.ui.test.OpaBuilderand press enter
What is the expected result?
Should see sap.ui.test.OpaBuilder object.
What happens instead?
It returns undefined
Any other information? (attach screenshot if possible)
It doesn't matter what you do, OpaBuilder doesn't show up in the library sap.ui.test. Even if you load it, like the following example:
sap.ui.require([
"sap/ui/test/OpaBuilder"
], function (OpaBuilder) {
console.dir(sap.ui.test.Opa); //OK
console.dir(sap.ui.test.Opa5); //OK
console.dir(sap.ui.test.OpaBuilder); //undefined
console.dir(OpaBuilder); //OK
});
Thanks for bringing this up!
This is kind of a documentation issue.
As you might know, we slowly transition from global names as APIs to import-based APIs (using sap.ui.define/AMD in standard JavaScript or using ES6 imports when working with TypeScript). In line with this transition, newer APIs often no longer provide a global name and only export their API from the sap.ui.define call. That's the case for the OpaBuilder.
But unfortunately, the OpaBuilder documents a global name sap.ui.test.OpaBuilder and that's highly misleading. Other modules that don't have global exports, use JSDoc's module name syntax, e.g. module:sap/base/Log. The OpaBuilder should IMO do the same.
@codeworrior for the first time, I have a use case for globals and you tell me OpaBuilder isn't global... Oh, the irony 😆
Thanks for the response.
Hello @mauriciolauffer , Thank you for sharing this finding. I've created an internal incident 2370018538. The status of the issue will be updated here in GitHub.
Hello, I would rather close this item due to internal discussion inactivity. The general direction is to use modules and avoid exposing globals. If there is an important use case for exposing global here perhaps we can think of another approach but please do share with us. Best regards, Jordan