From 3a3cc585f4f6a02d3e7632c559c3d029f3da1d99 Mon Sep 17 00:00:00 2001 From: Pedro Bonamin <46196328+pedrobonamin@users.noreply.github.com> Date: Wed, 15 Jan 2025 19:05:27 +0100 Subject: [PATCH] fix(core): cannot find namespace 'vi' (#8282) --- .../form/store/utils/__tests__/immutableReconcile.test.ts | 4 ++-- .../store/_legacy/document/document-pair/validation.test.ts | 4 ++-- .../documentPanel/header/DocumentHeaderTitle.test.tsx | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/sanity/src/core/form/store/utils/__tests__/immutableReconcile.test.ts b/packages/sanity/src/core/form/store/utils/__tests__/immutableReconcile.test.ts index f7356d7db4a..056f80a36f0 100644 --- a/packages/sanity/src/core/form/store/utils/__tests__/immutableReconcile.test.ts +++ b/packages/sanity/src/core/form/store/utils/__tests__/immutableReconcile.test.ts @@ -1,5 +1,5 @@ import {defineField, defineType} from '@sanity/types' -import {beforeEach, expect, test, vi} from 'vitest' +import {beforeEach, expect, type Mock, test, vi} from 'vitest' import {createSchema} from '../../../../schema/createSchema' import {createImmutableReconcile} from '../immutableReconcile' @@ -7,7 +7,7 @@ import {createImmutableReconcile} from '../immutableReconcile' const immutableReconcile = createImmutableReconcile({decorator: vi.fn}) beforeEach(() => { - ;(immutableReconcile as vi.Mock).mockClear() + ;(immutableReconcile as Mock).mockClear() }) test('it preserves previous value if shallow equal', () => { diff --git a/packages/sanity/src/core/store/_legacy/document/document-pair/validation.test.ts b/packages/sanity/src/core/store/_legacy/document/document-pair/validation.test.ts index 070c4946573..b8f76a3fcdc 100644 --- a/packages/sanity/src/core/store/_legacy/document/document-pair/validation.test.ts +++ b/packages/sanity/src/core/store/_legacy/document/document-pair/validation.test.ts @@ -11,7 +11,7 @@ import { timer, } from 'rxjs' import {buffer, publish, takeWhile} from 'rxjs/operators' -import {beforeEach, describe, expect, it, vi} from 'vitest' +import {beforeEach, describe, expect, it, type Mock, vi} from 'vitest' import {createMockSanityClient} from '../../../../../../test/mocks/mockSanityClient' import {getFallbackLocaleSource} from '../../../../i18n/fallback' @@ -21,7 +21,7 @@ import {editState, type EditStateFor} from './editState' import {validation} from './validation' // Mock `./editState` -const mockEditState = editState as vi.Mock +const mockEditState = editState as Mock vi.mock('./editState', () => ({editState: vi.fn()})) const schema = createSchema({ diff --git a/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.test.tsx b/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.test.tsx index 2d44598c7f0..5fe0006d0ad 100644 --- a/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.test.tsx +++ b/packages/sanity/src/structure/panes/document/documentPanel/header/DocumentHeaderTitle.test.tsx @@ -1,6 +1,6 @@ import {render, waitFor} from '@testing-library/react' import {defineConfig, type SanityClient, unstable_useValuePreview as useValuePreview} from 'sanity' -import {afterEach, beforeEach, describe, expect, it, vi} from 'vitest' +import {afterEach, beforeEach, describe, expect, it, type MockedFunction, vi} from 'vitest' import {createMockSanityClient} from '../../../../../../test/mocks/mockSanityClient' import {createTestProvider} from '../../../../../../test/testUtils/TestProvider' @@ -33,8 +33,8 @@ vi.mock('sanity', async () => { }) describe('DocumentHeaderTitle', () => { - const mockUseDocumentPane = useDocumentPane as vi.MockedFunction - const mockUseValuePreview = useValuePreview as vi.MockedFunction + const mockUseDocumentPane = useDocumentPane as MockedFunction + const mockUseValuePreview = useValuePreview as MockedFunction const defaultProps = { connectionState: 'connected',