thunder-client-support
thunder-client-support copied to clipboard
Easily reference path-parameters in Tests / New variables menu for Request-Windows
Is your feature request related to a problem? Please describe.
Referencing a path-parameter on the Tests-Tab is kind of cumbersome. It would be nice if there was a way to easily refer to a path-parameter variable in the Tests-Tab.
Describe the solution you'd like
My first thought was some kind of URL object (like in JS) thats exposed to the Tests-Tab, which then can be accessed in the tests.
For example:
With the testing-tab:

Testing that json.user_name is "John Doe" (which is the supplied path-parameter). So when you change the path-parameter user_name to "Jane" the test automatically tests for "Jane".
Describe alternatives you've considered
Maybe even better would be a new menu for variables in each Request-Tab, like:

with which you can reference to the variable from the address-bar (picture above) and the Tests-Section (picture below) with some special syntax:

This way it would be even more versatile and you could even set variables that you want to reference in other menus, like the [Headers] or [Auth] tabs.
Implementation:
I currently have to suggestions for implementation. Lets discuss 😊
Thanks @Blackwidow-sudo for the feedback, Will review it and also wait for other users feedback.
As an alternative suggestion would be to use env variables
As an alternative suggestion would be to use
env variables
Yes im doing that currently. But its kind of cumbersome because if you want to test that your path responds with the path-param you supplied, you always have to switch between the env-variables window and the request window to test the same route with a new path-param. I understand that this is kind of a niche usecase and not that big of a deal, but i still wanted to make the feature-request because i think it could be useful and would make it easier for these cases 😊
Another potential usecase for this would be when working with PUT requests, to make sure the id in the path is matching the id in the request payload. It is not a problem having to repeat the id twice, but it would be a very nice little timesaver and simplification in my opinion 🙂
