Open akramsarkis opened 1 week ago
It looks like that the lifecycle of insomnia.variables.set
effect should be extended to the whole runner execution, thanks for the very detailed report and Ill look into it.
Thank you, waiting for your update
fix(runner): extend insomnia.variables.set lifetime to whole execution period #8157
Hello @ihexxa ,
How are you?
Is the fix above applied and the problem I mentioned is fixed ?
Best regards, Akram
Hello @akramsarkis,
Thanks you and I'm doing well. Yes, this is the fix for the UI and hopefully we could release a beta this week.
Best, George
Expected Behavior
I have a folder of requests, the aim is to run the folder to test scenarios.
Variables set are not used in the next query of the folder
- I have a login request from which I am setting variables to use them for my next request ```` insomnia.test("Verify login status code", () => { // Extract values from the response and set them as environment variables console.log(insomnia.response.json().token) // Set variables insomnia.variables.set('token_admin', insomnia.response.json().token.token); insomnia.variables.set('project_id', insomnia.response.json().projects[0].saas_project_id); // Log the values to confirm console.log('token_admin:', insomnia.variables.get('token_admin')); console.log('project_id:', insomnia.variables.get('project_id')); // Verify the response status code insomnia.expect(insomnia.response.code).to.eql(200); }); ```` - When adding a pre request script to my next query to use them, I am expecting to have the values set used ```` // Log the existing variables to ensure they are available console.log(insomnia.variables.get('token_admin')); console.log(insomnia.variables.get('project_id')); ````In the pre request of a query I am generating I value I want to use as path parameter and it is not
In the pre request of a query I am generating I value I want to use as path parameter and I am expecting it to work ```` // Log the existing variables to ensure they are available console.log(insomnia.variables.get('token_admin')); console.log(insomnia.variables.get('project_id')); // Function to generate a random alphanumeric string of specified length function generateRandomString(length) { let result = ''; const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; const charactersLength = characters.length; for (let i = 0; i < length; i++) { result += characters.charAt(Math.floor(Math.random() * charactersLength)); } return result; } // Generate a random string of length 8 const randomString = generateRandomString(8); const sectionname = `section+${randomString}`; // Set the generated section name to a variable insomnia.variables.set("generated_sectionname", sectionname); // Log the generated section name to confirm console.log('Generated Section Name:', sectionname); ````Actual Behavior
1) For the first point the actual behaviour is to not use set variables in the next query, it is using the values I have set in my environment variable
Here the variable set by the first login query
And as you can see in the next query it is not using them , the token is not the correct one and project id is the one I set in my env variables
2) Fo the second point as you can see below for the name path parameter I have configured the value I am generating in the pre request of the query
And what is happening is that it is trying to create for me a section called ":name" instead of creating a section with the value of name param
Reproduction Steps
A) First point about variables not used in the next query
B) Second point about path variable value not taken into consideration
Is there an existing issue for this?
Additional Information
No response
Insomnia Version
10.1.1
What operating system are you using?
macOS
Operating System Version
macOS Monterey version 12.7.6
Installation method
From internet, I downloaded it and installed it
Last Known Working Insomnia version
No response