将组件的文件加载在不同组件的测试上下文中

问题描述 投票:0回答:1
I有一个SAPUI5应用程序,总共有5个组件:4个组件和1个共享组件,其中包含共享文件。所有它们都在根文件夹下。 第一个组件的代码使用共享组件中的文件,当我在UI中对其进行测试时,一切正常,没有任何问题。 当我运行测试时,问题会开始,并且从第一个测试开始失败。 经过长时间的调试会话并花了很多小时,我发现来自共享组件的文件未加载到Component1的测试上下文中。 以下是component 1:


文件(仅是我加载共享组件的部分)
manifest.js

I也更新了文件
"sap.ui5": { "resourceRoots": { "shared.component": "../shared-component/" } }

如下:

opaTests.qunit.html

I也添加了一个脚本到文件
data-sap-ui-resourceroots='{ "component1": "./../../", "shared.component": "./../../../shared-component" }'

以明确加载共享文件:

opaTests.qunit.html

我在SAPUI5文档中都找不到任何相关示例。
    

1。用于文件
<script> sap.ui.require.preload({ "path/to/shared/component/MessageBox.js": ` sap.ui.define([], function () { "use strict"; return { showWarningAsync: async function (sText, primaryAction, secondaryAction, sTitle) { return new Promise((resolve) => { console.log(\`Mock MessageBox.warning called with: Text: \${sText} Title: \${sTitle} Primary Action: \${primaryAction} Secondary Action: \${secondaryAction}\`); const oAction = primaryAction; resolve(oAction === primaryAction); }); } }; }); ` }); </script>

指向
opaTests.qunit.html

./resources
sapui5 ui5-tooling ui5-webcomponents
1个回答
0
投票
2。在测试站点的

data-sap-ui-resourceroots='{ "shared.component": "./resources/shared-component" }'

路径下共享组件。
./resources
    

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.