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

feature(postman_tests_scripts): automatic tests and scripts translation from postman import #1151

Merged
merged 12 commits into from
Mar 13, 2024

Conversation

bpoulaindev
Copy link
Contributor

Description

Regarding issue #1147
Previous postman script import result :
image

Translated postman script import result :
image

Translations are made using a regex, with a separated typescript function
Non-translatable postman code will be still returned as comments

Contribution Checklist:

  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • 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.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

@bpoulaindev
Copy link
Contributor Author

This PR is now ready @helloanoop 🎉

@raaaouf
Copy link

raaaouf commented Mar 4, 2024

how to test this?

@bpoulaindev
Copy link
Contributor Author

how to test this?

Import a postman collection into Bruno, the collection must have postman commands in scripts and/or tests. By default scripts are inside a comment, when you enable the translation it converts pm.environment.get() to bru.getEnvVar()

@raaaouf
Copy link

raaaouf commented Mar 4, 2024

how can i enable this in bruno ? Because when i import collection from Postman i d'ont have this option (Enable postman translation ]

@bpoulaindev
Copy link
Contributor Author

how can i enable this in bruno ? Because when i import collection from Postman i d'ont have this option (Enable postman translation ]

Are you on the right branch ? There should be a checkbox in the import dialog before choosing "Postman collection"

@raaaouf
Copy link

raaaouf commented Mar 4, 2024

i downloaded zip file from your branch but don't know how to try it

@bpoulaindev
Copy link
Contributor Author

You have to clone the Bruno repository, switch to the branch feature/postman_tests_scripts, install the dependencies, follow the readme manual and launch the project locally on your machine

@helloanoop helloanoop merged commit 410eecc into usebruno:main Mar 13, 2024
0 of 3 checks passed
@mjhcorporate
Copy link
Contributor

@helloanoop : After this PR was merged, the main branch no longer builds for me. My steps are:

npm i --legacy-peer-deps
npm run build:graphql-docs  && npm run build:bruno-query && npm run build:bruno-common
npm run dev:web

Result:

error - ../../node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[7].use[1]!../../node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[7].use[2]!../../node_modules/codemirror/lib/codemirror.css
Error: Cannot find module 'tailwindcss/plugin'
Require stack:
- /Users/woof/SAPDevelop/git/bruno/node_modules/@tailwindcss/forms/src/index.js

@bpoulaindev
Copy link
Contributor Author

Can you try running npm i @tailwindcss/forms ?

@mjhcorporate
Copy link
Contributor

Yep, that fixes it.

@mjhcorporate
Copy link
Contributor

@BBE-91
Copy link

BBE-91 commented Mar 26, 2024

Hello @bpoulaindev,
Thanks, it's a great feature !

Could we go one step further, having more replacements, like :

  • pm.test => test
  • pm.response.json() => res.body
  • pm.response.to.have.status => expect(res.status).to.be.equal
  • pm.globals.set => bru.setVar
  • pm.globals.get => bru.getVar

I observed that set commands are not replaced if expression contains a . ?
This was not replaced :

//     var response = pm.response.json();
//     pm.environment.set("variable_key", response.key);

could be replaced by :

var response = res.body;
bru.setEnvVar("variable_key", response.key);

@bpoulaindev
Copy link
Contributor Author

Hi @BBE-91 thanks for the suggestions;
I submitted a PR that was merged few das ago improving the translation : #1894
Here's the current status regarding your suggestions :

  • pm.test : ✅
  • pm.response.json() : good idea
  • pm.response.to.have.status() : ✅
  • pm.globals.set/get : not sure we can do this now, as Bruno doesn't support global variables yet, this could be misleading

@BBE-91
Copy link

BBE-91 commented Mar 26, 2024

Thanks for the PR, I also see this one : #1909

@apintocd
Copy link

can pm.collectionVariables get/set be added also? that and @BBE-91 suggestions would increase the coverage of the translation a lot :)

@bpoulaindev
Copy link
Contributor Author

Thanks for the PR, I also see this one : #1909

This one is interesting it should also be merged.
@apintocd this has been merged in the PR i mentioned above

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.

6 participants