import type { EnvironmentContext, JestEnvironment, JestEnvironmentConfig } from '@jest/environment'; import type { Circus } from '@jest/types'; import type { ReadonlySemiAsyncEmitter } from './emitters'; export type TestEnvironmentEvent = | TestEnvironmentSetupEvent | TestEnvironmentTeardownEvent | TestEnvironmentCircusEvent; export type TestEnvironmentSetupEvent = { type: 'test_environment_setup'; env: JestEnvironment; }; export type TestEnvironmentTeardownEvent = { type: 'test_environment_teardown'; env: JestEnvironment; }; export type TestEnvironmentCircusEvent = { type: E['name']; env: JestEnvironment; event: E; state: Circus.State; }; export type TestEnvironmentSyncEventMap = { add_hook: TestEnvironmentCircusEvent; add_test: TestEnvironmentCircusEvent; error: TestEnvironmentCircusEvent; finish_describe_definition: TestEnvironmentCircusEvent< Circus.Event & { name: 'finish_describe_definition' } >; start_describe_definition: TestEnvironmentCircusEvent< Circus.Event & { name: 'start_describe_definition' } >; }; export type TestEnvironmentAsyncEventMap = { hook_failure: TestEnvironmentCircusEvent; hook_start: TestEnvironmentCircusEvent; hook_success: TestEnvironmentCircusEvent; include_test_location_in_result: TestEnvironmentCircusEvent< Circus.Event & { name: 'include_test_location_in_result' } >; run_describe_finish: TestEnvironmentCircusEvent; run_describe_start: TestEnvironmentCircusEvent; run_finish: TestEnvironmentCircusEvent; run_start: TestEnvironmentCircusEvent; setup: TestEnvironmentCircusEvent; teardown: TestEnvironmentCircusEvent; test_done: TestEnvironmentCircusEvent; test_environment_setup: TestEnvironmentSetupEvent; test_environment_teardown: TestEnvironmentTeardownEvent; test_fn_failure: TestEnvironmentCircusEvent; test_fn_start: TestEnvironmentCircusEvent; test_fn_success: TestEnvironmentCircusEvent; test_retry: TestEnvironmentCircusEvent; test_skip: TestEnvironmentCircusEvent; test_start: TestEnvironmentCircusEvent; test_started: TestEnvironmentCircusEvent; test_todo: TestEnvironmentCircusEvent; }; export type EnvironmentListener = | EnvironmentListenerWithOptions | EnvironmentListenerOnly; export type EnvironmentListenerWithOptions = [ EnvironmentListenerOnly, any, ]; export type EnvironmentListenerOnly = | EnvironmentListenerFn | string; export type EnvironmentListenerFn = ( context: Readonly>, listenerConfig?: any, ) => void; export type EnvironmentEventEmitter = ReadonlySemiAsyncEmitter< TestEnvironmentAsyncEventMap, TestEnvironmentSyncEventMap >; export type EnvironmentListenerContext = { env: E; testEvents: EnvironmentEventEmitter; context: EnvironmentContext; config: JestEnvironmentConfig; };