bruno
bruno copied to clipboard
feature(postman_tests_scripts): automatic tests and scripts translation from postman import
Description
Regarding issue #1147
Previous postman script import result :
Translated postman script import result :
Translations are made using a regex, with a separated typescript function Non-translatable postman code will be still returned as comments
Contribution Checklist:
- [x] The pull request only addresses one issue or adds one feature.
- [x] The pull request does not introduce any breaking changes
- [x] I have added screenshots or gifs to help explain the change if applicable.
- [x] I have read the contribution guidelines.
- [x] 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.
This PR is now ready @helloanoop 🎉
how to test this?
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()
how can i enable this in bruno ? Because when i import collection from Postman i d'ont have this option (Enable postman translation ]
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"
i downloaded zip file from your branch but don't know how to try it
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 : 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
Can you try running npm i @tailwindcss/forms ?
Yep, that fixes it.
Related PR: https://github.com/usebruno/bruno/pull/1814/files
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);
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
Thanks for the PR, I also see this one : #1909
can pm.collectionVariables get/set be added also? that and @BBE-91 suggestions would increase the coverage of the translation a lot :)
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