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/add execution context #1875

Closed

Conversation

tlaloc911
Copy link
Contributor

@tlaloc911 tlaloc911 commented Mar 21, 2024

Description

In reference to #1874
I have the need to know the execution context of the request:

  1. Name of the Request executed
  2. Path of the .bru name
  3. Execution mode: single, runner, cli
  4. Associated documentation of the request

This will allow me to take some decisions in scripts, such as how to name logs, where to find data associated to every request, apply or exclude some tests depending on the way it is launched, etc.

Pre Request script example

console.log("-------- executionMode ----------")
console.log(bru.getVar("executionMode"))
console.log("-------- pathname ----------")
console.log(bru.getVar("currentItem").pathname)
console.log("-------- filename ----------")
console.log(bru.getVar("currentItem").filename)

Outputs

image image image

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.

@mjhcorporate
Copy link
Contributor

mjhcorporate commented Mar 21, 2024

Interesting idea! But I worry about potential name-conflicts with user-defined variables.

How about attaching this info to the bru object? Something like

bru.context.executionMode
bru.context.currentItem

In Postman, there was pm.request.name for the currentItem.fileName...

@tlaloc911
Copy link
Contributor Author

hi @mjhcorporate, in fact, I wanted to include it in the request object, but I notice the req object is different depending on the context: single request, runner or cli and I prefer not to touch it because it can break somenone's script

@mjhcorporate
Copy link
Contributor

Yes, I agree that we should not put it on the request object, and that we should not break existing scripts. I think attaching new properties to the bru object is the safest path forward.

@tlaloc911
Copy link
Contributor Author

This was partially solved by #3105, and I open #3298 implementing the filepath part

@tlaloc911 tlaloc911 closed this Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants