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 Request: Enable references to external JavaScript files as an alternative to embedding arrays of JavaScript containing strings #3141

Open
nilvon9wo opened this issue Aug 23, 2023 · 2 comments

Comments

@nilvon9wo
Copy link

This isn't so much an issue with Newman as not finding Postman to be an ideal JavaScript editor, yet finding it worse to edit .json collection files in something else.

In an idea solution, when Newman files a string instead of an array as the value of exec, Newman would check if this is a file path and whether a file can be found at this location. If so, it would run it.

So, for example, instead of:

					"script": {
						"exec": [
							"let response = pm.response.json();\r",
							"pm.globals.set(\"jwt_for_workday_to_airtable\", response.access_token);\r",
							"pm.test(\"Status code is 200\", function () {\r",
							"    pm.response.to.have.status(200);\r",
							"});"
						],
						"type": "text/javascript"
					}

I could have

					"script": {
						"exec": "./capture_access_token.js",
						"type": "text/javascript"
					}
@nilvon9wo
Copy link
Author

I thought about trying to make a PR to do something like this, but I won't pretend my JavaScript is good enough to figure out how your solution is working, so I can't modify it.

Instead, since this isn't getting any response, I'm working on a wrapper ( https://github.com/nilvon9wo/impendingman ) which will allow users to do translate a collection.template.json and run it in newman.

Ideally, I'd like to make newman a direct dependency instead of going through the shell, but I couldn't figure out how to turn command line arguments into NewmanOptions, or if that is even necessary or the best way to do this....

If anyone here is interested in helping with this solution, I'm all eyeballs.

@nilvon9wo
Copy link
Author

In case anyone is interested in actually using this tool, it is now on npm: https://www.npmjs.com/package/impendingman?activeTab=readme

... Alas, I still haven't figured out how to integrate newman directly instead of going through the shell....

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

1 participant