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

Added pre-request and tests scripts support from Postman Collection #711

Merged
merged 1 commit into from
Oct 22, 2023

Conversation

survivant
Copy link
Contributor

Description

In Postman you can define Pre-request scripts and tests to do when you do a request. Those information are stored in the collection but were not imported by bruno

image
image

linked to this feature : [FEATURE] Support Postman pre-request script and tests when Importing collection #710

Contribution Checklist:

  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • [X ] I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

#hacktoberfest

@mirkogolze
Copy link
Contributor

Hi @survivant,
cool idea. If you have some time you could try to translate some Postman Syntax to Bruno-Syntax.
Like reading and writing variables.
From pm.variables.set(... -> bru.setVar(...

@survivant
Copy link
Contributor Author

agree. I'll do that in another PR. I'll try to keep them small, so it's easier to merge

@helloanoop helloanoop merged commit 82c6e83 into usebruno:main Oct 22, 2023
2 checks passed
@helloanoop
Copy link
Contributor

Merged!

Thanks @survivant !

If you have some time you could try to translate some Postman Syntax to Bruno-Syntax.

@mirkogolze @survivant
This seems to be a bit hard to do read the syntax and transpile the code correctly.
This actually seems to be a great task for an AI to translate. It'd be great to find something that can run locally.
And also provide an option to use OpenAI api to do this conversion (for folks who are ok)

@survivant Another thing also would be good immediately is to just have these scripts imported in Bruno, but every line commented //. This allows the user to gradually migrate the tests and scripts, but also the app not to crash since pm variable is not found.

@fxsth
Copy link

fxsth commented Oct 24, 2023

Please do not use a non-deterministic solution for a deterministic problem. An AI is not suitable for translating a syntax, that relies heavily on correctness. It may result in rewritten tests that passes, but test the wrong thing, which is even worse than broken tests.

@helloanoop
Copy link
Contributor

@fxsth Sure.

For now, the tests and scripts get imported (and are commented) by default. The user can migrate the tests gradually.

On the AI part, if we go that route, it won't be baked into the app. Will provide an additional cli tool that can automatically read the files and convert the scripts and it's upto the user to vet the correctness looking at the the diff

My personal opinion is that I would use a cli, use an openai key, and have the ai do the majority of the grunt work and I will vet the changes done by the AI. (Note: my collection scripts are not super confidential, so I am fine to send them to openai to do the conversion)

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

Successfully merging this pull request may close these issues.

5 participants