Skip to content

Conversation

@Smerom
Copy link

@Smerom Smerom commented Oct 8, 2025

The current MatchError matcher considers errors to be a match that errors.Is does not, and so cannot be used in a test to ensure that upstream error handling can use errors.Is to for error specific handling. In order to not break any existing tests, I propose adding the following stricter error matcher that considers two errors a match if and only if they are both non-nil, and errors.Is(actual, expected) returns true.

As an example of current behavior:

Expect(errors.New("some error")).To(MatchError(errors.New("some error")))

will pass, however:

errors.Is(errors.New("some error"), errors.New("some error"))

will return false.

Related to issue: #876

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant