Skip to content

Conditionally do asserts based on env variables or currently selected environment? #917

@victor-marino

Description

@victor-marino

Hi!

I'm using the assert feature in httpYac to create a sort of test suite for my APIs using the VS Code extension, adding things like this right after the request:

?? status == 400
?? body param1 == val1

Works pretty well :)

However, I'd like to tweak some of those asserts to make them conditional to the currently selected environment. I normally test my changes locally first, where the response isn't going to be exactly the same as that of my online environment, and that makes lots of tests "fail", which can be a bit cumbersome to comb through just to confirm all the failures were expected.

Is there any way to write an assert in such a way that it's only executed if the environment is, say, "local"? Or the other way around, only execute an assert if the environment is different from "local"?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions