Reputation: 165
I am newbie to protractor and javascript. I am trying to execute several tests in parallel using multiCapabilities. However when I do this onPrepare or beforeAll are all executing once per every spec. Is there a way to execute onPrepare and onComplete only once for all tests?
I am facing this issue in two situations. 1. Different browsers. 2. Same browser with multiple instance i.e., as follows. capabilities : { browserName : 'chrome', shardTestFiles : true, maxInstances : 2 }, In both cases my code under onPrepare is executing twice. I have a requirement to write the test result of each test to a Json file and I am creating new file in onPrepare and it is getting over written when I use maxinstances > 1
Upvotes: 0
Views: 1629
Reputation: 4832
When you are running your protractor test cases with multi capability option, Then the onPrepare
method will be executed for each set of capability you have mentioned in multi capabilities
object (i.e) Sharded tests run in a different process.
In you case, you need to create your test report file in beforeLaunch
method. This method will execute only once before initializing protractor global objects.
Kindly refer https://github.com/angular/protractor/blob/master/lib/config.ts#L404 for additional details on beforeLaunch
method.
Upvotes: 0