In my config file beforeLaunch and afterLaunch is executing twice because failed scripts are again re-executing. I have used protractor flake to re-execute the files. I want to know the afterlanch and beforeLaunch count. Can anybody help
Asked
Active
Viewed 101 times
1 Answers
0
I'm not exactly sure how the protractor flake npm package works but you could try using the global variables node allows you to create.
conf.js
//Declare the variable
global.glbBeforeLaunchCounter = 0;
global.glbAfterLaunchCounter = 0;
exports.config = {
beforeLaunch: function () {
glbBeforeLaunchCounter = glbBeforeLaunchCounter + 1;
//...
},
afterLaunch: function () {
glbAfterLaunchCounter = glbAfterLaunchCounter + 1;
//...
}
}

DublinDev
- 2,318
- 2
- 8
- 31
-
I actually tried doing that way, but when declaring it is showing me an error "[ts] Property 'glbAfterLaunchCounter' does not exist on type 'Global'. [2339]" – akhila anumolu Mar 19 '19 at 11:01
-
@akhila are you definitely declaring your global variable with a lowercase 'g'? – DublinDev Mar 19 '19 at 11:27
-
actually @akhila if you are using typescript [this question](https://stackoverflow.com/questions/40743131/how-to-prevent-property-does-not-exist-on-type-global-with-jsdom-and-t) may be useful – DublinDev Mar 19 '19 at 11:31