jest . mock ( './browsers/install' ) ; import type { CoreSetup , CoreStart , PluginInitializerContext } from 'kibana/server' ; import { coreMock } from 'src/core/server/mocks' ; import type { ScreenshotModePluginSetup } from 'src/plugins/screenshot_mode/server' ; import { install } from './browsers/install' ; import { ScreenshottingPlugin } from './plugin' ; describe ( 'ScreenshottingPlugin' , ( ) => { let initContext ; let coreSetup ; let coreStart ; let setupDeps ; let plugin ; beforeEach ( ( ) => { const configSchema = { browser : { chromium : { disableSandbox : false } } , } ; initContext = coreMock . createPluginInitializerContext ( configSchema ) ; coreSetup = coreMock . createSetup ( { } ) ; coreStart = coreMock . createStart ( ) ; setupDeps = { screenshotMode : { } as ScreenshotModePluginSetup , } ; plugin = new ScreenshottingPlugin ( initContext ) ; } ) ; describe ( 'setup' , ( ) => { test ( 'returns a setup contract' , async ( ) => { const setupContract = plugin . setup ( coreSetup , setupDeps ) ; expect ( setupContract ) . toEqual ( { } ) ; } ) ; test ( 'handles setup issues' , async ( ) => { ( install as jest . Mock ) . mockRejectedValue ( `Unsupported platform!!!` ) ; const setupContract = plugin . setup ( coreSetup , setupDeps ) ; expect ( setupContract ) . toEqual ( { } ) ; await coreSetup . getStartServices ( ) ; const startContract = plugin . start ( coreStart ) ; expect ( startContract ) . toEqual ( expect . objectContaining ( { diagnose : expect . any ( Function ) , getScreenshots : expect . any ( Function ) , } ) ) ; } ) ; } ) ; describe ( 'start' , ( ) => { beforeEach ( async ( ) => { plugin . setup ( coreSetup , setupDeps ) ; await coreSetup . getStartServices ( ) ; } ) ; test ( 'returns a start contract' , async ( ) => { const startContract = plugin . start ( coreStart ) ; expect ( startContract ) . toEqual ( expect . objectContaining ( { diagnose : expect . any ( Function ) , getScreenshots : expect . any ( Function ) , } ) ) ; } ) ; } ) ; } ) ;