Skip to content

fix(mocktail): name the verified mock on call-count mismatch - #275

Open
AzazelSensei wants to merge 1 commit into
felangel:mainfrom
AzazelSensei:fix/verify-names-checked-call
Open

fix(mocktail): name the verified mock on call-count mismatch#275
AzazelSensei wants to merge 1 commit into
felangel:mainfrom
AzazelSensei:fix/verify-names-checked-call

Conversation

@AzazelSensei

Copy link
Copy Markdown

Status

READY

Breaking Changes

NO

Description

Fixes #179.

verify(() => mockA.doIt(mockB.getValue())) does not check doIt. getValue() has a non-nullable return, so the dummy null from verify throws a TypeError and the rest of the closure never runs. .called(1) then fails with Expected 1 / Actual 6 and never says which mock was counted.

I put the mock type and member on that error so it reads Unexpected number of calls of MockDataProvider.getValue.

The call you want is still verify(() => mockA.doIt('mock value')).

Type of Change

  • 🛠️ Bug fix (non-breaking change which fixes an issue)

Testing

verify(() => a.foo(b.bar())) records b.bar when bar() has a
non-nullable return (TypeError aborts the closure). The count
error then looks like a.foo was called N times.

Include the mock type and member in the called() reason so the
failure names the invocation that was actually checked.

Fixes felangel#179
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.

verify verifies against wrong class when a second mock is called within the same verify call

1 participant