Skip to main content

Abstract Class: ComponentDriver<T>

Defined in: packages/core/src/drivers/ComponentDriver.ts:34

Base class for all component drivers. It provides the basic functionality to interact with the component

Extended by​

Type Parameters​

T​

T extends ScenePart = { }

Implements​

Constructors​

Constructor​

new ComponentDriver<T>(locator, interactor, option?): ComponentDriver<T>

Defined in: packages/core/src/drivers/ComponentDriver.ts:64

Parameters​

locator​

PartLocator

Locator for the root of this component.

interactor​

Interactor

Environment adapter used for all interactions.

option?​

Partial<IComponentDriverOption<T>>

Driver option carrying the shared driver-tree context.

Composite-driver authoring rule: a driver that declares non-empty parts must type this parameter as Partial<IComponentDriverOption> (i.e. the empty <{}> default) and hardcode its own parts in the body — super(locator, interactor, { ...option, parts }). The "natural" Partial<IComponentDriverOption<typeof parts>> signature does NOT satisfy ScenePartDefinition['driver'] (constructor parameters are checked contravariantly), so a driver written that way could not be placed in a parent ScenePart. Lock a composite driver against this rule in one line with AssertScenePlaceableDriver; the rule itself is regression-tested centrally in core/src/drivers/__type-tests__ and demonstrated in @atomic-testing/component-driver-html.

Returns​

ComponentDriver<T>

Properties​

commutableOption​

readonly commutableOption: CommutableComponentDriverOption

Defined in: packages/core/src/drivers/ComponentDriver.ts:45

The component-agnostic slice of the constructor option that is safe to share across the whole driver tree — everything the constructor received EXCEPT the component-specific parts, which each driver owns for itself. Parent drivers pass this straight to the constructors of children they create dynamically (see the list helpers). See CommutableComponentDriverOption.


interactor​

readonly interactor: Interactor

Defined in: packages/core/src/drivers/ComponentDriver.ts:66

Environment adapter used for all interactions.

Accessors​

driverName​

Get Signature​

get abstract driverName(): string

Defined in: packages/core/src/drivers/ComponentDriver.ts:381

Returns​

string


locator​

Get Signature​

get locator(): PartLocator

Defined in: packages/core/src/drivers/ComponentDriver.ts:115

Return the locator of the component

Returns​

PartLocator

The locator which helps locate the root of the component

Implementation of​

IComponentDriver.locator


parts​

Get Signature​

get parts(): ScenePartDriver<T>

Defined in: packages/core/src/drivers/ComponentDriver.ts:108

Return driver instance of all the named parts

Returns​

ScenePartDriver<T>

Return driver instance of all the named parts

Implementation of​

IComponentDriver.parts

Methods​

click()​

click(option?): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:181

Parameters​

option?​

Partial<ClickOption>

Returns​

Promise<void>


exists()​

exists(): Promise<boolean>

Defined in: packages/core/src/drivers/ComponentDriver.ts:177

Whether the component exists/attached to the DOM

Returns​

Promise<boolean>

true if the component is attached to the DOM, false otherwise

Implementation of​

IComponentDriver.exists


focus()​

focus(option?): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:224

Parameters​

option?​

Partial<FocusOption>

Returns​

Promise<void>


getAttribute()​

getAttribute(attributeName): Promise<Optional<string>>

Defined in: packages/core/src/drivers/ComponentDriver.ts:169

Parameters​

attributeName​

string

Returns​

Promise<Optional<string>>


getText()​

getText(): Promise<Optional<string>>

Defined in: packages/core/src/drivers/ComponentDriver.ts:165

Get the combined text content of the component

Returns​

Promise<Optional<string>>

If the component exists and has content, it should return the text or otherwise undefined

Implementation of​

IComponentDriver.getText


hover()​

hover(option?): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:185

Parameters​

option?​

Partial<HoverOption>

Returns​

Promise<void>


isVisible()​

isVisible(): Promise<boolean>

