Skip to content

Condition in mocks #115

@Adam-it

Description

@Adam-it

💡 Idea

What if it was possible to add a condition to a mock that it should be used only when the request contains a specific value in a specific param (either GET or POST) 🤔?
Currently, I think it is almost possible for GET requests by specifying a full URL of the mock also with params like https://test/some/reqeuest?param1=aaa. That way it will only be used when we specify also param1=aaa in the request right?
But for a POST request, this is impossible 🤔. So I was wondering if the response.json structure could have some additional property in which the developer could specify a condition when this mock will be used and the condition will be about values set in some specific param.
What do you think? TBH I haven't tested the above yet but just wanted to share an idea that I just got for this tool 😅.

📝 Use Case

As for a use case, I was thinking that we may not always want every POST request to fail for the same request. Sometimes it may be required to mock a failed response only when we pass specific data together with the request 🤔.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions