Skip to content

Commit

Permalink
Add fetch API to ajax counters in tests code
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Petry committed Mar 20, 2020
1 parent 8f7c301 commit 5d14937
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/acceptance/customCommands/initAjaxCounters.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,16 @@ exports.command = function () {
}
})(XMLHttpRequest.prototype.send)
})
this.execute(function () {
(function (wrappedFetch) {
window.fetch = function () {
window.activeAjaxCount++
window.sumStartedAjaxRequests++
return wrappedFetch.apply(this, arguments).then(function () {
window.activeAjaxCount--
})
}
})(window.fetch)
})
return this
}

0 comments on commit 5d14937

Please sign in to comment.