Reputation: 3
I am currently transcribing a postman collection to intellij http client and even though most of the stuff did work I am currently stuck at a specific problem where I need an inplace Variable @inplaceVar
(that is valid for all requests in the same http file) to be initialized with an external js function import
This is how it works for PreRequest variables:
< {%
import {certainFunction} from 'script/source';
request.variables.set("onetimeusevar", certainFunction());
%}
PreRequest Variables are only valid for the following request though so I need to import a function from my external file.js to be used with an inplace variable @inplaceVar
because as I said I want to reuse this var for other requests in the same file
I have certain ideas on how to solve the scoping issue
I could use client.global.set("varname", function())
but that causes all sorts of inconsistencies that global variables bring in a multirequest test setup and is prone to bite me in the ...
Maybe I could create temporary temp.js
file that I can initialize with the needed variables and overwrite for subsequent testruns/other http.files... Don't know how easy that is to implement though
Upvotes: 0
Views: 725
Reputation: 3
Ok so I found a solution for my case:
@sth = "ARTS{{$random.integer(111111111, 999999999)}}PPE";
The specifics for my string are not as complicated so I can do this inline on the variable itself without needing a function.
Upvotes: 0