Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

ActionTarget

ActionTarget: Element | string | Point | []

This union type represent action target for various user-action simulation methods.

It can be:

  • a native DOM Element
  • a string, which contains a CSS query to be resolved. The onAmbiguousQuery config controls the behavior if a query is resolved to multiple elements.
  • a Point on the screen, with the coordinates in the client coordinate system.
  • an empty array - equivalent of the point with current cursor location.

For example:

await t.click(document.body)
await t.click('body .css-class')
await t.click([ 100, 200 ])
await t.click([])

ActionTargetOffset

ActionTargetOffset: [dx: number | string, dy: number | string]

The offset for the action point. It should be a 2-elements array with either exact offsets (number) or "offset expressions" (string).

The expression consists from "percentage" part and optional "fixed" part and should have the following syntax:

'25%'
'50% + 10'
'50% - 10'

Overall, it may look like this:

[ 10, '50% + 10' ]

Note, that '100%' offset corresponds to the 1st point outside of the element's dimension, to specify the right/bottom-most element's point as an offset, provide it as:

[ '100% - 1', '100% - 1' ]

FiresOkOptions

FiresOkOptions<O>: { description?: string; during?: number | AnyFunction; events: Record<string, string | number>; observable: O }

The options object for the firesOk assertion

Type parameters

  • O

Type declaration

  • Optional description?: string

    Description for the assertion.

  • Optional during?: number | AnyFunction

    The period of time during which the events are counted. It can be:

    • execution of the function (which can possibly be async, in this case, don't forget to await on the firesOk call itself)
    • time period, in milliseconds
    • the rest of the test (if not provided).
  • events: Record<string, string | number>

    An object with the events to count. The keys of the object corresponds to the event names. The values - to the expected number of that event. The value can be either a number indicating the exact expected events number, or a string, with the "expected number expression".

    The expression consists from the comparison operator and number:

    '> 5'
    '<= 1'
    '== 3'
  • observable: O

    The observable, on which to count the fired events. The exact meaning of the "observable" depends from the environment, for example in browsers it is an instance of EventTarget interface and in Node.js - EventEmitter class.

    In general "observable" is whatever the resolveObservable method accepts as the 1st argument.

KeyboardActionOptions

KeyboardActionOptions: { altKey: boolean; clearExisting: boolean; ctrlKey: boolean; delay: number; metaKey: boolean; shiftKey: boolean; target: ActionTarget; text: SiestaTypeString; timeout: number }

The options object for the keyboard action

Type declaration

  • altKey: boolean

    Set to true to simulate Alt keypress during the action

  • clearExisting: boolean

    Whether to clear any existing text in the target <input>/<textarea> element before typing.

  • ctrlKey: boolean

    Set to true to simulate Ctrl keypress during the action

  • delay: number

    Delay between the individual key down / key up events. By default 0 (no delay)

  • metaKey: boolean

    Set to true to simulate Meta keypress during the action

  • shiftKey: boolean

    Set to true to simulate Shift keypress during the action

  • target: ActionTarget

    The target element to type at

  • text: SiestaTypeString

    The text to type.

  • timeout: number

    Maximum time for the target element to become actionable.

MouseActionOptions

MouseActionOptions: { allowChild: boolean; altKey: boolean; ctrlKey: boolean; metaKey: boolean; mouseMovePrecision: PointerMovePrecision; offset: ActionTargetOffset; shiftKey: boolean; target: ActionTarget; timeout: number }

The options for mouse action

Type declaration

  • allowChild: boolean

    When waiting for the target to become actionable, one of the checks that element needs to pass is "reachable". It defines that the action point should be directly reachable by the user (be the top-most and not covered with other elements). This setting defines whether to allow that point to be covered with child element of the target.

    Default is true.

  • altKey: boolean

    Set to true to simulate Alt keypress during the action

  • ctrlKey: boolean

    Set to true to simulate Ctrl keypress during the action

  • metaKey: boolean

    Set to true to simulate Meta keypress during the action.

  • mouseMovePrecision: PointerMovePrecision

    Mouse move precision to use, when moving the mouse cursor from its current location to the target point.

  • offset: ActionTargetOffset

    Offset for the action. If not provided, the action happens in the center of the visible part of the target element.

  • shiftKey: boolean

    Set to true to simulate Shift keypress during the action

  • target: ActionTarget

    The target of the action.

  • timeout: number

    The maximum time to wait for target to become actionable. By default its taken from the TestDescriptor.defaultTimeout

Point

Point: [x: number, y: number]

This type represent a 2-dimensional point, as a tuple (array with 2 elements)

PointerMovePrecision

PointerMovePrecision: number | { kind: "fixed"; precision: number } | { kind: "every_nth"; precision: number } | { kind: "first_and_last"; precision: number } | { kind: "last_only"; precision: number }

Union type, that describes the precision of the pointer movement. It defines how many mousemove/pointermove events will be fired for the mouse move actions. This also includes moving cursor the target point for other actions, like TestBrowser.click and similar.

The kind options are:

  • fixed - The fixed amount of mousemove events will be fired, divided equally along the path. For example, if precision is 3, 3 mouse move events will be fired - 1 at the beginning, 1 at the middle and 1 at the end of the path.
  • every_nth - Simulate a mousemove event every N-th point along the path. For example, if precision is 3 and the path is 10 pixels long, mousemove events will be simulated for 1st, 4th, 7th and 10th pixels. mousemove is always simulated for the last point.
  • first_and_last - Simulate a mousemove event for the precision number of points in the beginning and the end of path. For example, if precision is 2 and the path is 10 pixels long, mousemove events will be simulated for 1st, 2nd, 9th and 10th pixels.
  • last_only - Simulate a mousemove event for the precision number of points at the end of path. For example, if precision is 2 and the path is 10 pixels long, mousemove events will be simulated for 9th and 10th pixels.

The special case of number is equivalent to every_nth kind.

Having precise control over the mousemove simulation might be important for certain drag and drop implementations, which relies on at least 2 mousemove events fired on the drop target.

PreloadDescriptor

PreloadDescriptor: string | false | null | undefined | "" | {} | {} | {} | {} | {} | {} | {} | PreloadDescriptor[]

A preload descriptor describes what resources should be loaded into the test page, before starting the test. It can point to JavaScript or CSS resource, or can provide it inline.

Preload descriptor can be:

  • an object in the form { type : 'js', url : string, isEcmaModule? : boolean }, pointing to the JavaScript file. If the file contains Ecma module, the isEcmaModule flag should be set to true
  • an object in the form { type : 'js', content : string, isEcmaModule? : boolean }, providing the inline JavaScript content. If the content represents an Ecma module, the isEcmaModule flag should be set to true
  • an object in the form { type : 'css', url : string }, pointing to the CSS file.
  • an object in the form { type : 'css', content : string }, providing the inline CSS content.
  • a plain string, if it ends with .css it corresponds to { type : 'css', url : string }, otherwise it corresponds to { type : 'js', url : string, isEcmaModule : false }
  • an object in the form { code : string | Function }, which corresponds to { type : 'js', content : string, isEcmaModule : false }. If the code property is provided as a Function it will be stringified with .toString() call.
  • an object in the form { style : string }, which corresponds to { type : 'css', content : string }.
  • a "falsy" value, like null, undefined, empty string etc. It will be ignored
  • an array of preload descriptors - will be flattened.

The last 2 cases allows simple conditional preloading, for example:

preload         : [
'http://mydomain.com/file1.js'
{
code : 'MySpecialGlobalFunc = () => { if (typeof console != "undefined") ... }'
},
// simple conditional preload
someCondition ?
[
'http://mydomain.com/file2.css',
'http://mydomain.com/file3.js'
]
:
null
],

Generated using TypeDoc