usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
28k stars 1.3k forks source link

Import Pre Request Scripts and Tests while importing Postman Collection #144

Closed helloanoop closed 1 week ago

helloanoop commented 1 year ago

Bruno should import Pre Request Scripts and Tests while importing Postman Collection

armand-janssen commented 1 year ago

@helloanoop I have created the import for the 'pre request scripts' and 'tests' in this branch: https://github.com/armand-janssen/bruno/tree/feature/144-import-postman-scripts.

The implementation now only imports the scripts 1-on-1. By default the scripts can't work, because postman has different objects.

How far should the script go in trying to (String) replace the scripts?

Example:

const jsonData = pm.response.json();
pm.environment.set("sessionId", jsonData.sessionId);
// could be
bru.setEnvVar('sessionId', res('sessionId'));
pm.test("Response code is 200", function () {
    pm.response.to.have.status(200);
});
// could be
test("Response code is 200", function () {
  expect(res.status).to.equal(200);
});

But these are simple examples and the js scripts can get very complicated. As an end user I would expect either that nothing is merged or all, to avoid confusion.

So my question: Is the 1-on-1 good as a first version of this feature and later maybe a new feature to parse the js scripts to be as compatible as possible?

armand-janssen commented 1 year ago

Am I assuming correctly that this issue can be close this since https://github.com/usebruno/bruno/pull/711 was released in 0.27 ?

srikanthlogic commented 1 year ago

I think this can still be open. While pre-request / tests are imported at request level - Collection level defaults - Headers, Auth, Script, Tests, Proxy - are all empty. Assuming bruno uses the same overriding preferences of global / collection level / request level setting - for each execution - this breaks importing collections with collection-level pre-script / tests to run.

image

helloanoop commented 1 week ago

Bruno now supports importing scripts and tests (Folder Level and Collection Level) while importing collections. Closing this issue.