Defined in: packages/core/src/drivers/ComponentDriver.ts:328

Whether the component is visible. Visibility is defined that the component does not have the CSS property display: none, visibility: hidden, or opacity: 0. However this does not check whether the component is within the viewport.

Returns​

Promise<boolean>

true if the component is visible, false otherwise

Implementation of​

IComponentDriver.isVisible


pressKey()​

pressKey(key, option?): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:233

Dispatch a keyboard key press on the component. See Interactor.pressKey.

Parameters​

key​

string

A KeyboardEvent.key value, e.g. 'Escape', 'Backspace', 'Enter'

option?​

Partial<PressKeyOption>

Reserved for future modifier-key support

Returns​

Promise<void>


runtimeCssSelector()​

runtimeCssSelector(): Promise<string>

Defined in: packages/core/src/drivers/ComponentDriver.ts:377

Get the runtime CSS selector of the component. This is useful for debugging and testing purposes.

Returns​

Promise<string>

The runtime CSS selector of the component


scrollIntoView()​

scrollIntoView(): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:266

Scroll the component into the viewport. See Interactor.scrollIntoView.

jsdom has no layout engine, so the scroll is a no-op there and behavioral assertions (visibility, offset) are E2E-only.

Returns​

Promise<void>


typeText()​

typeText(text): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:242

Type text into the component as real per-character keystrokes, inserting at the current caret without clearing. See Interactor.typeText.

Parameters​

text​

string

The literal text to type, one keystroke per character

Returns​

Promise<void>


waitUntil()​

waitUntil<T>(option): Promise<T>

Defined in: packages/core/src/drivers/ComponentDriver.ts:360

Type Parameters​

T​

T

Parameters​

option​

WaitUntilOption<T>

Returns​

Promise<T>


waitUntilComponentState()​

waitUntilComponentState(option?): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:356

Wait until the component is in the expected state such as the component's visibility or existence. If the component has not reached the expected state within the timeout, it will throw an error.

By default it waits until the component is attached to the DOM within 30 seconds.

Parameters​

option?​

Partial<Readonly<WaitForOption>> = defaultWaitForOption

The option to configure the wait behavior

Returns​

Promise<void>

Implementation of​

IComponentDriver.waitUntilComponentState


waitUntilVisible()​

waitUntilVisible(timeoutMs?): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:338

Wait until the component is attached and becomes visible to the DOM.

Parameters​

timeoutMs?​

number = defaultWaitForOption.timeoutMs

The number of milliseconds to wait before timing out. Defaults to defaultWaitForOption.timeoutMs so this wait shares a single flake-tolerance source with waitUntilComponentState (#1057).

Returns​

Promise<void>


overriddenParentLocator()​

static overriddenParentLocator(): Optional<PartLocator>

Defined in: packages/core/src/drivers/ComponentDriver.ts:88

Portal hook: where to re-root this driver's locator when its component renders outside the parent's DOM (a modal, popup, drawer). Return the PartLocator that locates the component from the document root, or undefined (the default) for normal in-tree components whose locator chains from the parent.

This is static because it is per-class metadata read off the constructor before any instance exists — which makes the "no instance state" constraint structural rather than a documented caution. Override with static override.

Returns​

Optional<PartLocator>


overrideLocatorRelativePosition()​

static overrideLocatorRelativePosition(): Optional<LocatorRelativePosition>

Defined in: packages/core/src/drivers/ComponentDriver.ts:101

Portal hook: the locator relative position to apply when the component's real DOM is a sibling/elsewhere rather than a descendant (e.g. a MUI dialog rendered at the document root, located by a "Same"-level selector). Return undefined (the default) to keep the natural position declared by the ScenePart.

Static for the same reason as ComponentDriver.overriddenParentLocator: it is class-level metadata read before construction. Override with static override.

Returns​

Optional<LocatorRelativePosition>

Protected members (16)

Methods​

activate()​

protected activate(): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:256

Activate the component without relying on pointer geometry. See Interactor.activate.

Returns​

Promise<void>


contextMenu()​

protected contextMenu(): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:249

Dispatch a right-click / contextmenu event on the component. See Interactor.contextMenu.

Returns​

Promise<void>


drag()​

protected drag(delta): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:306

Drag this component by the given pixel delta from its center. See Interactor.drag.

Prefer a keyboard-driven setValue over a true drag in real drivers — these drag primitives exist only for cases keyboard cannot express (e.g. panning a Lightbox, reordering a column). jsdom has no layout engine, so the positional outcome of the drag is E2E-only there.

Parameters​
delta​

Point

Pixel offset to drag by

Returns​

Promise<void>


dragTo()​

protected dragTo(target): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:292

Drag this component and drop it onto another component. See Interactor.dragTo.

Prefer a keyboard-driven setValue over a true drag in real drivers — these drag primitives exist only for cases keyboard cannot express (e.g. panning a Lightbox, reordering a column). jsdom has no layout engine, so the positional outcome of the drag is E2E-only there.

Parameters​
target​

ComponentDriver<any>

Another driver whose root element is the drop target

Returns​

Promise<void>


enforcePartExistence()​

protected enforcePartExistence(partName): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:124

Check the specified parts' existences, and throw MissingPartError if any of the part is found not existence. Existence is defined by the part's existence in the DOM regardless of its visibility on the screen

Parameters​
partName​

keyof T | readonly keyof T[]

Single or array of the names of the parts to be enforced

Returns​

Promise<void>


getBoundingRect()​

protected getBoundingRect(): Promise<BoundingRect>

Defined in: packages/core/src/drivers/ComponentDriver.ts:316

Get this component's bounding rectangle. See Interactor.getBoundingRect.

jsdom has no layout engine, so every coordinate and dimension is 0 there; real geometry is E2E-only.

Returns​

Promise<BoundingRect>


getMissingPartNames()​

protected getMissingPartNames(partName): Promise<readonly keyof T[]>

Defined in: packages/core/src/drivers/ComponentDriver.ts:136

Get the names of parts not in the DOM

Parameters​
partName​

keyof T | readonly keyof T[]

Single or array of the names of the parts to be examined

Returns​

Promise<readonly keyof T[]>


innerHTML()​

protected innerHTML(): Promise<string>

Defined in: packages/core/src/drivers/ComponentDriver.ts:368

Get the inner HTML of the component

Returns​

Promise<string>

The inner HTML of the component


mouseDown()​

protected mouseDown(option?): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:200

Parameters​
option?​

Partial<MouseDownOption>

Returns​

Promise<void>


mouseEnter()​

protected mouseEnter(option?): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:216

Parameters​
option?​

Partial<MouseEnterOption>

Returns​

Promise<void>


mouseLeave()​

protected mouseLeave(option?): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:220

Parameters​
option?​

Partial<MouseLeaveOption>

Returns​

Promise<void>


mouseMove()​

protected mouseMove(option?): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:196

Parameters​
option?​

Partial<MouseMoveOption>

Returns​

Promise<void>


mouseOut()​

protected mouseOut(option?): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:212

Parameters​
option?​

Partial<MouseOutOption>

Returns​

Promise<void>


mouseOver()​

protected mouseOver(option?): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:208

Parameters​
option?​

Partial<HoverOption>

Returns​

Promise<void>


mouseUp()​

protected mouseUp(option?): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:204

Parameters​
option?​

Partial<MouseUpOption>

Returns​

Promise<void>


scrollBy()​

protected scrollBy(delta): Promise<void>

Defined in: packages/core/src/drivers/ComponentDriver.ts:278

Scroll the component by the given pixel delta. See Interactor.scrollBy.

jsdom has no layout engine, so the scroll is a no-op there and behavioral assertions (resulting offset) are E2E-only.

Parameters​
delta​

Point

Pixel offset to scroll by

Returns​

Promise<void>