Skip to content

expect.soft does not work together with an async expectation result #8092

@fvanderveen

Description

@fvanderveen

Describe the bug

When using expect.soft(actual) combined with a .to<Something> that returns an AsyncExpectationResult, the test gets stopped after the first failure.

Initially found this trying to use vitest-plugin-vis matcher toMatchImageSnapshot together with expect.soft to enable getting multiple image comparison result files for a single test case.

A little bit of research (though not sure if it would be the right place to fix things) lead me to jest-extend.ts, line 83 where a promise is augmented to throw an expectation error on failure, instead of handling it similar to wrapAssertion where the test.result.errors is augmented when using expect.soft.

Reproduction

StackBlitz here: https://stackblitz.com/edit/vitest-dev-vitest-pvde5zau

Reproduction in basic.test.ts (two tests, comparing an async assertion with a sync one)

System Info

Windows and linux (probably any system), with vitest 3.2.1

Used Package Manager

pnpm

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    Projects

    Status

    Approved

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions