thunderclient / thunder-client-support

Thunder Client is a lightweight Rest API Client Extension for VS Code.
https://www.thunderclient.com
Other
3.59k stars 128 forks source link

setVar inside tests from requests that is run from another request's (parent request) pre-run results in the parent request's getVar getting outdated value #1550

Open oopchi opened 1 month ago

oopchi commented 1 month ago

Describe the bug setVar inside tests from requests that is run from another request's (parent request) pre-run results in the parent request's getVar getting outdated value. For example:

  1. Run request A
  2. Request A's pre-run gets called
  3. Request A's pre-run call await tc.runRequest(request B)
  4. Request B gets called
  5. Request B's test scripts get called
  6. Request B's test scripts contains tc.setVar("existing-key", "updated-value");
  7. Request B's test ended
  8. Request A's pre-run resume from point 3
  9. Request A's pre-run calls tc.getVar("key-from-point-6");
  10. Request A's pre-run gets "old-value" instead of "updated-value"

To Reproduce

  1. Run request A
  2. Request A's pre-run gets called
  3. Request A's pre-run call await tc.runRequest(request B)
  4. Request B gets called
  5. Request B's test scripts get called
  6. Request B's test scripts contains tc.setVar("existing-key", "updated-value");
  7. Request B's test ended
  8. Request A's pre-run resume from point 3
  9. Request A's pre-run calls tc.getVar("key-from-point-6");
  10. Request A's pre-run gets "old-value" instead of "updated-value"

Expected behavior getVar should return the updated value instead of the old value of the requested variable after being updated from a child-request's test functions.

Platform:

Are you using the free version/paid version/trial: free version

rangav commented 1 month ago

@oopchi thanks for reporting, will look into it.

tc.runRequest will be a paid feature from June 3rd. https://github.com/thunderclient/thunder-client-support/releases/tag/v2.24.0