import { expectTypeOf } from 'expect-type'; import { // DOM Interaction Helpers blur, click, doubleClick, fillIn, focus, scrollTo, select, tab, tap, triggerEvent, triggerKeyEvent, typeIn, // DOM Query Helpers find, findAll, getRootElement, // Routing Helpers visit, currentRouteName, currentURL, // Rendering Helpers render, rerender, clearRender, // Wait Helpers waitFor, waitUntil, settled, isSettled, getSettledState, // Pause Helpers pauseTest, resumeTest, // Debug Helpers getDebugInfo, registerDebugInfoHelper, // Test Framework APIs setResolver, getResolver, setupContext, getContext, setContext, unsetContext, teardownContext, setupRenderingContext, RenderingTestContext, getApplication, setApplication, setupApplicationContext, validateErrorHandler, setupOnerror, resetOnerror, getTestMetadata, // deprecation and warning APIs getDeprecations, getDeprecationsDuringCallback, getWarnings, getWarningsDuringCallback, BaseContext, TestContext, TestMetadata, DebugInfo as InternalDebugInfo, DeprecationFailure, Warning, Target, // Helper hooks registerHook, runHooks, type Hook, type HookLabel, type HookUnregister, } from '@ember/test-helpers'; import { ComponentInstance } from '@glimmer/interfaces'; import { Owner } from '@ember/test-helpers/build-owner'; import { DebugInfo as BackburnerDebugInfo } from '@ember/runloop/-private/backburner'; import type { Resolver as EmberResolver } from '@ember/owner'; import Application from '@ember/application'; import { TemplateFactory } from 'ember-cli-htmlbars'; import type { IDOMElementDescriptor } from 'dom-element-descriptors'; // DOM Interaction Helpers expectTypeOf(blur).toEqualTypeOf<(target?: Target) => Promise>(); expectTypeOf(click).toEqualTypeOf< (target: Target, options?: MouseEventInit) => Promise >(); expectTypeOf(doubleClick).toEqualTypeOf< (target: Target, options?: MouseEventInit) => Promise >(); expectTypeOf(fillIn).toEqualTypeOf< (target: Target, text: string) => Promise >(); expectTypeOf(focus).toEqualTypeOf<(target: Target) => Promise>(); expectTypeOf(scrollTo).toEqualTypeOf< ( target: string | HTMLElement | IDOMElementDescriptor, x: number, y: number ) => Promise >(); expectTypeOf(select).toEqualTypeOf< ( target: Target, options: string | string[], keepPreviouslySelected?: boolean ) => Promise >(); expectTypeOf(tab).toEqualTypeOf< ({ backwards, unRestrainTabIndex, }?: { backwards?: boolean | undefined; unRestrainTabIndex?: boolean | undefined; }) => Promise >(); expectTypeOf(tap).toEqualTypeOf< (target: Target, options?: TouchEventInit) => Promise >(); expectTypeOf(triggerEvent).toEqualTypeOf< ( target: Target, eventType: string, options?: Record ) => Promise >(); expectTypeOf(triggerKeyEvent).toEqualTypeOf< ( target: Target, eventType: 'keydown' | 'keyup' | 'keypress', key: number | string, modifiers?: { ctrlKey?: boolean; altKey?: boolean; shiftKey?: boolean; metaKey?: boolean; } ) => Promise >(); expectTypeOf(typeIn).toEqualTypeOf< ( target: Target, text: string, options?: { delay?: number; } ) => Promise >(); // DOM Query Helpers expectTypeOf(find).toEqualTypeOf(); expectTypeOf(find('a')).toEqualTypeOf(); expectTypeOf(find('div')).toEqualTypeOf(); expectTypeOf(find('circle')).toEqualTypeOf(); expectTypeOf(find('.corkscrew')).toEqualTypeOf(); expectTypeOf(findAll).toEqualTypeOf<(selector: string) => Array>(); expectTypeOf(findAll('a')).toEqualTypeOf<(HTMLAnchorElement | SVGAElement)[]>(); expectTypeOf(findAll('div')).toEqualTypeOf(); expectTypeOf(findAll('circle')).toEqualTypeOf(); expectTypeOf(findAll('.corkscrew')).toEqualTypeOf(); expectTypeOf(getRootElement).toEqualTypeOf<() => Element | Document>(); // Routing Helpers expectTypeOf(visit).toEqualTypeOf< (url: string, options?: Record) => Promise >(); expectTypeOf(currentRouteName).toEqualTypeOf<() => string>(); expectTypeOf(currentURL).toEqualTypeOf<() => string>(); // Rendering Helpers expectTypeOf(render).toMatchTypeOf< (templateOrComponent: object, options?: { owner?: Owner }) => Promise >(); expectTypeOf(rerender).toMatchTypeOf<() => Promise>(); expectTypeOf(clearRender).toEqualTypeOf<() => Promise>(); // Wait Helpers expectTypeOf(waitFor).toEqualTypeOf< ( selector: string | IDOMElementDescriptor, options?: { timeout?: number; count?: number | null; timeoutMessage?: string; } ) => Promise> >(); expectTypeOf(waitUntil).toEqualTypeOf< ( callback: () => T | void | false | 0 | '' | null | undefined, options?: { timeout?: number; timeoutMessage?: string; } ) => Promise >(); expectTypeOf(settled).toEqualTypeOf<() => Promise>(); expectTypeOf(isSettled).toEqualTypeOf<() => boolean>(); expectTypeOf(getSettledState).toEqualTypeOf< () => { hasRunLoop: boolean; hasPendingTimers: boolean; hasPendingWaiters: boolean; hasPendingRequests: boolean; hasPendingTransitions: boolean | null; isRenderPending: boolean; pendingRequestCount: number; debugInfo: InternalDebugInfo; } >(); // Pause Helpers expectTypeOf(pauseTest).toEqualTypeOf<() => Promise>(); expectTypeOf(resumeTest).toEqualTypeOf<() => void>(); // Debug Helpers expectTypeOf(getDebugInfo).toEqualTypeOf<() => BackburnerDebugInfo | null>(); expectTypeOf(registerDebugInfoHelper).toEqualTypeOf< (debugInfoHelper: { name: string; log: () => void }) => void >(); // Test Framework APIs expectTypeOf(setResolver).toEqualTypeOf<(resolver: EmberResolver) => void>(); expectTypeOf(getResolver).toEqualTypeOf<() => EmberResolver | undefined>(); expectTypeOf(setupContext).toEqualTypeOf< ( context: BaseContext, options?: { resolver?: EmberResolver } ) => Promise >(); expectTypeOf(getContext).toEqualTypeOf<() => BaseContext | undefined>(); expectTypeOf(setContext).toEqualTypeOf<(context: BaseContext) => void>(); expectTypeOf(unsetContext).toEqualTypeOf<() => void>(); expectTypeOf(teardownContext).toEqualTypeOf< ( context: TestContext, options?: { waitForSettled?: boolean } ) => Promise >(); expectTypeOf(setupRenderingContext).toEqualTypeOf< (context: TestContext) => Promise >(); expectTypeOf(getApplication).toEqualTypeOf<() => Application | undefined>(); expectTypeOf(setApplication).toEqualTypeOf< (application: Application) => void >(); expectTypeOf(setupApplicationContext).toEqualTypeOf< (context: TestContext) => Promise >(); expectTypeOf(validateErrorHandler).toMatchTypeOf< ( callback?: (error: Error) => void ) => | Readonly<{ isValid: true; message: null }> | Readonly<{ isValid: false; message: string }> >(); expectTypeOf(setupOnerror).toEqualTypeOf< (onError?: (error: Error) => void) => void >(); expectTypeOf(resetOnerror).toEqualTypeOf<() => void>(); expectTypeOf(getTestMetadata).toEqualTypeOf< (context: BaseContext) => TestMetadata >(); // deprecation and warning APIs expectTypeOf(getDeprecations).toEqualTypeOf<() => Array>(); expectTypeOf(getDeprecationsDuringCallback).toEqualTypeOf< ( callback: () => void ) => Array | Promise> >(); expectTypeOf(getWarnings).toEqualTypeOf<() => Array>(); expectTypeOf(getWarningsDuringCallback).toEqualTypeOf< (callback: () => void) => Array | Promise> >(); // Helper hooks expectTypeOf(registerHook).toEqualTypeOf< (helperName: string, label: HookLabel, hook: Hook) => HookUnregister >(); expectTypeOf(runHooks).toEqualTypeOf< (helperName: string, label: HookLabel, ...args: unknown[]) => Promise >();