Created
December 5, 2018 23:30
-
-
Save ferm10n/65aaac6b9e7d709d868bc1b4662119dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// browser code we test against, using axios | |
function onClick () { | |
const ajaxRequestPromise = axios.get('/service-call'); // make the service call | |
ajaxRequestPromise.then(response => { // do something with the response | |
doSomethingFruity(response.data); | |
}); | |
} | |
myButton.onclick = onClick; // bind to button | |
///////////////////// | |
// if we wanted to know if the service call is made, we could inject this | |
const _axiosGet = axios.get; // preserve the original function | |
axios.get = function (url) { // monkey patch | |
magicallyReportCallToService(); // somehow let selenium know the call was made? | |
return _axiosGet.apply(null, arguments); // pass the arguments to the original function. The caller (onClick) is none the wiser :) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment