Skip to content

Setting output behavior programattically / looping over the same assert #839

@esran

Description

@esran

I have a test that is checking output from an API. The output may take several seconds to become stable. Hence I want to check this within a loop. I've got this working with std::panic::catch_unwind() and specifying the prefix with insta::assert_json_snapshot!("test_case_name", response);. My loop has a timeout, and after my loop I repeat the assert without the catch_unwind to get the actual test result.

The problem I have is that every call in the loop outputs the diff. It doesn't seem to be possible to set the output behaviour programmatically in my test. The Settings struct doesn't have anything for setting the output behaviour.

Is there a different API where I can have it not assert or output and just return whether it is okay or not? Or some way of suppressing the output programmatically? Or even a different approach entirely for doing this sort of test without being massively spammy.

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