0
votes

I'm currently using protractor jasmine to test our Angular4 application. Our application has 2 modules (Form1 and Form2). Form1 needs to be completed first before an applicant can proceed to Form2. In e2e, how can I chain my Form2 to Form1 so that after Form1 is finished it will call the Form2 spec test (Form 2 will not login anymore). Note: I need the form1 and form2 tests in its own separated spec file.

form1.test-spec.ts

describe('Form 1 Test', function() {
  beforeAll(() => {
    commonService.doLogin();
  });

 it('scenario1' () => {
    //test for form1
    //Call form2.test-spec.ts
  });
});

form2.test-spec.ts

describe('Form 2 Test', function() {

 it('scenario1' () => {
    //test for form2
  });

});
1

1 Answers

1
votes

Inside your conf.js file is where you will make change

seleniumAddress: 'http://localhost:4444/wd/hub',
specs: 'spec1',
framework: 'jasmine2',

Assuming that your current conf.js file looks similar to this, you will change the specs option to

specs: ['form1.test-spec.ts','form2.test-spec.ts'],

This would make the spec files be separate, and they will run in sequence as long as you don't have it setup to be run in parallel. It is also possible to have multiple describes in the same file which will run in sequence, albeit with being in the same file.

describe('Form 1 Test', function() { 
   it('should do a thing',function(){}); 
});
describe('Form 2 Test', function() { 
   it('should do a different thing',function(){}); 
});