usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
26.26k stars 1.2k forks source link

Asserts should be able to reference query variables #1481

Open MelGrubb opened 8 months ago

MelGrubb commented 8 months ago

In the Assert tab, I can already make use of environment variables, but there is no way to reference the values from the "Variables" tab. For example, if I have a variable called "id", I'd like to be able to assert that its value appears in the body of the response. Maybe my query tries to retrieve a particular user record. I'd like to assert that the "id" value on the response matches what I asked for. This example is highly simplified, of course.

I'm not sure what that syntax would look like, though. Would it use the same double curly braces? Would the variable name need a prefix of some sort like {{vars.id}} and how would you prevent collisions with environment variables other than by saying "don't start your variables with "vars""?

fredjeck commented 8 months ago

Hi @MelGrubb this works for me image image

MelGrubb commented 8 months ago

Hi @MelGrubb this works for me

Ah, I'm doing GraphQL queries and the UI is slightly different for those. There's a separate "variables" tab there. Those are the ones I need to reference in the assertions.