[GH-ISSUE #3184] [feature]: Access to environment in Tests #1049

Closed
opened 2026-03-16 18:16:52 +03:00 by kerem · 2 comments
Owner

Originally created by @koehler0179 on GitHub (Jul 13, 2023).
Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3184

Is there an existing issue for this?

  • I have searched the existing issues

Summary

Would be nice if it would be possible to access the environment variables in the tests as it is possible in Postman.

Why should this be worked on?

Sometimes you have multiple requests where the next request uses a value of the result from the previous request. Currently if trying to set an environment variable in a test ends up with an error running the test.

pw.env.set("myVar", "some value");

Originally created by @koehler0179 on GitHub (Jul 13, 2023). Original GitHub issue: https://github.com/hoppscotch/hoppscotch/issues/3184 ### Is there an existing issue for this? - [X] I have searched the existing issues ### Summary Would be nice if it would be possible to access the environment variables in the tests as it is possible in Postman. ### Why should this be worked on? Sometimes you have multiple requests where the next request uses a value of the result from the previous request. Currently if trying to set an environment variable in a test ends up with an error running the test. pw.env.set("myVar", "some value");
kerem 2026-03-16 18:16:52 +03:00
  • closed this issue
  • added the
    feature
    label
Author
Owner

@liyasthomas commented on GitHub (Jul 15, 2023):

Hi @koehler0179, can you share the error logs when you ran the Test scripts?

Hoppscotch Test scripts have support for environment context and can add, append and edit environment variables from test scripts. Documentation: https://docs.hoppscotch.io/documentation/features/scripts#pwenvgetvariable

pw.env.set("baseURL", "https://httpbin.org");
<!-- gh-comment-id:1636646872 --> @liyasthomas commented on GitHub (Jul 15, 2023): Hi @koehler0179, can you share the error logs when you ran the Test scripts? Hoppscotch Test scripts have support for environment context and can add, append and edit environment variables from test scripts. Documentation: https://docs.hoppscotch.io/documentation/features/scripts#pwenvgetvariable ```javascript pw.env.set("baseURL", "https://httpbin.org"); ```
Author
Owner

@koehler0179 commented on GitHub (Jul 17, 2023):

Okay, my fault. Value always has to be converted to string to work. Tried to set a bool and that was throwing an error.

pw.env.set("myVar", true);
or:
pw.env.set("myVar", 1);

Would be nice to have an any type as value that is internal converted to a string.

<!-- gh-comment-id:1637454309 --> @koehler0179 commented on GitHub (Jul 17, 2023): Okay, my fault. Value always has to be converted to string to work. Tried to set a bool and that was throwing an error. pw.env.set("myVar", true); or: pw.env.set("myVar", 1); Would be nice to have an any type as value that is internal converted to a string.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#1049
No description provided.