From 50f7f839544d6c901e4e1ed49aec30b8c9ab871f Mon Sep 17 00:00:00 2001 From: Michael Cousins Date: Fri, 1 Nov 2024 11:27:37 -0400 Subject: [PATCH] fixup: avoid runtime change --- src/stubs.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/stubs.ts b/src/stubs.ts index 004c755..ea0186b 100644 --- a/src/stubs.ts +++ b/src/stubs.ts @@ -64,8 +64,7 @@ export const configureStub = ( 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 && @@ -73,7 +72,7 @@ export const validateSpy = (maybeSpy: unknown): MockInstance => { 'getMockName' in maybeSpy && typeof maybeSpy.getMockName === 'function' ) { - return maybeSpy as MockInstance + return maybeSpy as unknown as MockInstance } throw new NotAMockFunctionError(maybeSpy)