Open mwolson opened 8 years ago
Very interesting, @mwolson! :) I don't have experience personally with yakback, but I do like the benefits you're listing. Sounds like it would be an improvement, and I don't think we're married to nock right now.
That said, I do like how the current nock implementation has the response easily-visible in plaintext, whereas the yakbak example provided seems to base64encode the response:
For example:
res.write(new Buffer("H4sIAAAAAAAAA+1cW3PbRpb+K23xIbMpmen7xQ8zseRrNpZdljPZ1GrH1Wg0REQgwMHFWlYy/31PA5QEgFBCL6LJi10JBQJg4+D0uXzn0v3L0WZV1EV19OSXo4299EdPyHF7AGcYwwK++HJ3AePjo7qobXb05AiucSaPjrufHz3571+O0hjOUym4EYIyTeFicZ37Es4KpTEllHx7hjGcrrwrfQ3nLUmcjrGJdXu2/NTeTRQOP05suT56QuGZaZ3B84+eZrEvrc3RaZEk3qPH6J0tr9BzW9Vwe1ptmihLXfsGaZWUqc+BItx+ses027ZfKpuEd/nX8S3BmCnMMea8RzDnAlMtJRDM+gRrTTkmkVZ4QLBUfIrg09Ku12l+iZKiREma26z6G3pW5F/V6Looy+0xuvZfffLosqjRtmhKFFl3tUQfyi0K37bNer1FblW4IrO1R66Ax/kY+WpT+qoqUORtXj1CP3q0sjBMvfJrlObIok8W3r7ewniXx/A1Dmy6G6c7m8dw5XqVhoH7l5bAULcKRzBqFQZFzgK/09wj/88m/WQzn9eoLhBDrtlUqEiAsnZCgKRN5m3l0brJ3epzJwX3JiVIEcZU9qWISJgroylMiuxPCrdC85hxGKM/KZyrqUn5HsQFOLINnDpdpc5eFo8eoZcNcBTYUXxVtbPwN3TRxJrF8OlxfHvsjECL3a/QAvji28/ERx7Ys0iKIt4UZY4W/1mUMDlo0c3hoi7TDVp8ss7WaQGnYQZBLiK45woG6Li3SEq72cDfVZH7bbgWw411aa8jXwLjKrSI4EdVEZ688h7e31754S0wq8AUu0aLiyayzFw0jloOhGOHLxobJxrOK6vb6yaOfuu68z5cEcy1d3vRjka6azR24Y5W7mdonjSSCtnXPMKw5FhjNp5lY4WinFBrB7MsyKTqvTNEY8wI+gv5jzkkghwySSjty6GhxChK1diaSSkJJ0nCxNA46Ek5XJzYsj5P15sqCMSHld8dV3cC4eCOIlxdNWuwILvz1aoAWXoHcuR9ef7PxpZw67m3dRh3hsrBbGgm1XA2OGUELJ6AdxWDd00EWG7FrB4ZQjz1rufpBizSRQMDJWBV6jocMvIEYS0wYpgiwRCjaFXXmycX31x8c9XkPvEuXboCZPkKbseJC6fgiwXl7X6foEVc5HFTri2omK2z7jRaZGAp", "base64"));
Regardless, I'd be interested in seeing a proof-of-concept PR to see how it works!
@mwolson if you want to investigate this upgrade, we'll probably want to branch off master
after merging a larger "v2.0" overhaul in https://github.com/ticketmaster-api/sdk-javascript/pull/19.
@ijpiantanida has an open pull request for yakbak which makes the fixtures human-readable: https://github.com/flickr/yakbak/pull/18 .
Likewise, not married to nock - especially since matching on query string params is annoyingly tricky.
Would love to see a spike if you're interested @mwolson?
Yakbak is described here: http://code.flickr.net/2016/04/25/introducing-yakbak-record-and-playback-http-interactions-in-nodejs/
It has the following benefits over nock:
1) automatic recording of requests that we don't have fixtures for
2) ability to wipe the fixtures directory and then run the tests once to regenerate all of them for an API change
3) can plug in multiple yakbak instances as middleware into a single express (or other framework) mock server, using routing on the URL path to determine which service mocks to provide. If you include a scenario name as the first level of that routing, and assign those fixtures to a distinct directory based on scenario name and service, it aids in quickly deleting and regenerating fixtures on an API change