diff --git a/src/core/public/apm_system.test.ts b/src/core/public/apm_system.test.ts index f88cdd899ef81..cd8488413fe29 100644 --- a/src/core/public/apm_system.test.ts +++ b/src/core/public/apm_system.test.ts @@ -19,6 +19,7 @@ jest.mock('@elastic/apm-rum'); import { init, apm } from '@elastic/apm-rum'; +import type { DeeplyMockedKeys } from '../types'; import { ApmSystem } from './apm_system'; const initMock = init as jest.Mocked; diff --git a/src/core/public/chrome/chrome_service.mock.ts b/src/core/public/chrome/chrome_service.mock.ts index 9cd96763d2e79..d6d77dffafec1 100644 --- a/src/core/public/chrome/chrome_service.mock.ts +++ b/src/core/public/chrome/chrome_service.mock.ts @@ -18,6 +18,7 @@ */ import { BehaviorSubject } from 'rxjs'; import type { PublicMethodsOf } from '@kbn/utility-types'; +import type { DeeplyMockedKeys } from '../../types'; import { ChromeBadge, ChromeBrand, ChromeBreadcrumb, ChromeService, InternalChromeStart } from './'; const createStartContractMock = () => { diff --git a/src/core/public/index.ts b/src/core/public/index.ts index 24d19e2d32074..ec4fb53959f80 100644 --- a/src/core/public/index.ts +++ b/src/core/public/index.ts @@ -80,7 +80,7 @@ import { export { PackageInfo, EnvironmentMode } from '../server/types'; export { CoreContext, CoreSystem } from './core_system'; export { DEFAULT_APP_CATEGORIES } from '../utils'; -export { +export type { AppCategory, UiSettingsParams, UserProvidedValues, @@ -89,6 +89,8 @@ export { StringValidation, StringValidationRegex, StringValidationRegexString, + DeeplyMockedKeys, + MockedKeys, } from '../types'; export { diff --git a/src/core/public/notifications/notifications_service.mock.ts b/src/core/public/notifications/notifications_service.mock.ts index 990ab479d35c3..8e7427ee147f0 100644 --- a/src/core/public/notifications/notifications_service.mock.ts +++ b/src/core/public/notifications/notifications_service.mock.ts @@ -17,6 +17,7 @@ * under the License. */ import type { PublicMethodsOf } from '@kbn/utility-types'; +import type { MockedKeys } from '../../types'; import { NotificationsService, NotificationsSetup, diff --git a/src/core/public/overlays/overlay_service.mock.ts b/src/core/public/overlays/overlay_service.mock.ts index 66ba36b20b45c..48c6e09a28f56 100644 --- a/src/core/public/overlays/overlay_service.mock.ts +++ b/src/core/public/overlays/overlay_service.mock.ts @@ -17,6 +17,7 @@ * under the License. */ import type { PublicMethodsOf } from '@kbn/utility-types'; +import type { DeeplyMockedKeys } from '../../types'; import { OverlayService, OverlayStart } from './overlay_service'; import { overlayBannersServiceMock } from './banners/banners_service.mock'; import { overlayFlyoutServiceMock } from './flyout/flyout_service.mock'; diff --git a/src/core/server/core_context.mock.ts b/src/core/server/core_context.mock.ts index bbf04783278f7..eb4ce78ffda31 100644 --- a/src/core/server/core_context.mock.ts +++ b/src/core/server/core_context.mock.ts @@ -18,6 +18,7 @@ */ import { REPO_ROOT } from '@kbn/dev-utils'; +import type { DeeplyMockedKeys } from '../types'; import { CoreContext } from './core_context'; import { Env, IConfigService } from './config'; import { configServiceMock, getEnvOptions } from './config/mocks'; diff --git a/src/core/server/elasticsearch/client/mocks.ts b/src/core/server/elasticsearch/client/mocks.ts index fb2826c787718..5ca92d6e8d1e5 100644 --- a/src/core/server/elasticsearch/client/mocks.ts +++ b/src/core/server/elasticsearch/client/mocks.ts @@ -19,6 +19,7 @@ import { Client, ApiResponse } from '@elastic/elasticsearch'; import { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport'; import { ElasticsearchClient } from './types'; +import type { DeeplyMockedKeys } from '../../../types'; import { ICustomClusterClient } from './cluster_client'; const createInternalClientMock = (): DeeplyMockedKeys => { diff --git a/src/core/server/index.ts b/src/core/server/index.ts index efb196590ea97..a77fcd33c026d 100644 --- a/src/core/server/index.ts +++ b/src/core/server/index.ts @@ -334,7 +334,7 @@ export { MetricsServiceStart, } from './metrics'; -export { AppCategory } from '../types'; +export type { AppCategory, DeeplyMockedKeys, MockedKeys } from '../types'; export { DEFAULT_APP_CATEGORIES } from '../utils'; export { diff --git a/src/core/server/mocks.ts b/src/core/server/mocks.ts index e47d06409894e..ff647715b4847 100644 --- a/src/core/server/mocks.ts +++ b/src/core/server/mocks.ts @@ -19,7 +19,13 @@ import { of } from 'rxjs'; import { duration } from 'moment'; import { ByteSizeValue } from '@kbn/config-schema'; -import { PluginInitializerContext, CoreSetup, CoreStart, StartServicesAccessor } from '.'; +import type { + PluginInitializerContext, + CoreSetup, + CoreStart, + StartServicesAccessor, + MockedKeys, +} from '.'; import { loggingSystemMock } from './logging/logging_system.mock'; import { loggingServiceMock } from './logging/logging_service.mock'; import { elasticsearchServiceMock } from './elasticsearch/elasticsearch_service.mock'; diff --git a/src/core/types/index.ts b/src/core/types/index.ts index 07d7789d235ec..ab7acd5a06b38 100644 --- a/src/core/types/index.ts +++ b/src/core/types/index.ts @@ -27,3 +27,4 @@ export * from './app_category'; export * from './ui_settings'; export * from './saved_objects'; export * from './serializable'; +export * from './mocks'; diff --git a/src/core/typings.ts b/src/core/types/mocks.ts similarity index 90% rename from src/core/typings.ts rename to src/core/types/mocks.ts index f271d0b03e0d3..fe182ddfb131b 100644 --- a/src/core/typings.ts +++ b/src/core/types/mocks.ts @@ -17,11 +17,11 @@ * under the License. */ -type DeeplyMockedKeys = { +export type DeeplyMockedKeys = { [P in keyof T]: T[P] extends (...args: any[]) => any ? jest.MockInstance, Parameters> : DeeplyMockedKeys; } & T; -type MockedKeys = { [P in keyof T]: jest.Mocked }; +export type MockedKeys = { [P in keyof T]: jest.Mocked };