如何在 Protractor 的 onPrepare 中同时使用函数和规范文件?

How to use both a function and a spec file in Protractor 's onPrepare?

这两个我都需要做

onPrepare: function () {
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
},

还有这个

onPrepare: 'login.spec.js',

量角器配置的 onPrepare 接受函数或规范文件

但我需要同时使用我需要启用 jasmine-spec-reporter 的功能和我需要一个 spec 文件来登录。我该怎么做?

我见过合并多个函数或处理多个浏览器等的其他问题,但不是这个确切的问题

为什么登录需要spec文件?您应该只编写一个页面对象或一个处理登录的帮助程序 class,然后从 onPrepare 调用它。

onPrepare: function () {
    jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true }}));

    const loginPage = new LoginPage();
    loginPage.login(username, pw);
},