stubby4node icon indicating copy to clipboard operation
stubby4node copied to clipboard

Feature request: Log unmatched fields and Fail with 400 instead of 404 when endpoint matches but payload doesn't

Open marcoaam opened this issue 6 years ago • 1 comments

Maybe this is going outside of the scope of the project but here it goes anyway.

I have been using stubby4node a lot and one of the best features that I have found is that when you set up an endpoint with specific headers or payload it fails if it doesn't match. That is really handy for testing. It has worked fine until now but I am dealing now with slightly more complex scenarios in where I would like to see why the request failed by either returning it in the response, similar to a real service, or by logging it to the console to be able to examine the logs when tests start failing.

1 - Add option to cli to log why the request didn't match (e.g log the unmatched key and value in the compareObjects function) when endpoint matches but payload doesn't OR at least capture the failing payload by logging it or saving it in disk. 2 - Optional - return a 400 bad request rather than 404 with the details that didn't match

I am happy to submit a PR for this feature but just want to check that people are happy with this. Whoever is familiar with the codebase feel free to suggest an approach.

marcoaam avatar Sep 10 '19 08:09 marcoaam

Logging everything related to stub matching to help debug stub failures. The logs are verbose, but you should have a very good sense of why a stub is failing, if it does fail. It certainly helped me identify the failure points for my stubs. The debug stub logs are enabled by an option on stubby.

aparna-sath avatar Jun 05 '20 07:06 aparna-sath