3

I've created few tests (Specs) in Protractor - that every test works fine when running alone. the problem is that when executing them as one suite - the tests break. I'd like to add some operation in between the tests - such as timeout or logout. is there an option to do it? I've tried looking here: https://github.com/angular/protractor/blob/master/docs/referenceConf.js

this is my conf.js file (the specs part):

suites:{
    sanity: ['*/AccountSettingsTest.js','*/createApptest.js']

},

specs: ['*/AccountSettingsTest.js'],

thanks

user2880391
  • 2,683
  • 7
  • 38
  • 77

2 Answers2

1

I believe you can use jasmine afterAll function. It should run after the describe block in your test. Just your logout/timeout function into an afterAll block inside of your describe block, and for that spec file, it will run after the describe. Since you have multiple specs, I imagine you'll want it in each spec file, as the order the files run in may vary.

From the jasmine docs:

describe("A spec using beforeAll and afterAll", function() {
  var foo;

  beforeAll(function() {
      foo = 1;
  });

  afterAll(function() {
      foo = 0;
  });

  it("sets the initial value of foo before specs run", function() {
      expect(foo).toEqual(1);
      foo += 1;
  });

  it("does not reset foo between specs", function() {
      expect(foo).toEqual(2);
  });
});
user2020347
  • 883
  • 7
  • 17
0

You can indeed try to add the below line in your conf.js file to restart your browser between tests -

restartBrowserBetweenTests: false,

In order to keep a default timeout add below line in jasmineNodeOpts object -

defaultTimeoutInterval: 30000

A detailed explanation is given in the referenceConf.js file

giri-sh
  • 6,934
  • 2
  • 25
  • 50
  • @user2880391 , can you please clarify the problem you are facing if the above answer isnt the one you are looking for. – giri-sh Aug 24 '15 at 13:24