AnWeber / vscode-httpyac

Quickly and easily send REST, Soap, GraphQL, GRPC, MQTT and WebSocket requests directly within Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=anweber.vscode-httpyac
MIT License
237 stars 20 forks source link

[Feature request] Bail for vscode #186

Closed woolfas closed 1 year ago

woolfas commented 1 year ago

Hi, I'm missing "bail" functionality in VSCode. Currently Httpyac CLI supports "--bail" option which terminates execution when a first test case fails, so I'm wandering is there a way to achieve the same behavior in VSCode? Here's a simple example:

### First
# @name first
POST https://httpbin.org/anything
Content-Type: application/json

{
    "name": "First"
}

{{
    test('first test', () => {
        // "This will always pass";
    });
}}

### Second
# @name second
POST https://httpbin.org/anything
Content-Type: application/json

{
    "name": "Second"
}

{{
    test('second test', () => {
        throw "This will always fail";
    });
}}

### Third
# @name third
POST https://httpbin.org/anything
Content-Type: application/json

{
    "name": "Third"
}

{{
    test('third test', () => {
        // "This will always pass";
    });
}}

//==========================================
### All
# @forceRef first
# @forceRef second
# @forceRef third

When I execute "All" in VSCode I would expect that after "second" request is executed, further requests will not be invoked at all since "second" has failing test. I assume that there could be introduced "bail" metadata (which would allow to bail specific http regions) or env variable (which will allow to set default behavior for all requests). Please consider adding this feature.

AnWeber commented 1 year ago

I have added a new setting that makes it possible to activate the desired feature. With the next release it is included.