🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More
Socket
Book a DemoSign in
Socket

@oracle/oraclejet-testing

Package Overview
Dependencies
Maintainers
42
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oracle/oraclejet-testing - npm Package Compare versions

Comparing version
18.1.5
to
19.0.0
+1
README.md
# oraclejet-testing
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var TestDriver = require('./TestDriver.cjs');
var timeouts = require('./timeouts.cjs');
var waitFor = require('./waitFor.cjs');
exports.Keys = TestDriver.Keys;
exports.TestDriverBase = TestDriver.TestDriverBase;
exports.getTestDriver = TestDriver.getTestDriver;
exports.setTestDriver = TestDriver.setTestDriver;
exports.unwrapElement = TestDriver.unwrapElement;
exports.getTimeouts = timeouts.getTimeouts;
exports.setTimeouts = timeouts.setTimeouts;
exports.waitFor = waitFor.waitFor;
//# sourceMappingURL=index.cjs.map
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
export * from './TestDriver';
export * from './timeouts';
export { waitFor } from './waitFor';
export { Keys, TestDriverBase, getTestDriver, setTestDriver, unwrapElement } from './TestDriver.mjs';
export { getTimeouts, setTimeouts } from './timeouts.mjs';
export { waitFor } from './waitFor.mjs';
//# sourceMappingURL=index.mjs.map
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var waitFor = require('./waitFor.cjs');
/**
* A base class for implementing the TestDriver interface. Platform-specific TestDrivers should
* extend this class to inherit behavior for waiting on conditions.
*/
class TestDriverBase {
/**
* Wait for a condition to pass.
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
* the callback. The truthy return value of the callback will be returned to the caller.
* @param options Options for wait time/interval
* @returns A Promise resolving to the returned value from the callback
*/
async waitFor(callback, options) {
return waitFor.waitFor_internal(callback, options);
}
}
const ModifierKeys = {
ALT: { key: 'ALT' },
CONTROL: { key: 'CONTROL' },
CONTROL_COMMAND: { key: 'CONTROL_COMMAND' },
SHIFT: { key: 'SHIFT' }
};
const Keys = {
...ModifierKeys,
BACKSPACE: { key: 'BACKSPACE' },
TAB: { key: 'TAB' },
ENTER: { key: 'ENTER' },
ESCAPE: { key: 'ESCAPE' },
PAGE_UP: { key: 'PAGE_UP' },
PAGE_DOWN: { key: 'PAGE_DOWN' },
END: { key: 'END' },
HOME: { key: 'HOME' },
ARROW_LEFT: { key: 'ARROW_LEFT' },
ARROW_UP: { key: 'ARROW_UP' },
ARROW_RIGHT: { key: 'ARROW_RIGHT' },
ARROW_DOWN: { key: 'ARROW_DOWN' },
DELETE: { key: 'DELETE' },
F1: { key: 'F1' },
F2: { key: 'F2' },
F3: { key: 'F3' },
F4: { key: 'F4' },
F5: { key: 'F5' },
F6: { key: 'F6' },
F7: { key: 'F7' },
F8: { key: 'F8' },
F9: { key: 'F9' },
F10: { key: 'F10' },
F11: { key: 'F11' },
F12: { key: 'F12' }
};
let _driver;
/**
* Set the TestDriver instance to be used for testing. This method should be called by
* tests during setup, before calling any test adapter methods.
*
* @param driver The TestDriver instance
*/
function setTestDriver(driver) {
_driver = driver;
}
/**
* Get the configured TestDriver instance to be used for testing. This method should
* only be called by test adapters to interact with the browser environment.
*
* @returns The TestDriver instance
*/
function getTestDriver() {
if (!_driver) {
throw Error('Driver has not been set. Call setTestDriver()');
}
return _driver;
}
/**
* Unwrap the given TestElement into its driver-specific element
* @param element
*/
function unwrapElement(element) {
return getTestDriver().unwrapElement(element);
}
exports.Keys = Keys;
exports.TestDriverBase = TestDriverBase;
exports.getTestDriver = getTestDriver;
exports.setTestDriver = setTestDriver;
exports.unwrapElement = unwrapElement;
//# sourceMappingURL=TestDriver.cjs.map
{"version":3,"file":"TestDriver.cjs","sources":["../../src/UNSAFE_Driver/TestDriver.ts"],"sourcesContent":["import { ElementLocator } from '../UNSAFE_Locators';\nimport { type WaitForOptions, waitFor_internal } from './waitFor';\n/**\n * A TestDriver implements the platform-specific commands needed for testing\n * with adapters.\n */\nexport interface TestDriver {\n /**\n * Click on the given TestElement\n * @param element The TestElement on which to click\n */\n click(element: TestElement, options?: ClickOptions): Promise<void>;\n /**\n * Execute a script in the browser environment.\n * Note that if passing a TestElement as an argument, you must first call {@link unwrapElement}\n * on it to pass the driver-specific element to the script.\n * @example\n * const testEl = await this.getElement();\n * await driver.executeScript<number>((el: HTMLElement) => el.clientHeight), unwrapElement(testEl));\n *\n * @param script The script to execute\n * @param args Any arguments to pass to the script. Access each argument through\n * the <code>arguments</code> array.\n */\n executeScript<T>(script: string | ((...args: any) => T), ...args: any): Promise<T>;\n /**\n * Find an element in the browser environment that matches the given ElementLocator.\n * If an element doesn't exist, this method will wait up to the timeout defined by\n * {@link getTimeouts().elementExistsTimeout}\n * This method throws an exception if no matching elements are found.\n * @param locator\n */\n waitForElement(locator: ElementLocator): Promise<TestElement>;\n /**\n * Find elements in the browser environment matching the given ElementLocator. If no\n * matching elements are found, return a blank array.\n * @param locator\n */\n waitForElements(locator: ElementLocator): Promise<TestElement[]>;\n /**\n * Send text as keystrokes to the browser. If modifier keys are used, all key parameters in the\n * sequence will be combined into a single chord.\n * @param element The element to receive the keystrokes\n * @param text The text value to send, or an array of KeyMap strings to send as a chord of keys\n */\n sendKeys(element: TestElement, ...text: (string | KeyType)[]): Promise<void>;\n /**\n * Unwrap the given TestElement into its driver-specific element\n * @param element\n */\n unwrapElement<T>(element: TestElement): T;\n}\n\n/**\n * A base class for implementing the TestDriver interface. Platform-specific TestDrivers should\n * extend this class to inherit behavior for waiting on conditions.\n */\nexport abstract class TestDriverBase implements TestDriver {\n /**\n * Wait for a condition to pass.\n * @param callback The function to run. Return truthy to stop the wait; anything else will retry\n * the callback. The truthy return value of the callback will be returned to the caller.\n * @param options Options for wait time/interval\n * @returns A Promise resolving to the returned value from the callback\n */\n async waitFor<T>(callback: () => T | Promise<T>, options?: WaitForOptions) {\n return waitFor_internal(callback, options);\n }\n abstract click(element: TestElement, options?: ClickOptions): Promise<void>;\n abstract executeScript<T>(script: string | ((...args: any) => T), ...args: any): Promise<T>;\n abstract waitForElement(locator: ElementLocator): Promise<TestElement>;\n abstract waitForElements(locator: ElementLocator): Promise<TestElement[]>;\n abstract sendKeys(element: TestElement, ...text: (string | KeyType)[]): Promise<void>;\n abstract unwrapElement<T>(element: TestElement): T;\n}\n\n/**\n * A TestElement represents the DOM element in the browser environment. This interface\n * is used by test adapters to work with elements without being bound to a specific\n * platform implementation.\n */\nexport interface TestElement {\n /**\n * Find an element in the browser environment that matches the given ElementLocator.\n * This method should throw an exception if no matching elements are found.\n * @param locator\n */\n waitForElement(locator: ElementLocator): Promise<TestElement>;\n /**\n * Find elements in the browser environment matching the given ElementLocator. If no\n * matching elements are found, return a blank array.\n * @param locator\n */\n waitForElements(locator: ElementLocator): Promise<TestElement[]>;\n /**\n * Get the element's attribute value from the given attrName.\n * @param attrName\n */\n getAttribute(attrName: string): Promise<string | null>;\n}\n\nconst ModifierKeys = {\n ALT: { key: 'ALT' },\n CONTROL: { key: 'CONTROL' },\n CONTROL_COMMAND: { key: 'CONTROL_COMMAND' },\n SHIFT: { key: 'SHIFT' }\n} as const;\n\nexport type ClickOptions = {\n modifiers?: (typeof ModifierKeys)[keyof typeof ModifierKeys][];\n};\n\nexport const Keys = {\n ...ModifierKeys,\n BACKSPACE: { key: 'BACKSPACE' },\n TAB: { key: 'TAB' },\n ENTER: { key: 'ENTER' },\n ESCAPE: { key: 'ESCAPE' },\n PAGE_UP: { key: 'PAGE_UP' },\n PAGE_DOWN: { key: 'PAGE_DOWN' },\n END: { key: 'END' },\n HOME: { key: 'HOME' },\n ARROW_LEFT: { key: 'ARROW_LEFT' },\n ARROW_UP: { key: 'ARROW_UP' },\n ARROW_RIGHT: { key: 'ARROW_RIGHT' },\n ARROW_DOWN: { key: 'ARROW_DOWN' },\n DELETE: { key: 'DELETE' },\n\n F1: { key: 'F1' },\n F2: { key: 'F2' },\n F3: { key: 'F3' },\n F4: { key: 'F4' },\n F5: { key: 'F5' },\n F6: { key: 'F6' },\n F7: { key: 'F7' },\n F8: { key: 'F8' },\n F9: { key: 'F9' },\n F10: { key: 'F10' },\n F11: { key: 'F11' },\n F12: { key: 'F12' }\n} as const;\n\ntype KeysType = Record<keyof typeof Keys, { key: string }>;\nexport type KeyType = KeysType[keyof KeysType];\n\nlet _driver: TestDriver;\n\n/**\n * Set the TestDriver instance to be used for testing. This method should be called by\n * tests during setup, before calling any test adapter methods.\n *\n * @param driver The TestDriver instance\n */\nexport function setTestDriver(driver: TestDriver) {\n _driver = driver;\n}\n\n/**\n * Get the configured TestDriver instance to be used for testing. This method should\n * only be called by test adapters to interact with the browser environment.\n *\n * @returns The TestDriver instance\n */\nexport function getTestDriver() {\n if (!_driver) {\n throw Error('Driver has not been set. Call setTestDriver()');\n }\n return _driver;\n}\n\n/**\n * Unwrap the given TestElement into its driver-specific element\n * @param element\n */\nexport function unwrapElement(element: TestElement) {\n return getTestDriver().unwrapElement(element);\n}\n"],"names":["waitFor_internal"],"mappings":";;;;;;AAqDA;;;AAGG;MACmB,cAAc,CAAA;AAClC;;;;;;AAMG;AACH,IAAA,MAAM,OAAO,CAAI,QAA8B,EAAE,OAAwB,EAAA;AACvE,QAAA,OAAOA,wBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;KAC5C;AAOF,CAAA;AA2BD,MAAM,YAAY,GAAG;AACnB,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,OAAO,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE;AAC3B,IAAA,eAAe,EAAE,EAAE,GAAG,EAAE,iBAAiB,EAAE;AAC3C,IAAA,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;CACf,CAAC;AAME,MAAA,IAAI,GAAG;AAClB,IAAA,GAAG,YAAY;AACf,IAAA,SAAS,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE;AAC/B,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;AACvB,IAAA,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;AACzB,IAAA,OAAO,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE;AAC3B,IAAA,SAAS,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE;AAC/B,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE;AACrB,IAAA,UAAU,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE;AACjC,IAAA,QAAQ,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE;AAC7B,IAAA,WAAW,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE;AACnC,IAAA,UAAU,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE;AACjC,IAAA,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;AAEzB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;EACV;AAKX,IAAI,OAAmB,CAAC;AAExB;;;;;AAKG;AACG,SAAU,aAAa,CAAC,MAAkB,EAAA;IAC9C,OAAO,GAAG,MAAM,CAAC;AACnB,CAAC;AAED;;;;;AAKG;SACa,aAAa,GAAA;IAC3B,IAAI,CAAC,OAAO,EAAE;AACZ,QAAA,MAAM,KAAK,CAAC,+CAA+C,CAAC,CAAC;KAC9D;AACD,IAAA,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;AAGG;AACG,SAAU,aAAa,CAAC,OAAoB,EAAA;AAChD,IAAA,OAAO,aAAa,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAChD;;;;;;;;"}
import { ElementLocator } from '../UNSAFE_Locators';
import { type WaitForOptions } from './waitFor';
/**
* A TestDriver implements the platform-specific commands needed for testing
* with adapters.
*/
export interface TestDriver {
/**
* Click on the given TestElement
* @param element The TestElement on which to click
*/
click(element: TestElement, options?: ClickOptions): Promise<void>;
/**
* Execute a script in the browser environment.
* Note that if passing a TestElement as an argument, you must first call {@link unwrapElement}
* on it to pass the driver-specific element to the script.
* @example
* const testEl = await this.getElement();
* await driver.executeScript<number>((el: HTMLElement) => el.clientHeight), unwrapElement(testEl));
*
* @param script The script to execute
* @param args Any arguments to pass to the script. Access each argument through
* the <code>arguments</code> array.
*/
executeScript<T>(script: string | ((...args: any) => T), ...args: any): Promise<T>;
/**
* Find an element in the browser environment that matches the given ElementLocator.
* If an element doesn't exist, this method will wait up to the timeout defined by
* {@link getTimeouts().elementExistsTimeout}
* This method throws an exception if no matching elements are found.
* @param locator
*/
waitForElement(locator: ElementLocator): Promise<TestElement>;
/**
* Find elements in the browser environment matching the given ElementLocator. If no
* matching elements are found, return a blank array.
* @param locator
*/
waitForElements(locator: ElementLocator): Promise<TestElement[]>;
/**
* Send text as keystrokes to the browser. If modifier keys are used, all key parameters in the
* sequence will be combined into a single chord.
* @param element The element to receive the keystrokes
* @param text The text value to send, or an array of KeyMap strings to send as a chord of keys
*/
sendKeys(element: TestElement, ...text: (string | KeyType)[]): Promise<void>;
/**
* Unwrap the given TestElement into its driver-specific element
* @param element
*/
unwrapElement<T>(element: TestElement): T;
}
/**
* A base class for implementing the TestDriver interface. Platform-specific TestDrivers should
* extend this class to inherit behavior for waiting on conditions.
*/
export declare abstract class TestDriverBase implements TestDriver {
/**
* Wait for a condition to pass.
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
* the callback. The truthy return value of the callback will be returned to the caller.
* @param options Options for wait time/interval
* @returns A Promise resolving to the returned value from the callback
*/
waitFor<T>(callback: () => T | Promise<T>, options?: WaitForOptions): Promise<T>;
abstract click(element: TestElement, options?: ClickOptions): Promise<void>;
abstract executeScript<T>(script: string | ((...args: any) => T), ...args: any): Promise<T>;
abstract waitForElement(locator: ElementLocator): Promise<TestElement>;
abstract waitForElements(locator: ElementLocator): Promise<TestElement[]>;
abstract sendKeys(element: TestElement, ...text: (string | KeyType)[]): Promise<void>;
abstract unwrapElement<T>(element: TestElement): T;
}
/**
* A TestElement represents the DOM element in the browser environment. This interface
* is used by test adapters to work with elements without being bound to a specific
* platform implementation.
*/
export interface TestElement {
/**
* Find an element in the browser environment that matches the given ElementLocator.
* This method should throw an exception if no matching elements are found.
* @param locator
*/
waitForElement(locator: ElementLocator): Promise<TestElement>;
/**
* Find elements in the browser environment matching the given ElementLocator. If no
* matching elements are found, return a blank array.
* @param locator
*/
waitForElements(locator: ElementLocator): Promise<TestElement[]>;
/**
* Get the element's attribute value from the given attrName.
* @param attrName
*/
getAttribute(attrName: string): Promise<string | null>;
}
declare const ModifierKeys: {
readonly ALT: {
readonly key: "ALT";
};
readonly CONTROL: {
readonly key: "CONTROL";
};
readonly CONTROL_COMMAND: {
readonly key: "CONTROL_COMMAND";
};
readonly SHIFT: {
readonly key: "SHIFT";
};
};
export type ClickOptions = {
modifiers?: (typeof ModifierKeys)[keyof typeof ModifierKeys][];
};
export declare const Keys: {
readonly BACKSPACE: {
readonly key: "BACKSPACE";
};
readonly TAB: {
readonly key: "TAB";
};
readonly ENTER: {
readonly key: "ENTER";
};
readonly ESCAPE: {
readonly key: "ESCAPE";
};
readonly PAGE_UP: {
readonly key: "PAGE_UP";
};
readonly PAGE_DOWN: {
readonly key: "PAGE_DOWN";
};
readonly END: {
readonly key: "END";
};
readonly HOME: {
readonly key: "HOME";
};
readonly ARROW_LEFT: {
readonly key: "ARROW_LEFT";
};
readonly ARROW_UP: {
readonly key: "ARROW_UP";
};
readonly ARROW_RIGHT: {
readonly key: "ARROW_RIGHT";
};
readonly ARROW_DOWN: {
readonly key: "ARROW_DOWN";
};
readonly DELETE: {
readonly key: "DELETE";
};
readonly F1: {
readonly key: "F1";
};
readonly F2: {
readonly key: "F2";
};
readonly F3: {
readonly key: "F3";
};
readonly F4: {
readonly key: "F4";
};
readonly F5: {
readonly key: "F5";
};
readonly F6: {
readonly key: "F6";
};
readonly F7: {
readonly key: "F7";
};
readonly F8: {
readonly key: "F8";
};
readonly F9: {
readonly key: "F9";
};
readonly F10: {
readonly key: "F10";
};
readonly F11: {
readonly key: "F11";
};
readonly F12: {
readonly key: "F12";
};
readonly ALT: {
readonly key: "ALT";
};
readonly CONTROL: {
readonly key: "CONTROL";
};
readonly CONTROL_COMMAND: {
readonly key: "CONTROL_COMMAND";
};
readonly SHIFT: {
readonly key: "SHIFT";
};
};
type KeysType = Record<keyof typeof Keys, {
key: string;
}>;
export type KeyType = KeysType[keyof KeysType];
/**
* Set the TestDriver instance to be used for testing. This method should be called by
* tests during setup, before calling any test adapter methods.
*
* @param driver The TestDriver instance
*/
export declare function setTestDriver(driver: TestDriver): void;
/**
* Get the configured TestDriver instance to be used for testing. This method should
* only be called by test adapters to interact with the browser environment.
*
* @returns The TestDriver instance
*/
export declare function getTestDriver(): TestDriver;
/**
* Unwrap the given TestElement into its driver-specific element
* @param element
*/
export declare function unwrapElement(element: TestElement): unknown;
export {};
import { waitFor_internal } from './waitFor.mjs';
/**
* A base class for implementing the TestDriver interface. Platform-specific TestDrivers should
* extend this class to inherit behavior for waiting on conditions.
*/
class TestDriverBase {
/**
* Wait for a condition to pass.
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
* the callback. The truthy return value of the callback will be returned to the caller.
* @param options Options for wait time/interval
* @returns A Promise resolving to the returned value from the callback
*/
async waitFor(callback, options) {
return waitFor_internal(callback, options);
}
}
const ModifierKeys = {
ALT: { key: 'ALT' },
CONTROL: { key: 'CONTROL' },
CONTROL_COMMAND: { key: 'CONTROL_COMMAND' },
SHIFT: { key: 'SHIFT' }
};
const Keys = {
...ModifierKeys,
BACKSPACE: { key: 'BACKSPACE' },
TAB: { key: 'TAB' },
ENTER: { key: 'ENTER' },
ESCAPE: { key: 'ESCAPE' },
PAGE_UP: { key: 'PAGE_UP' },
PAGE_DOWN: { key: 'PAGE_DOWN' },
END: { key: 'END' },
HOME: { key: 'HOME' },
ARROW_LEFT: { key: 'ARROW_LEFT' },
ARROW_UP: { key: 'ARROW_UP' },
ARROW_RIGHT: { key: 'ARROW_RIGHT' },
ARROW_DOWN: { key: 'ARROW_DOWN' },
DELETE: { key: 'DELETE' },
F1: { key: 'F1' },
F2: { key: 'F2' },
F3: { key: 'F3' },
F4: { key: 'F4' },
F5: { key: 'F5' },
F6: { key: 'F6' },
F7: { key: 'F7' },
F8: { key: 'F8' },
F9: { key: 'F9' },
F10: { key: 'F10' },
F11: { key: 'F11' },
F12: { key: 'F12' }
};
let _driver;
/**
* Set the TestDriver instance to be used for testing. This method should be called by
* tests during setup, before calling any test adapter methods.
*
* @param driver The TestDriver instance
*/
function setTestDriver(driver) {
_driver = driver;
}
/**
* Get the configured TestDriver instance to be used for testing. This method should
* only be called by test adapters to interact with the browser environment.
*
* @returns The TestDriver instance
*/
function getTestDriver() {
if (!_driver) {
throw Error('Driver has not been set. Call setTestDriver()');
}
return _driver;
}
/**
* Unwrap the given TestElement into its driver-specific element
* @param element
*/
function unwrapElement(element) {
return getTestDriver().unwrapElement(element);
}
export { Keys, TestDriverBase, getTestDriver, setTestDriver, unwrapElement };
//# sourceMappingURL=TestDriver.mjs.map
{"version":3,"file":"TestDriver.mjs","sources":["../../src/UNSAFE_Driver/TestDriver.ts"],"sourcesContent":["import { ElementLocator } from '../UNSAFE_Locators';\nimport { type WaitForOptions, waitFor_internal } from './waitFor';\n/**\n * A TestDriver implements the platform-specific commands needed for testing\n * with adapters.\n */\nexport interface TestDriver {\n /**\n * Click on the given TestElement\n * @param element The TestElement on which to click\n */\n click(element: TestElement, options?: ClickOptions): Promise<void>;\n /**\n * Execute a script in the browser environment.\n * Note that if passing a TestElement as an argument, you must first call {@link unwrapElement}\n * on it to pass the driver-specific element to the script.\n * @example\n * const testEl = await this.getElement();\n * await driver.executeScript<number>((el: HTMLElement) => el.clientHeight), unwrapElement(testEl));\n *\n * @param script The script to execute\n * @param args Any arguments to pass to the script. Access each argument through\n * the <code>arguments</code> array.\n */\n executeScript<T>(script: string | ((...args: any) => T), ...args: any): Promise<T>;\n /**\n * Find an element in the browser environment that matches the given ElementLocator.\n * If an element doesn't exist, this method will wait up to the timeout defined by\n * {@link getTimeouts().elementExistsTimeout}\n * This method throws an exception if no matching elements are found.\n * @param locator\n */\n waitForElement(locator: ElementLocator): Promise<TestElement>;\n /**\n * Find elements in the browser environment matching the given ElementLocator. If no\n * matching elements are found, return a blank array.\n * @param locator\n */\n waitForElements(locator: ElementLocator): Promise<TestElement[]>;\n /**\n * Send text as keystrokes to the browser. If modifier keys are used, all key parameters in the\n * sequence will be combined into a single chord.\n * @param element The element to receive the keystrokes\n * @param text The text value to send, or an array of KeyMap strings to send as a chord of keys\n */\n sendKeys(element: TestElement, ...text: (string | KeyType)[]): Promise<void>;\n /**\n * Unwrap the given TestElement into its driver-specific element\n * @param element\n */\n unwrapElement<T>(element: TestElement): T;\n}\n\n/**\n * A base class for implementing the TestDriver interface. Platform-specific TestDrivers should\n * extend this class to inherit behavior for waiting on conditions.\n */\nexport abstract class TestDriverBase implements TestDriver {\n /**\n * Wait for a condition to pass.\n * @param callback The function to run. Return truthy to stop the wait; anything else will retry\n * the callback. The truthy return value of the callback will be returned to the caller.\n * @param options Options for wait time/interval\n * @returns A Promise resolving to the returned value from the callback\n */\n async waitFor<T>(callback: () => T | Promise<T>, options?: WaitForOptions) {\n return waitFor_internal(callback, options);\n }\n abstract click(element: TestElement, options?: ClickOptions): Promise<void>;\n abstract executeScript<T>(script: string | ((...args: any) => T), ...args: any): Promise<T>;\n abstract waitForElement(locator: ElementLocator): Promise<TestElement>;\n abstract waitForElements(locator: ElementLocator): Promise<TestElement[]>;\n abstract sendKeys(element: TestElement, ...text: (string | KeyType)[]): Promise<void>;\n abstract unwrapElement<T>(element: TestElement): T;\n}\n\n/**\n * A TestElement represents the DOM element in the browser environment. This interface\n * is used by test adapters to work with elements without being bound to a specific\n * platform implementation.\n */\nexport interface TestElement {\n /**\n * Find an element in the browser environment that matches the given ElementLocator.\n * This method should throw an exception if no matching elements are found.\n * @param locator\n */\n waitForElement(locator: ElementLocator): Promise<TestElement>;\n /**\n * Find elements in the browser environment matching the given ElementLocator. If no\n * matching elements are found, return a blank array.\n * @param locator\n */\n waitForElements(locator: ElementLocator): Promise<TestElement[]>;\n /**\n * Get the element's attribute value from the given attrName.\n * @param attrName\n */\n getAttribute(attrName: string): Promise<string | null>;\n}\n\nconst ModifierKeys = {\n ALT: { key: 'ALT' },\n CONTROL: { key: 'CONTROL' },\n CONTROL_COMMAND: { key: 'CONTROL_COMMAND' },\n SHIFT: { key: 'SHIFT' }\n} as const;\n\nexport type ClickOptions = {\n modifiers?: (typeof ModifierKeys)[keyof typeof ModifierKeys][];\n};\n\nexport const Keys = {\n ...ModifierKeys,\n BACKSPACE: { key: 'BACKSPACE' },\n TAB: { key: 'TAB' },\n ENTER: { key: 'ENTER' },\n ESCAPE: { key: 'ESCAPE' },\n PAGE_UP: { key: 'PAGE_UP' },\n PAGE_DOWN: { key: 'PAGE_DOWN' },\n END: { key: 'END' },\n HOME: { key: 'HOME' },\n ARROW_LEFT: { key: 'ARROW_LEFT' },\n ARROW_UP: { key: 'ARROW_UP' },\n ARROW_RIGHT: { key: 'ARROW_RIGHT' },\n ARROW_DOWN: { key: 'ARROW_DOWN' },\n DELETE: { key: 'DELETE' },\n\n F1: { key: 'F1' },\n F2: { key: 'F2' },\n F3: { key: 'F3' },\n F4: { key: 'F4' },\n F5: { key: 'F5' },\n F6: { key: 'F6' },\n F7: { key: 'F7' },\n F8: { key: 'F8' },\n F9: { key: 'F9' },\n F10: { key: 'F10' },\n F11: { key: 'F11' },\n F12: { key: 'F12' }\n} as const;\n\ntype KeysType = Record<keyof typeof Keys, { key: string }>;\nexport type KeyType = KeysType[keyof KeysType];\n\nlet _driver: TestDriver;\n\n/**\n * Set the TestDriver instance to be used for testing. This method should be called by\n * tests during setup, before calling any test adapter methods.\n *\n * @param driver The TestDriver instance\n */\nexport function setTestDriver(driver: TestDriver) {\n _driver = driver;\n}\n\n/**\n * Get the configured TestDriver instance to be used for testing. This method should\n * only be called by test adapters to interact with the browser environment.\n *\n * @returns The TestDriver instance\n */\nexport function getTestDriver() {\n if (!_driver) {\n throw Error('Driver has not been set. Call setTestDriver()');\n }\n return _driver;\n}\n\n/**\n * Unwrap the given TestElement into its driver-specific element\n * @param element\n */\nexport function unwrapElement(element: TestElement) {\n return getTestDriver().unwrapElement(element);\n}\n"],"names":[],"mappings":";;AAqDA;;;AAGG;MACmB,cAAc,CAAA;AAClC;;;;;;AAMG;AACH,IAAA,MAAM,OAAO,CAAI,QAA8B,EAAE,OAAwB,EAAA;AACvE,QAAA,OAAO,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;KAC5C;AAOF,CAAA;AA2BD,MAAM,YAAY,GAAG;AACnB,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,OAAO,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE;AAC3B,IAAA,eAAe,EAAE,EAAE,GAAG,EAAE,iBAAiB,EAAE;AAC3C,IAAA,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;CACf,CAAC;AAME,MAAA,IAAI,GAAG;AAClB,IAAA,GAAG,YAAY;AACf,IAAA,SAAS,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE;AAC/B,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,KAAK,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE;AACvB,IAAA,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;AACzB,IAAA,OAAO,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE;AAC3B,IAAA,SAAS,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE;AAC/B,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,IAAI,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE;AACrB,IAAA,UAAU,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE;AACjC,IAAA,QAAQ,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE;AAC7B,IAAA,WAAW,EAAE,EAAE,GAAG,EAAE,aAAa,EAAE;AACnC,IAAA,UAAU,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE;AACjC,IAAA,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;AAEzB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE;AACjB,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;AACnB,IAAA,GAAG,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE;EACV;AAKX,IAAI,OAAmB,CAAC;AAExB;;;;;AAKG;AACG,SAAU,aAAa,CAAC,MAAkB,EAAA;IAC9C,OAAO,GAAG,MAAM,CAAC;AACnB,CAAC;AAED;;;;;AAKG;SACa,aAAa,GAAA;IAC3B,IAAI,CAAC,OAAO,EAAE;AACZ,QAAA,MAAM,KAAK,CAAC,+CAA+C,CAAC,CAAC;KAC9D;AACD,IAAA,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;AAGG;AACG,SAAU,aAAa,CAAC,OAAoB,EAAA;AAChD,IAAA,OAAO,aAAa,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;AAChD;;;;"}
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
const _timeouts = {
/**
* The window of time to wait for an element to exist in the DOM.
* Set to 0 to wait indefinitely.
* Defaults to 1000
*/
elementExistsTimeout: 1000,
/**
* The window of time to wait for a remote script to complete execution.
* Set to 0 to wait indefinitely.
* Defaults to 30000
*/
scriptTimeout: 30 * 1000,
/**
* The window of time with which the waitFor() function will retry the callback.
* Set to 0 to wait indefinitely.
* Defaults to 30000
*/
waitForTimeout: 30 * 1000,
/**
* The delay between polling calls that waitFor() will wait before retrying the callback.
* Defaults to 100
*/
pollingInterval: 100
};
/**
* Set the default timeouts for the TestDriver in milliseconds.
* Every property is optional, and can be partially set.
* @param timeouts
*/
function setTimeouts(timeouts) {
Object.assign(_timeouts, timeouts);
}
/**
* Get the default timeouts set for the TestDriver
* @returns
*/
function getTimeouts() {
return { ..._timeouts };
}
exports.getTimeouts = getTimeouts;
exports.setTimeouts = setTimeouts;
//# sourceMappingURL=timeouts.cjs.map
{"version":3,"file":"timeouts.cjs","sources":["../../src/UNSAFE_Driver/timeouts.ts"],"sourcesContent":["const _timeouts = {\n /**\n * The window of time to wait for an element to exist in the DOM.\n * Set to 0 to wait indefinitely.\n * Defaults to 1000\n */\n elementExistsTimeout: 1000,\n /**\n * The window of time to wait for a remote script to complete execution.\n * Set to 0 to wait indefinitely.\n * Defaults to 30000\n */\n scriptTimeout: 30 * 1000,\n /**\n * The window of time with which the waitFor() function will retry the callback.\n * Set to 0 to wait indefinitely.\n * Defaults to 30000\n */\n waitForTimeout: 30 * 1000,\n /**\n * The delay between polling calls that waitFor() will wait before retrying the callback.\n * Defaults to 100\n */\n pollingInterval: 100\n};\n\nexport type TimeoutsType = typeof _timeouts;\n\n/**\n * Set the default timeouts for the TestDriver in milliseconds.\n * Every property is optional, and can be partially set.\n * @param timeouts\n */\nexport function setTimeouts(timeouts: Partial<TimeoutsType>) {\n Object.assign(_timeouts, timeouts);\n}\n\n/**\n * Get the default timeouts set for the TestDriver\n * @returns\n */\nexport function getTimeouts() {\n return { ..._timeouts };\n}\n"],"names":[],"mappings":";;;;AAAA,MAAM,SAAS,GAAG;AAChB;;;;AAIG;AACH,IAAA,oBAAoB,EAAE,IAAI;AAC1B;;;;AAIG;IACH,aAAa,EAAE,EAAE,GAAG,IAAI;AACxB;;;;AAIG;IACH,cAAc,EAAE,EAAE,GAAG,IAAI;AACzB;;;AAGG;AACH,IAAA,eAAe,EAAE,GAAG;CACrB,CAAC;AAIF;;;;AAIG;AACG,SAAU,WAAW,CAAC,QAA+B,EAAA;AACzD,IAAA,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC;AAED;;;AAGG;SACa,WAAW,GAAA;AACzB,IAAA,OAAO,EAAE,GAAG,SAAS,EAAE,CAAC;AAC1B;;;;;"}
declare const _timeouts: {
/**
* The window of time to wait for an element to exist in the DOM.
* Set to 0 to wait indefinitely.
* Defaults to 1000
*/
elementExistsTimeout: number;
/**
* The window of time to wait for a remote script to complete execution.
* Set to 0 to wait indefinitely.
* Defaults to 30000
*/
scriptTimeout: number;
/**
* The window of time with which the waitFor() function will retry the callback.
* Set to 0 to wait indefinitely.
* Defaults to 30000
*/
waitForTimeout: number;
/**
* The delay between polling calls that waitFor() will wait before retrying the callback.
* Defaults to 100
*/
pollingInterval: number;
};
export type TimeoutsType = typeof _timeouts;
/**
* Set the default timeouts for the TestDriver in milliseconds.
* Every property is optional, and can be partially set.
* @param timeouts
*/
export declare function setTimeouts(timeouts: Partial<TimeoutsType>): void;
/**
* Get the default timeouts set for the TestDriver
* @returns
*/
export declare function getTimeouts(): {
/**
* The window of time to wait for an element to exist in the DOM.
* Set to 0 to wait indefinitely.
* Defaults to 1000
*/
elementExistsTimeout: number;
/**
* The window of time to wait for a remote script to complete execution.
* Set to 0 to wait indefinitely.
* Defaults to 30000
*/
scriptTimeout: number;
/**
* The window of time with which the waitFor() function will retry the callback.
* Set to 0 to wait indefinitely.
* Defaults to 30000
*/
waitForTimeout: number;
/**
* The delay between polling calls that waitFor() will wait before retrying the callback.
* Defaults to 100
*/
pollingInterval: number;
};
export {};
const _timeouts = {
/**
* The window of time to wait for an element to exist in the DOM.
* Set to 0 to wait indefinitely.
* Defaults to 1000
*/
elementExistsTimeout: 1000,
/**
* The window of time to wait for a remote script to complete execution.
* Set to 0 to wait indefinitely.
* Defaults to 30000
*/
scriptTimeout: 30 * 1000,
/**
* The window of time with which the waitFor() function will retry the callback.
* Set to 0 to wait indefinitely.
* Defaults to 30000
*/
waitForTimeout: 30 * 1000,
/**
* The delay between polling calls that waitFor() will wait before retrying the callback.
* Defaults to 100
*/
pollingInterval: 100
};
/**
* Set the default timeouts for the TestDriver in milliseconds.
* Every property is optional, and can be partially set.
* @param timeouts
*/
function setTimeouts(timeouts) {
Object.assign(_timeouts, timeouts);
}
/**
* Get the default timeouts set for the TestDriver
* @returns
*/
function getTimeouts() {
return { ..._timeouts };
}
export { getTimeouts, setTimeouts };
//# sourceMappingURL=timeouts.mjs.map
{"version":3,"file":"timeouts.mjs","sources":["../../src/UNSAFE_Driver/timeouts.ts"],"sourcesContent":["const _timeouts = {\n /**\n * The window of time to wait for an element to exist in the DOM.\n * Set to 0 to wait indefinitely.\n * Defaults to 1000\n */\n elementExistsTimeout: 1000,\n /**\n * The window of time to wait for a remote script to complete execution.\n * Set to 0 to wait indefinitely.\n * Defaults to 30000\n */\n scriptTimeout: 30 * 1000,\n /**\n * The window of time with which the waitFor() function will retry the callback.\n * Set to 0 to wait indefinitely.\n * Defaults to 30000\n */\n waitForTimeout: 30 * 1000,\n /**\n * The delay between polling calls that waitFor() will wait before retrying the callback.\n * Defaults to 100\n */\n pollingInterval: 100\n};\n\nexport type TimeoutsType = typeof _timeouts;\n\n/**\n * Set the default timeouts for the TestDriver in milliseconds.\n * Every property is optional, and can be partially set.\n * @param timeouts\n */\nexport function setTimeouts(timeouts: Partial<TimeoutsType>) {\n Object.assign(_timeouts, timeouts);\n}\n\n/**\n * Get the default timeouts set for the TestDriver\n * @returns\n */\nexport function getTimeouts() {\n return { ..._timeouts };\n}\n"],"names":[],"mappings":"AAAA,MAAM,SAAS,GAAG;AAChB;;;;AAIG;AACH,IAAA,oBAAoB,EAAE,IAAI;AAC1B;;;;AAIG;IACH,aAAa,EAAE,EAAE,GAAG,IAAI;AACxB;;;;AAIG;IACH,cAAc,EAAE,EAAE,GAAG,IAAI;AACzB;;;AAGG;AACH,IAAA,eAAe,EAAE,GAAG;CACrB,CAAC;AAIF;;;;AAIG;AACG,SAAU,WAAW,CAAC,QAA+B,EAAA;AACzD,IAAA,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC;AAED;;;AAGG;SACa,WAAW,GAAA;AACzB,IAAA,OAAO,EAAE,GAAG,SAAS,EAAE,CAAC;AAC1B;;;;"}
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var timeouts = require('./timeouts.cjs');
/**
* Wait for a condition to pass.
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
* the callback. The truthy return value of the callback will be returned to the caller.
* @returns A Promise resolving to the returned value from the callback
*/
async function waitFor(callback) {
const { pollingInterval, waitForTimeout } = timeouts.getTimeouts();
return waitFor_internal(callback, { timeout: waitForTimeout, interval: pollingInterval });
}
/**
* Wait for a condition to pass.
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
* the callback. The truthy return value of the callback will be returned to the caller.
* @param options Options for wait time/interval
* @returns A Promise resolving to the returned value from the callback
*/
async function waitFor_internal(callback, options) {
const { waitForTimeout, pollingInterval } = timeouts.getTimeouts();
const timeout = options?.timeout ?? waitForTimeout;
const interval = options?.interval ?? pollingInterval;
const start = performance.now();
async function testCallback() {
try {
const result = await callback();
if (result) {
return result;
}
return retry();
}
catch {
return retry();
}
}
function retry() {
const now = performance.now();
const elapsed = Math.round(now - start);
if (timeout && elapsed > timeout) {
return Promise.reject(new WaitForTimeoutError(elapsed));
}
return new Promise((accept, reject) => setTimeout(() => testCallback().then(accept).catch(reject), interval));
}
return testCallback();
}
class WaitForTimeoutError extends Error {
constructor(elapsed) {
super(`timed out after ${elapsed}ms`);
this.name = 'WaitForTimeoutError';
}
}
exports.waitFor = waitFor;
exports.waitFor_internal = waitFor_internal;
//# sourceMappingURL=waitFor.cjs.map
{"version":3,"file":"waitFor.cjs","sources":["../../src/UNSAFE_Driver/waitFor.ts"],"sourcesContent":["import { getTimeouts } from './timeouts';\n\nexport type WaitForOptions = {\n timeout?: number;\n interval?: number;\n};\n\n/**\n * Wait for a condition to pass.\n * @param callback The function to run. Return truthy to stop the wait; anything else will retry\n * the callback. The truthy return value of the callback will be returned to the caller.\n * @returns A Promise resolving to the returned value from the callback\n */\nexport async function waitFor<T>(callback: () => T | Promise<T>) {\n const { pollingInterval, waitForTimeout } = getTimeouts();\n return waitFor_internal(callback, { timeout: waitForTimeout, interval: pollingInterval });\n}\n\n/**\n * Wait for a condition to pass.\n * @param callback The function to run. Return truthy to stop the wait; anything else will retry\n * the callback. The truthy return value of the callback will be returned to the caller.\n * @param options Options for wait time/interval\n * @returns A Promise resolving to the returned value from the callback\n */\nexport async function waitFor_internal<T>(\n callback: () => T | Promise<T>,\n options?: WaitForOptions\n) {\n const { waitForTimeout, pollingInterval } = getTimeouts();\n const timeout = options?.timeout ?? waitForTimeout;\n const interval = options?.interval ?? pollingInterval;\n const start = performance.now();\n async function testCallback() {\n try {\n const result = await callback();\n if (result) {\n return result;\n }\n return retry();\n } catch {\n return retry();\n }\n }\n function retry(): T | Promise<T> {\n const now = performance.now();\n const elapsed = Math.round(now - start);\n if (timeout && elapsed > timeout) {\n return Promise.reject(new WaitForTimeoutError(elapsed));\n }\n return new Promise((accept, reject) =>\n setTimeout(() => testCallback().then(accept).catch(reject), interval)\n );\n }\n return testCallback();\n}\n\nclass WaitForTimeoutError extends Error {\n constructor(elapsed: number) {\n super(`timed out after ${elapsed}ms`);\n this.name = 'WaitForTimeoutError';\n }\n}\n"],"names":["getTimeouts"],"mappings":";;;;;;AAOA;;;;;AAKG;AACI,eAAe,OAAO,CAAI,QAA8B,EAAA;IAC7D,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,GAAGA,oBAAW,EAAE,CAAC;AAC1D,IAAA,OAAO,gBAAgB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,CAAC;AAC5F,CAAC;AAED;;;;;;AAMG;AACI,eAAe,gBAAgB,CACpC,QAA8B,EAC9B,OAAwB,EAAA;IAExB,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,GAAGA,oBAAW,EAAE,CAAC;AAC1D,IAAA,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,cAAc,CAAC;AACnD,IAAA,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,eAAe,CAAC;AACtD,IAAA,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;AAChC,IAAA,eAAe,YAAY,GAAA;AACzB,QAAA,IAAI;AACF,YAAA,MAAM,MAAM,GAAG,MAAM,QAAQ,EAAE,CAAC;YAChC,IAAI,MAAM,EAAE;AACV,gBAAA,OAAO,MAAM,CAAC;aACf;YACD,OAAO,KAAK,EAAE,CAAC;SAChB;AAAC,QAAA,MAAM;YACN,OAAO,KAAK,EAAE,CAAC;SAChB;KACF;AACD,IAAA,SAAS,KAAK,GAAA;AACZ,QAAA,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC;AACxC,QAAA,IAAI,OAAO,IAAI,OAAO,GAAG,OAAO,EAAE;YAChC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;SACzD;AACD,QAAA,OAAO,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,KAChC,UAAU,CAAC,MAAM,YAAY,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CACtE,CAAC;KACH;IACD,OAAO,YAAY,EAAE,CAAC;AACxB,CAAC;AAED,MAAM,mBAAoB,SAAQ,KAAK,CAAA;AACrC,IAAA,WAAA,CAAY,OAAe,EAAA;AACzB,QAAA,KAAK,CAAC,CAAA,gBAAA,EAAmB,OAAO,CAAA,EAAA,CAAI,CAAC,CAAC;AACtC,QAAA,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;KACnC;AACF;;;;;"}
export type WaitForOptions = {
timeout?: number;
interval?: number;
};
/**
* Wait for a condition to pass.
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
* the callback. The truthy return value of the callback will be returned to the caller.
* @returns A Promise resolving to the returned value from the callback
*/
export declare function waitFor<T>(callback: () => T | Promise<T>): Promise<T>;
/**
* Wait for a condition to pass.
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
* the callback. The truthy return value of the callback will be returned to the caller.
* @param options Options for wait time/interval
* @returns A Promise resolving to the returned value from the callback
*/
export declare function waitFor_internal<T>(callback: () => T | Promise<T>, options?: WaitForOptions): Promise<T>;
import { getTimeouts } from './timeouts.mjs';
/**
* Wait for a condition to pass.
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
* the callback. The truthy return value of the callback will be returned to the caller.
* @returns A Promise resolving to the returned value from the callback
*/
async function waitFor(callback) {
const { pollingInterval, waitForTimeout } = getTimeouts();
return waitFor_internal(callback, { timeout: waitForTimeout, interval: pollingInterval });
}
/**
* Wait for a condition to pass.
* @param callback The function to run. Return truthy to stop the wait; anything else will retry
* the callback. The truthy return value of the callback will be returned to the caller.
* @param options Options for wait time/interval
* @returns A Promise resolving to the returned value from the callback
*/
async function waitFor_internal(callback, options) {
const { waitForTimeout, pollingInterval } = getTimeouts();
const timeout = options?.timeout ?? waitForTimeout;
const interval = options?.interval ?? pollingInterval;
const start = performance.now();
async function testCallback() {
try {
const result = await callback();
if (result) {
return result;
}
return retry();
}
catch {
return retry();
}
}
function retry() {
const now = performance.now();
const elapsed = Math.round(now - start);
if (timeout && elapsed > timeout) {
return Promise.reject(new WaitForTimeoutError(elapsed));
}
return new Promise((accept, reject) => setTimeout(() => testCallback().then(accept).catch(reject), interval));
}
return testCallback();
}
class WaitForTimeoutError extends Error {
constructor(elapsed) {
super(`timed out after ${elapsed}ms`);
this.name = 'WaitForTimeoutError';
}
}
export { waitFor, waitFor_internal };
//# sourceMappingURL=waitFor.mjs.map
{"version":3,"file":"waitFor.mjs","sources":["../../src/UNSAFE_Driver/waitFor.ts"],"sourcesContent":["import { getTimeouts } from './timeouts';\n\nexport type WaitForOptions = {\n timeout?: number;\n interval?: number;\n};\n\n/**\n * Wait for a condition to pass.\n * @param callback The function to run. Return truthy to stop the wait; anything else will retry\n * the callback. The truthy return value of the callback will be returned to the caller.\n * @returns A Promise resolving to the returned value from the callback\n */\nexport async function waitFor<T>(callback: () => T | Promise<T>) {\n const { pollingInterval, waitForTimeout } = getTimeouts();\n return waitFor_internal(callback, { timeout: waitForTimeout, interval: pollingInterval });\n}\n\n/**\n * Wait for a condition to pass.\n * @param callback The function to run. Return truthy to stop the wait; anything else will retry\n * the callback. The truthy return value of the callback will be returned to the caller.\n * @param options Options for wait time/interval\n * @returns A Promise resolving to the returned value from the callback\n */\nexport async function waitFor_internal<T>(\n callback: () => T | Promise<T>,\n options?: WaitForOptions\n) {\n const { waitForTimeout, pollingInterval } = getTimeouts();\n const timeout = options?.timeout ?? waitForTimeout;\n const interval = options?.interval ?? pollingInterval;\n const start = performance.now();\n async function testCallback() {\n try {\n const result = await callback();\n if (result) {\n return result;\n }\n return retry();\n } catch {\n return retry();\n }\n }\n function retry(): T | Promise<T> {\n const now = performance.now();\n const elapsed = Math.round(now - start);\n if (timeout && elapsed > timeout) {\n return Promise.reject(new WaitForTimeoutError(elapsed));\n }\n return new Promise((accept, reject) =>\n setTimeout(() => testCallback().then(accept).catch(reject), interval)\n );\n }\n return testCallback();\n}\n\nclass WaitForTimeoutError extends Error {\n constructor(elapsed: number) {\n super(`timed out after ${elapsed}ms`);\n this.name = 'WaitForTimeoutError';\n }\n}\n"],"names":[],"mappings":";;AAOA;;;;;AAKG;AACI,eAAe,OAAO,CAAI,QAA8B,EAAA;IAC7D,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,WAAW,EAAE,CAAC;AAC1D,IAAA,OAAO,gBAAgB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,CAAC;AAC5F,CAAC;AAED;;;;;;AAMG;AACI,eAAe,gBAAgB,CACpC,QAA8B,EAC9B,OAAwB,EAAA;IAExB,MAAM,EAAE,cAAc,EAAE,eAAe,EAAE,GAAG,WAAW,EAAE,CAAC;AAC1D,IAAA,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,cAAc,CAAC;AACnD,IAAA,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,eAAe,CAAC;AACtD,IAAA,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;AAChC,IAAA,eAAe,YAAY,GAAA;AACzB,QAAA,IAAI;AACF,YAAA,MAAM,MAAM,GAAG,MAAM,QAAQ,EAAE,CAAC;YAChC,IAAI,MAAM,EAAE;AACV,gBAAA,OAAO,MAAM,CAAC;aACf;YACD,OAAO,KAAK,EAAE,CAAC;SAChB;AAAC,QAAA,MAAM;YACN,OAAO,KAAK,EAAE,CAAC;SAChB;KACF;AACD,IAAA,SAAS,KAAK,GAAA;AACZ,QAAA,MAAM,GAAG,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC;AACxC,QAAA,IAAI,OAAO,IAAI,OAAO,GAAG,OAAO,EAAE;YAChC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC;SACzD;AACD,QAAA,OAAO,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,KAChC,UAAU,CAAC,MAAM,YAAY,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,CACtE,CAAC;KACH;IACD,OAAO,YAAY,EAAE,CAAC;AACxB,CAAC;AAED,MAAM,mBAAoB,SAAQ,KAAK,CAAA;AACrC,IAAA,WAAA,CAAY,OAAe,EAAA;AACzB,QAAA,KAAK,CAAC,CAAA,gBAAA,EAAmB,OAAO,CAAA,EAAA,CAAI,CAAC,CAAC;AACtC,QAAA,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;KACnC;AACF;;;;"}
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
/**
* Create a locator that targets an element by its testId
* @param testId
* @returns The ElementLocator for the given testId
*/
function byTestId(testId) {
return byCss(getTestIdCss(testId));
}
/**
* Create a locator that targets an element by CSS selector
* @param css
* @returns The ElementLocator matching the CSS selector
*/
function byCss(css) {
return {
css
};
}
function getTestIdCss(testId) {
return `[data-testid=${testId}]`;
}
exports.byCss = byCss;
exports.byTestId = byTestId;
//# sourceMappingURL=index.cjs.map
{"version":3,"file":"index.cjs","sources":["../../src/UNSAFE_Locators/index.ts"],"sourcesContent":["export interface ElementLocator {\n css: string;\n}\n\n/**\n * Create a locator that targets an element by its testId\n * @param testId\n * @returns The ElementLocator for the given testId\n */\nexport function byTestId(testId: string): ElementLocator {\n return byCss(getTestIdCss(testId));\n}\n\n/**\n * Create a locator that targets an element by CSS selector\n * @param css\n * @returns The ElementLocator matching the CSS selector\n */\nexport function byCss(css: string): ElementLocator {\n return {\n css\n };\n}\n\nfunction getTestIdCss(testId: string) {\n return `[data-testid=${testId}]`;\n}\n"],"names":[],"mappings":";;;;AAIA;;;;AAIG;AACG,SAAU,QAAQ,CAAC,MAAc,EAAA;AACrC,IAAA,OAAO,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;AACrC,CAAC;AAED;;;;AAIG;AACG,SAAU,KAAK,CAAC,GAAW,EAAA;IAC/B,OAAO;QACL,GAAG;KACJ,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,MAAc,EAAA;IAClC,OAAO,CAAA,aAAA,EAAgB,MAAM,CAAA,CAAA,CAAG,CAAC;AACnC;;;;;"}
export interface ElementLocator {
css: string;
}
/**
* Create a locator that targets an element by its testId
* @param testId
* @returns The ElementLocator for the given testId
*/
export declare function byTestId(testId: string): ElementLocator;
/**
* Create a locator that targets an element by CSS selector
* @param css
* @returns The ElementLocator matching the CSS selector
*/
export declare function byCss(css: string): ElementLocator;
/**
* Create a locator that targets an element by its testId
* @param testId
* @returns The ElementLocator for the given testId
*/
function byTestId(testId) {
return byCss(getTestIdCss(testId));
}
/**
* Create a locator that targets an element by CSS selector
* @param css
* @returns The ElementLocator matching the CSS selector
*/
function byCss(css) {
return {
css
};
}
function getTestIdCss(testId) {
return `[data-testid=${testId}]`;
}
export { byCss, byTestId };
//# sourceMappingURL=index.mjs.map
{"version":3,"file":"index.mjs","sources":["../../src/UNSAFE_Locators/index.ts"],"sourcesContent":["export interface ElementLocator {\n css: string;\n}\n\n/**\n * Create a locator that targets an element by its testId\n * @param testId\n * @returns The ElementLocator for the given testId\n */\nexport function byTestId(testId: string): ElementLocator {\n return byCss(getTestIdCss(testId));\n}\n\n/**\n * Create a locator that targets an element by CSS selector\n * @param css\n * @returns The ElementLocator matching the CSS selector\n */\nexport function byCss(css: string): ElementLocator {\n return {\n css\n };\n}\n\nfunction getTestIdCss(testId: string) {\n return `[data-testid=${testId}]`;\n}\n"],"names":[],"mappings":"AAIA;;;;AAIG;AACG,SAAU,QAAQ,CAAC,MAAc,EAAA;AACrC,IAAA,OAAO,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC;AACrC,CAAC;AAED;;;;AAIG;AACG,SAAU,KAAK,CAAC,GAAW,EAAA;IAC/B,OAAO;QACL,GAAG;KACJ,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,MAAc,EAAA;IAClC,OAAO,CAAA,aAAA,EAAgB,MAAM,CAAA,CAAA,CAAG,CAAC;AACnC;;;;"}
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var TestAdapter = require('./TestAdapter.cjs');
exports.TestAdapter = TestAdapter.TestAdapter;
//# sourceMappingURL=index.cjs.map
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
export { TestAdapter } from './TestAdapter';
export { TestAdapter } from './TestAdapter.mjs';
//# sourceMappingURL=index.mjs.map
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var TestDriver = require('../UNSAFE_Driver/TestDriver.cjs');
/**
* The base class for portable test adapters. Test adapters should extend this
* class to provide uniform construction.
*/
class TestAdapter {
/**
* Create the test adapter from the locator and optional TestDriver or TestElement.
* If a driverOrElement is given, the locator will be searched from there.
* @param locator The ElementLocator used to search for the component
* @param driverOrElement The optional TestDriver or TestElement from which to search. If
* TestElement is given, locator will search underneath that element. If TestDriver is given
* or the parameter is undefined, the DOM is searched globally.
*/
constructor(locator, driverOrElement) {
this._elementQuery = () => {
if (driverOrElement) {
return driverOrElement.waitForElement(locator);
}
else {
return TestDriver.getTestDriver().waitForElement(locator);
}
};
}
/**
* Get the TestElement for the root DOM of this component. This method will query the DOM environment
* for the matching element each time it's calld. Do not store the reference to the returned element.
* It's recommended that this method be called each time element is needed, to avoid the chance that
* the reference may become stale due to a rerender.
* @returns Promise resolving to the TestElement for this adapter
*/
getElement() {
return this._elementQuery();
}
getTestDriver() {
return TestDriver.getTestDriver();
}
}
exports.TestAdapter = TestAdapter;
//# sourceMappingURL=TestAdapter.cjs.map
{"version":3,"file":"TestAdapter.cjs","sources":["../../src/UNSAFE_TestAdapter/TestAdapter.ts"],"sourcesContent":["import { TestDriver, TestElement, getTestDriver } from '../UNSAFE_Driver';\nimport { ElementLocator } from '../UNSAFE_Locators';\n\n/**\n * The base class for portable test adapters. Test adapters should extend this\n * class to provide uniform construction.\n */\nexport class TestAdapter {\n private _elementQuery: () => Promise<TestElement>;\n\n /**\n * Create the test adapter from the locator and optional TestDriver or TestElement.\n * If a driverOrElement is given, the locator will be searched from there.\n * @param locator The ElementLocator used to search for the component\n * @param driverOrElement The optional TestDriver or TestElement from which to search. If\n * TestElement is given, locator will search underneath that element. If TestDriver is given\n * or the parameter is undefined, the DOM is searched globally.\n */\n constructor(locator: ElementLocator, driverOrElement?: TestDriver | TestElement) {\n this._elementQuery = () => {\n if (driverOrElement) {\n return driverOrElement.waitForElement(locator);\n } else {\n return getTestDriver().waitForElement(locator);\n }\n };\n }\n\n /**\n * Get the TestElement for the root DOM of this component. This method will query the DOM environment\n * for the matching element each time it's calld. Do not store the reference to the returned element.\n * It's recommended that this method be called each time element is needed, to avoid the chance that\n * the reference may become stale due to a rerender.\n * @returns Promise resolving to the TestElement for this adapter\n */\n protected getElement() {\n return this._elementQuery();\n }\n\n protected getTestDriver() {\n return getTestDriver();\n }\n}\n"],"names":["getTestDriver"],"mappings":";;;;;;AAGA;;;AAGG;MACU,WAAW,CAAA;AAGtB;;;;;;;AAOG;IACH,WAAY,CAAA,OAAuB,EAAE,eAA0C,EAAA;AAC7E,QAAA,IAAI,CAAC,aAAa,GAAG,MAAK;YACxB,IAAI,eAAe,EAAE;AACnB,gBAAA,OAAO,eAAe,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;aAChD;iBAAM;AACL,gBAAA,OAAOA,wBAAa,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;aAChD;AACH,SAAC,CAAC;KACH;AAED;;;;;;AAMG;IACO,UAAU,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,aAAa,EAAE,CAAC;KAC7B;IAES,aAAa,GAAA;QACrB,OAAOA,wBAAa,EAAE,CAAC;KACxB;AACF;;;;"}
import { TestDriver, TestElement } from '../UNSAFE_Driver';
import { ElementLocator } from '../UNSAFE_Locators';
/**
* The base class for portable test adapters. Test adapters should extend this
* class to provide uniform construction.
*/
export declare class TestAdapter {
private _elementQuery;
/**
* Create the test adapter from the locator and optional TestDriver or TestElement.
* If a driverOrElement is given, the locator will be searched from there.
* @param locator The ElementLocator used to search for the component
* @param driverOrElement The optional TestDriver or TestElement from which to search. If
* TestElement is given, locator will search underneath that element. If TestDriver is given
* or the parameter is undefined, the DOM is searched globally.
*/
constructor(locator: ElementLocator, driverOrElement?: TestDriver | TestElement);
/**
* Get the TestElement for the root DOM of this component. This method will query the DOM environment
* for the matching element each time it's calld. Do not store the reference to the returned element.
* It's recommended that this method be called each time element is needed, to avoid the chance that
* the reference may become stale due to a rerender.
* @returns Promise resolving to the TestElement for this adapter
*/
protected getElement(): Promise<TestElement>;
protected getTestDriver(): TestDriver;
}
import { getTestDriver } from '../UNSAFE_Driver/TestDriver.mjs';
/**
* The base class for portable test adapters. Test adapters should extend this
* class to provide uniform construction.
*/
class TestAdapter {
/**
* Create the test adapter from the locator and optional TestDriver or TestElement.
* If a driverOrElement is given, the locator will be searched from there.
* @param locator The ElementLocator used to search for the component
* @param driverOrElement The optional TestDriver or TestElement from which to search. If
* TestElement is given, locator will search underneath that element. If TestDriver is given
* or the parameter is undefined, the DOM is searched globally.
*/
constructor(locator, driverOrElement) {
this._elementQuery = () => {
if (driverOrElement) {
return driverOrElement.waitForElement(locator);
}
else {
return getTestDriver().waitForElement(locator);
}
};
}
/**
* Get the TestElement for the root DOM of this component. This method will query the DOM environment
* for the matching element each time it's calld. Do not store the reference to the returned element.
* It's recommended that this method be called each time element is needed, to avoid the chance that
* the reference may become stale due to a rerender.
* @returns Promise resolving to the TestElement for this adapter
*/
getElement() {
return this._elementQuery();
}
getTestDriver() {
return getTestDriver();
}
}
export { TestAdapter };
//# sourceMappingURL=TestAdapter.mjs.map
{"version":3,"file":"TestAdapter.mjs","sources":["../../src/UNSAFE_TestAdapter/TestAdapter.ts"],"sourcesContent":["import { TestDriver, TestElement, getTestDriver } from '../UNSAFE_Driver';\nimport { ElementLocator } from '../UNSAFE_Locators';\n\n/**\n * The base class for portable test adapters. Test adapters should extend this\n * class to provide uniform construction.\n */\nexport class TestAdapter {\n private _elementQuery: () => Promise<TestElement>;\n\n /**\n * Create the test adapter from the locator and optional TestDriver or TestElement.\n * If a driverOrElement is given, the locator will be searched from there.\n * @param locator The ElementLocator used to search for the component\n * @param driverOrElement The optional TestDriver or TestElement from which to search. If\n * TestElement is given, locator will search underneath that element. If TestDriver is given\n * or the parameter is undefined, the DOM is searched globally.\n */\n constructor(locator: ElementLocator, driverOrElement?: TestDriver | TestElement) {\n this._elementQuery = () => {\n if (driverOrElement) {\n return driverOrElement.waitForElement(locator);\n } else {\n return getTestDriver().waitForElement(locator);\n }\n };\n }\n\n /**\n * Get the TestElement for the root DOM of this component. This method will query the DOM environment\n * for the matching element each time it's calld. Do not store the reference to the returned element.\n * It's recommended that this method be called each time element is needed, to avoid the chance that\n * the reference may become stale due to a rerender.\n * @returns Promise resolving to the TestElement for this adapter\n */\n protected getElement() {\n return this._elementQuery();\n }\n\n protected getTestDriver() {\n return getTestDriver();\n }\n}\n"],"names":[],"mappings":";;AAGA;;;AAGG;MACU,WAAW,CAAA;AAGtB;;;;;;;AAOG;IACH,WAAY,CAAA,OAAuB,EAAE,eAA0C,EAAA;AAC7E,QAAA,IAAI,CAAC,aAAa,GAAG,MAAK;YACxB,IAAI,eAAe,EAAE;AACnB,gBAAA,OAAO,eAAe,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;aAChD;iBAAM;AACL,gBAAA,OAAO,aAAa,EAAE,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;aAChD;AACH,SAAC,CAAC;KACH;AAED;;;;;;AAMG;IACO,UAAU,GAAA;AAClB,QAAA,OAAO,IAAI,CAAC,aAAa,EAAE,CAAC;KAC7B;IAES,aAAa,GAAA;QACrB,OAAO,aAAa,EAAE,CAAC;KACxB;AACF;;;;"}
+26
-5
{
"name": "@oracle/oraclejet-testing",
"scripts": {
"build": "yarn clean; tsc --outDir dist && yarn copy-files",
"build": "turbo run-build --filter=@oracle/oraclejet-testing",
"clean": "rimraf dist",
"copy-files": "mergeJson package.json src/package-overrides.json dist/package.json"
"check-types": "turbo run-check-types --filter=@oracle/oraclejet-testing -- ",
"copy-files": "mergeJson package.json src/package-overrides.json dist/package.json; copyfiles -f README.md dist",
"lint": "turbo run-lint --filter=@oracle/oraclejet-testing -- ",
"run-build": "rollup -c rollup.config.mjs && yarn copy-files",
"run-check-types": "tsc --noEmit",
"run-lint": "eslint",
"test": "jest -c test/jest.config.js",
"test-ci-headless": "yarn test"
},
"devDependencies": {
"@jest/globals": "29.6.2",
"@oracle/oraclejet-config-eslint": "workspace:*",
"@oracle/oraclejet-config-jest": "workspace:*",
"@oracle/oraclejet-config-typescript": "workspace:*",
"@oracle/oraclejet-internal-ws-build": "workspace:^",
"copyfiles": "2.4.1",
"eslint": "9.2.0",
"jest": "29.6.2",
"rimraf": "3.0.2",
"typescript": "5.7.2"
"rollup": "2.70.2",
"ts-jest": "29.1.0",
"turbo": "2.3.3",
"typescript": "5.8.3",
"typescript-eslint": "8.29.1"
},
"exports": {
"./*": "./*/index.js"
"./*": {
"types": "./*/index.d.ts",
"require": "./*/index.cjs",
"import": "./*/index.mjs"
}
},

@@ -25,3 +46,3 @@ "typesVersions": {

"dependencies": {},
"version": "18.1.5"
"version": "19.0.0"
}
-73
/**
* A TestDriver implements the platform-specific commands needed for testing
* with adapters.
*/
export interface TestDriver {
/**
* Click on the given TestElement
* @param element The TestElement on which to click
*/
click(element: TestElement, options?: ClickOptions): Promise<void>;
/**
* Execute a script in the browser environment.
* @param script The script to execute
* @param args Any arguments to pass to the script. Access each argument through
* the <code>arguments</code> array.
*/
executeScript<T>(script: string | (() => T), ...args: any): Promise<T>;
/**
* Find an element in the browser environment that matches the given CSS query.
* This method should throw an exception if no matching elements are found.
* @param query The CSS query to use in locate the element
*/
findElement(query: string): Promise<TestElement>;
/**
* Find elements in the browser environment matching the given CSS query. If no
* matching elements are found, return a blank array.
* @param query The CSS query to use in locating the elements.
*/
findElements(query: string): Promise<TestElement[]>;
/**
* Send text as keystrokes to the browser. If modifier keys are used, all key parameters in the
* sequence will be combined into a single chord.
* @param element The element to receive the keystrokes
* @param text The text value to send, or an array of KeyMap strings to send as a chord of keys
*/
sendKeys(element: TestElement, ...text: (string | KeyType)[]): Promise<void>;
}
/**
* A TestElement represents the DOM element in the browser environment. This interface
* is used by test adapters to work with elements without being bound to a specific
* platform implementation.
*/
export interface TestElement {
findElement(query: string): Promise<TestElement>;
findElements(query: string): Promise<TestElement[]>;
getAttribute(attrName: string): Promise<string | null>;
}
export declare const ModifierKeys: {
[key: string]: KeyType;
};
export type ClickOptions = {
modifiers?: (typeof ModifierKeys)[keyof typeof ModifierKeys][];
};
export declare const Keys: {
[key: string]: {
key: string;
};
};
export type KeyType = (typeof Keys)[keyof typeof Keys];
/**
* Set the TestDriver instance to be used for testing. This method should be called by
* tests during setup, before calling any test adapter methods.
*
* @param driver The TestDriver instance
*/
export declare function setDriver(driver: TestDriver): void;
/**
* Get the configured TestDriver instance to be used for testing. This method should
* only be called by test adapters to interact with the browser environment.
*
* @returns The TestDriver instance
*/
export declare function getDriver(): TestDriver;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Keys = exports.ModifierKeys = void 0;
exports.setDriver = setDriver;
exports.getDriver = getDriver;
// export const ModifierKeys: { [k: string]: KeyType } = {
exports.ModifierKeys = {
ALT: { key: 'ALT' },
CONTROL: { key: 'CONTROL' },
CONTROL_COMMAND: { key: 'CONTROL_COMMAND' },
SHIFT: { key: 'SHIFT' }
};
exports.Keys = {
...exports.ModifierKeys,
BACKSPACE: { key: 'BACKSPACE' },
TAB: { key: 'TAB' },
ENTER: { key: 'ENTER' },
ESCAPE: { key: 'ESCAPE' },
PAGE_UP: { key: 'PAGE_UP' },
PAGE_DOWN: { key: 'PAGE_DOWN' },
END: { key: 'END' },
HOME: { key: 'HOME' },
ARROW_LEFT: { key: 'ARROW_LEFT' },
ARROW_UP: { key: 'ARROW_UP' },
ARROW_RIGHT: { key: 'ARROW_RIGHT' },
ARROW_DOWN: { key: 'ARROW_DOWN' },
DELETE: { key: 'DELETE' },
F1: { key: 'F1' },
F2: { key: 'F2' },
F3: { key: 'F3' },
F4: { key: 'F4' },
F5: { key: 'F5' },
F6: { key: 'F6' },
F7: { key: 'F7' },
F8: { key: 'F8' },
F9: { key: 'F9' },
F10: { key: 'F10' },
F11: { key: 'F11' },
F12: { key: 'F12' }
};
let _driver;
/**
* Set the TestDriver instance to be used for testing. This method should be called by
* tests during setup, before calling any test adapter methods.
*
* @param driver The TestDriver instance
*/
function setDriver(driver) {
_driver = driver;
}
/**
* Get the configured TestDriver instance to be used for testing. This method should
* only be called by test adapters to interact with the browser environment.
*
* @returns The TestDriver instance
*/
function getDriver() {
if (!_driver) {
throw Error('Driver has not been set. Call setDriver()');
}
return _driver;
}
export * from './Driver';
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./Driver"), exports);
import { type TestElement } from '../UNSAFE_driver';
interface ElementLocator {
css: string;
}
export interface TestIdLocator extends ElementLocator {
}
/**
* Create a locator that targets an element by its testId
* @param testId
* @returns The ElementLocator for the given testId
*/
export declare function getByTestId(testId: string): TestIdLocator;
/**
* Perform an element search on the driver using the given ElementLocator
* @param locator
* @returns
*/
export declare function getElement(locator: ElementLocator): Promise<TestElement>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getByTestId = getByTestId;
exports.getElement = getElement;
const UNSAFE_driver_1 = require("../UNSAFE_driver");
/**
* Create a locator that targets an element by its testId
* @param testId
* @returns The ElementLocator for the given testId
*/
function getByTestId(testId) {
return {
css: getTestIdQuery(testId)
};
}
function getTestIdQuery(testId) {
return `[data-testid=${testId}]`;
}
/**
* Perform an element search on the driver using the given ElementLocator
* @param locator
* @returns
*/
async function getElement(locator) {
const matches = await (0, UNSAFE_driver_1.getDriver)().findElements(locator.css);
if (!matches.length) {
throw Error(`No matches found for "${locator.css}"`);
}
return matches[0];
}