From 164cb705598bfc27e8fd632428d5bbd816b87a08 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Fri, 6 Dec 2024 18:29:51 +0900 Subject: [PATCH] fix: class instance is fine since not own prop --- packages/mocker/src/automocker.ts | 2 +- packages/spy/src/index.ts | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/mocker/src/automocker.ts b/packages/mocker/src/automocker.ts index 1ed45a0f17dd..256dbb952310 100644 --- a/packages/mocker/src/automocker.ts +++ b/packages/mocker/src/automocker.ts @@ -115,7 +115,7 @@ export function mockObject( const type = getType(value) const isFunction = type.includes('Function') && typeof value === 'function' - if (isFunction && !value._isMockFunction) { + if (isFunction) { // mock and delegate calls to original prototype method, which should be also mocked already const original = this[key] const mock = spyOn(this, key as string) diff --git a/packages/spy/src/index.ts b/packages/spy/src/index.ts index 23bffdd5d5e0..4f3180224621 100644 --- a/packages/spy/src/index.ts +++ b/packages/spy/src/index.ts @@ -467,16 +467,11 @@ export function spyOn( const currentStub = getSpy(obj, method, accessType) if (currentStub) { - // TODO: should we reset? return currentStub } const stub = tinyspy.internalSpyOn(obj, objMethod as any) - // if (vitestSpy in stub) { - // return stub as any as MockInstance - // } - return enhanceSpy(stub) as MockInstance }