Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running single requests uses separate object of collection variables. This makes every request in UI independent. #188

Closed
mirkogolze opened this issue Sep 13, 2023 · 4 comments

Comments

@mirkogolze
Copy link
Contributor

When I run a folder from the UI then the collection variables are used for all requests in the folder. But I don't see the responses.
When I have requests belonging to one to another where one request stores a collection variable, then the next request can't use the value of the stored variable because running it as single request makes them independent.
So I can't test the flow of my collection by running the request one by one and see the result.

With additionally added scripts this is not so easy too, because I can't use fs to work with temporary files or so. I only could use databases. But that would be like shooting sparrows with cannons.

@helloanoop
Copy link
Contributor

@mirkogolze
Can you elaborate the requirement a bit more.?

When I run a folder from the UI then the collection variables are used for all requests in the folder. But I don't see the responses.

If you click on "200 ok" response status, you should see the response
image

where one request stores a collection variable, then the next request can't use the value of the stored variable because running it as single request makes them independent.

The collection variables are a the collection scope. If a requests sets it using bru.setVar(name, value) then any subsequent request can access it using bru.getVar(name)

Can you describe your high level use case? I might be able to suggest some simpler approach.

@mirkogolze
Copy link
Contributor Author

SampleCollection: VarTesting.zip

SetVar

test("should return the IP", function() {
  const data = res.getBody();
  expect(data.ip).to.be.a('string');
  bru.setVar('myIP', data.ip);
});

GetVar

test("should get the IP from var", function() {
  const ip = bru.getVar('myIP');
  expect(ip).to.be.a('string');
});

Running the folder in the UI
image
All is fine!

Running the request one by one in the UI
image
Variable is saved

image
Variable should be read from Collection - but collection variables are empty.

I think now the requests are running with the method runSingleRequest, where the collectionVariables are freshly instantiated.
To implement a flow of requests, I wan't to run the requests one by one, see the responses, implement my tests and assertions.
Read data from responses, store to collection variables and use that data in pre-request-scripts.
This is not possible because every request has its own collection variables. So we would need a kind of context inside the UI on scope of the collection.

@helloanoop
Copy link
Contributor

helloanoop commented Sep 13, 2023

Thanks @mirkogolze for the detailed writeup of the issue.

The collection variables are intended to be scoped inside the collection. There as a bug that was causing this behavior not to work.

I have fixed this and this is now available in the latest v0.14.0 release

PS: In this release, I've also added support for printing console.log() statements (inside the scripts/tests) in the devtools for easier debugging.

@mirkogolze
Copy link
Contributor Author

Thanks. Works now as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants