diff --git a/packages/hooks/use-lockscreen/index.ts b/packages/hooks/use-lockscreen/index.ts index fc378c287e..e36d8dd0fb 100644 --- a/packages/hooks/use-lockscreen/index.ts +++ b/packages/hooks/use-lockscreen/index.ts @@ -48,6 +48,9 @@ export const useLockscreen = ( const cleanup = () => { setTimeout(() => { + // When the test case is running, the context environment simulated by jsdom may have been destroyed, + // and the document does not exist at this time. + if (typeof document === 'undefined') return removeClass(document?.body, hiddenCls.value) if (withoutHiddenClass && document) { document.body.style.width = bodyWidth