I have a javascript file called pendingAjaxCallsCounter.js with a variable “var pendingAjaxCalls” which is incremented/decremented when various methods in the js file are called.
Separately, I have created an automated testing app which checks that the pendingAjaxCalls has a value of 0 before interacting with any page. I’m wondering, if a given page, were to import the js file multiple times; multiple
statements, how would that affect the value of my variable “var pendingAjaxCalls”?
The script would be run each time it was included, but make sure that you don’t redefine the
pendingAjaxCallsvariable each time. i.e. Check it’s defined before declaring it with something like: