Skip to content

Lupa API Reference / commands / Events

Class: Events

Defined in: src/commands/events.ts:1263

Synthetic event dispatcher for browser DOM testing.

Use

when

  • Fast event dispatching is required without Playwright IPC overhead.
  • Testing event handlers in isolated web components or DOM subtrees.

Dont

use when

  • Testing native browser behaviors that depend on OS-level input drivers or Playwright actionability checks.

Example

typescript
import { events, KeyCode } from '@pawel-up/lupa/commands'

const input = document.querySelector('input')!
events(input).focus.in()
events(input).input.fill('Hello World')
events(input).clipboard.paste('Pasted Text')
await events(input).keyboard.press('Enter')
events(input).focus.out()

Constructors

Constructor

new Events(target): Events

Defined in: src/commands/events.ts:1294

Creates a new instance of the Events class.

Parameters

target

EventTarget

The target DOM node for dispatching synthetic events.

Returns

Events

Properties

clipboard

readonly clipboard: ClipboardEvents

Defined in: src/commands/events.ts:1282

Synthetic clipboard event helper.


focus

readonly focus: FocusEvents

Defined in: src/commands/events.ts:1287

Synthetic focus and blur event helper.


input

readonly input: InputEvents

Defined in: src/commands/events.ts:1277

Synthetic input/form control event helper.


keyboard

readonly keyboard: KeyboardEvents

Defined in: src/commands/events.ts:1267

Synthetic keyboard event helper.


mouse

readonly mouse: MouseEvents

Defined in: src/commands/events.ts:1272

Synthetic mouse event helper.