使用Karma运行OPA5测试时出错

时间:2017-10-12 14:50:34

标签: sapui5 karma-runner

我正在尝试使用grunt和karma运行OPA5集成测试。

收到此错误消息:error Message

当我运行opaTests.qunit.html时,测试工作正常,所以我认为它必须与Gruntfile中的karma属性有关。 调用opaTest函数时,NavigationJourney.js中会发生错误。

Gruntfile.js业力部分:

karma: {
            options: {
                basePath: rootDirectory,
                frameworks: ["openui5", "qunit"],
                openui5: {
                    path: "https://openui5.hana.ondemand.com/1.38.23/resources/sap-ui-core.js",
                    useMockServer: false
                },
                client: {
                    openui5: {
                        config: {
                            compatVersion: "edge",
                            preload: "async",
                            resourceroots: {
                                "bitflow.web": "./base"
                            }
                        }
                    }
                },
                files: [
                    { pattern: "test/karma-main.js", included: true, served: true, watched: true }, 
                    { pattern: "**", included: false, served: true, watched: true}

                ],
                proxies: {
                    "/test/": "/base/test",
                    "/test/integration/pages": "/base/test/integration/pages",
                    "base/resources/": "http://localhost:8080/resources"
                },
                reporters: ["progress"],
                port: 9876,
                logLevel: "DEBUG",
                browsers: ["Chrome"]
            },
            watch: {
                client: {                       
                    clearContext: false,
                    qunit: {
                        showUI: true
                    }
                }
            },
        }
    });

npm依赖项:

"devDependencies": {
"eslint-detailed-reporter": "^0.7.2",
"grunt": "^1.0.1",
"grunt-eslint": "^20.0.0",
"grunt-karma": "^2.0.0",
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.2.0",
"karma-firefox-launcher": "^1.0.1",
"karma-phantomjs-launcher": "^1.0.4",
"karma-openui5": "^0.2.2",
"karma-qunit": "^1.2.1",
"karma-sinon": "^1.0.5",
"qunitjs": "^2.0.0"
  }

果报main.js

(function (karma) {
"use strict";

// Prevent Karma from running prematurely.
karma.loaded = function () { };

sap.ui.getCore().attachInit(function () {
    sap.ui.require([
        //unit tests can be added here too
        "bitflow/web/test/integration/AllJourneys"
    ], function () {
        // Finally, start Karma to run the tests.
        karma.start();
    });
});
})(window.__karma__);

AllJourneys

sap.ui.define([
"sap/ui/test/Opa5",
"bitflow/web/test/integration/pages/Common",
"bitflow/web/test/integration/pages/App",
"bitflow/web/test/integration/NavigationJourney"
], function(Opa5, Common) {
"use strict";
Opa5.extendConfig({
    arrangements: new Common(),
    viewNamespace: "bitflow.web.view",
    pollingInterval: 1
});
});

NavigationJourney

sap.ui.define([
"sap/ui/test/opaQunit",
"bitflow/web/test/integration/pages/App"
], function(opaTest) {
"use strict";

QUnit.module("Navigation");

opaTest("Should See Page", function(Given, When, Then) {
    Given.iStartMyApp();

    Then.onTheAppPage.iShouldSeeThePage();
});

0 个答案:

没有答案