Thursday, March 3, 2016

angular protractor tip: what requests were made?

I'm building up my testing mojo.

One challenge I'm surprised doesn't get talked about more is keeping your protractor mocks up to date as forms and endpoints change - keeping them in sync seems like a significant challenge, especially if you've used the "pluck data from the console network tab, call that the mock data" method - often the state of the system you're using for that kind of developer testing is pretty arbitrary, and might be different if you tried to redo the mock data straight from the system.

I asked about it at work, one developer suggested the test do
afterEach(function () {
    mock.requestsMade().then(function (requests) {
   console.log(requests);
});
});
but that only shows the mocks that were successfully caught; I'm interested in the opposite.

I hunted around without luck at finding the code that intercepts each request (and/or decides to let it pass through if there are no matching mocks) and jamming in some console.log()s. I ended up resorting to doing a browser.pause() or two, opening up the browser's network tab, and doing a visual delta inspection from that. Suboptimal, but got the job done for now.

No comments:

Post a Comment