praneeth mendu
praneeth mendu

Reputation: 409

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

I need to do both this

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

and this

onPrepare: 'login.spec.js',

Protractor config's onPrepare either takes a function or a spec file

But I need to use both I need the function to enable jasmine-spec-reporter and I need a spec file to login. How do I do both ?

I have seen other questions that merge multiple functions or address dealing with multiple browsers etc but not this exact problem

Upvotes: 1

Views: 97

Answers (1)

tehbeardedone
tehbeardedone

Reputation: 2858

Why do you need a spec file to login? You should just write a page object or a helper class that handles the login, and then call it from the onPrepare.

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

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

Upvotes: 2

Related Questions