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

Is there a way to prevent Request being made on Pre-Request script? #43

Open
roncsak opened this issue Nov 10, 2023 · 2 comments
Open
Labels
enhancement New feature or request

Comments

@roncsak
Copy link

roncsak commented Nov 10, 2023

Is your feature request related to a problem?

Let's say I have a Request but I only want that being run on a specific condition.
In general, I can just write throw new Error("cause of the error"); and thats it.

In my case I would like to use console.log() or console.info() before throwing an error but because of the throw new the console message is not displayed.

Describe the solution you'd like

Would it be possible to use return false; and still logging to console?

Currently the script return false; results the following:
image

When I would use return false I would expect that the Request is not being made at all.

Additional context

No response

@roncsak roncsak added the enhancement New feature or request label Nov 10, 2023
@AntonShuvaev
Copy link
Collaborator

Thanks for the feedback. I will support printing logs when an error is thrown in the pre-request script. I'm not certain about using 'return false' because I think throwing an error is more obvious and solves the problem, especially if logs will be printed. By the way, you can run requests conditionally in the Test script of a Folder or Test Suite, like this:

if (condition) {
    await jc.runRequest("1d4246e1");
}

@roncsak
Copy link
Author

roncsak commented Nov 15, 2023

Thanks for the support!
Well, regarding the return statement, I'm not really sure either.

Actually in the Pre-Request tab, I would like to do some precondition checking and if that fails, I would like to prevent the "normal" requuest being fired. With the console object, I'd like to provide additional info(), warn() or even error() message. In such case, throwing an error seems a bit too harsh for me but I can live with it. But for me its more important to structure the messages in the console which Error(msg) is not capable of.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants