Skip to content

Commit

Permalink
fixup: avoid runtime change
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous committed Nov 1, 2024
1 parent 884030b commit 50f7f83
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,15 @@ export const configureStub = <TFunc extends AnyFunction>(

export const validateSpy = (maybeSpy: unknown): MockInstance => {
if (
maybeSpy &&
(typeof maybeSpy === 'function' || typeof maybeSpy === 'object') &&
typeof maybeSpy === 'function' &&
'mockImplementation' in maybeSpy &&
typeof maybeSpy.mockImplementation === 'function' &&
'getMockImplementation' in maybeSpy &&
typeof maybeSpy.getMockImplementation === 'function' &&
'getMockName' in maybeSpy &&
typeof maybeSpy.getMockName === 'function'
) {
return maybeSpy as MockInstance
return maybeSpy as unknown as MockInstance
}

throw new NotAMockFunctionError(maybeSpy)
Expand Down

0 comments on commit 50f7f83

Please sign in to comment.