diff --git a/eslint.config.ts b/eslint.config.ts index 3ad574dc3a74..837dbac5c56f 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -875,6 +875,7 @@ export default typescript.config([ 'error', {additionalTestBlockFunctions: ['it.isKnownFlake']}, ], + 'jest/prefer-jest-mocked': 'error', 'jest/expect-expect': 'off', // Disabled as we have many tests which render as simple validations 'jest/no-conditional-expect': 'off', // TODO(ryan953): Fix violations then delete this line diff --git a/static/app/components/events/autofix/autofixChanges.analytics.spec.tsx b/static/app/components/events/autofix/autofixChanges.analytics.spec.tsx index a791cf4487a5..9c2ac387b69d 100644 --- a/static/app/components/events/autofix/autofixChanges.analytics.spec.tsx +++ b/static/app/components/events/autofix/autofixChanges.analytics.spec.tsx @@ -32,7 +32,7 @@ jest.mock('@sentry/scraps/button', () => ({ jest.mock('sentry/components/events/autofix/useAutofix'); -const mockButton = Button as jest.MockedFunction; +const mockButton = jest.mocked(Button); describe('AutofixChanges', () => { const defaultProps = { diff --git a/static/app/views/settings/projectGeneralSettings/index.spec.tsx b/static/app/views/settings/projectGeneralSettings/index.spec.tsx index 1168e4d48770..8f7df4e3d40c 100644 --- a/static/app/views/settings/projectGeneralSettings/index.spec.tsx +++ b/static/app/views/settings/projectGeneralSettings/index.spec.tsx @@ -130,9 +130,7 @@ describe('projectGeneralSettings', () => { }) ); - const addSuccessMessageMock = addSuccessMessage as jest.MockedFunction< - typeof addSuccessMessage - >; + const addSuccessMessageMock = jest.mocked(addSuccessMessage); const undo = addSuccessMessageMock.mock.calls[0]?.[1]?.undo; expect(undo).toBeInstanceOf(Function); diff --git a/static/gsApp/components/productSelectionAvailability.spec.tsx b/static/gsApp/components/productSelectionAvailability.spec.tsx index e74286e7fbb2..892d57e29613 100644 --- a/static/gsApp/components/productSelectionAvailability.spec.tsx +++ b/static/gsApp/components/productSelectionAvailability.spec.tsx @@ -333,9 +333,7 @@ describe('ProductSelectionAvailability', () => { }, }; - const MockUsePreviewData = usePreviewData as jest.MockedFunction< - typeof usePreviewData - >; + const MockUsePreviewData = jest.mocked(usePreviewData); const mockReservations: Reservations = { reservedErrors: 50000, reservedTransactions: 0, diff --git a/static/gsApp/components/productUnavailableCTA.spec.tsx b/static/gsApp/components/productUnavailableCTA.spec.tsx index e8916c097c3c..597db6c68fa3 100644 --- a/static/gsApp/components/productUnavailableCTA.spec.tsx +++ b/static/gsApp/components/productUnavailableCTA.spec.tsx @@ -201,9 +201,7 @@ describe('ProductUnavailableCTA', () => { canSelfServe: true, }); - const MockUsePreviewData = usePreviewData as jest.MockedFunction< - typeof usePreviewData - >; + const MockUsePreviewData = jest.mocked(usePreviewData); const mockReservations: Reservations = { reservedErrors: 50000, reservedTransactions: 0, diff --git a/static/gsApp/utils/rawTrackAnalyticsEvent.spec.tsx b/static/gsApp/utils/rawTrackAnalyticsEvent.spec.tsx index aee38dfd074f..17d3af8d583b 100644 --- a/static/gsApp/utils/rawTrackAnalyticsEvent.spec.tsx +++ b/static/gsApp/utils/rawTrackAnalyticsEvent.spec.tsx @@ -25,7 +25,7 @@ describe('rawTrackAnalyticsEvent', () => { const org_id = Number(organization.id); beforeEach(() => { - (uniqueId as jest.MockedFunction).mockReturnValue('345'); + jest.mocked(uniqueId).mockReturnValue('345'); }); afterEach(() => {