Skip to content

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

@marcoaam

Description

@marcoaam

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions