import { DriverCoreIO } from './driverCoreIO'; import { DriverError, WaitForDataOptions, WaitUntilOptions, WriteAndWaitForDataOptions } from './interfaces'; /** * Base abstract class of Driver. Its responsibilities are wait for a condition and facilities for basing that * condition (predicate) in the current data emitted from last write() */ export declare class DriverWait extends DriverCoreIO { /** * this error occurs when unser calls waitUntil* method with an interval greater than timeout */ static ERROR_WAITUNTIL_INTERVAL_GREATER_THAN_TIMEOUT: 'ERROR_WAITUNTIL_INTERVAL_GREATER_THAN_TIMEOUT'; /** * this error occurs on waitUntil* methods timeouts */ static ERROR_WAITUNTIL_TIMEOUT: 'ERROR_WAITUNTIL_TIMEOUT'; /** * the more generic wait* method on which all the others are based. Returns a promise that is resolved only when * given predicate is fulfilled or rejected if timeout ms passes. THe implementation will be calling the * predicate function like polling each interval [[waitInterval]] milliseconds. * @param predicate a function that if return a truthy value will stop the polling * @param timeout default value is [[waitTimeout]] * @param interval default value is [[waitInterval]] * @param rejectOnTimeout By default waitUntil (and all wait* methods) will reject the promise on timeout. Set * this to false so they resolve the promise with false value instead * @returns A promise resolved with the return value of the predicate if it ever return truthy or in other case * if the predicate never returns truthy in given timeout it will be rejected unless rejectOnTimeout===false in * which case the promise is resolved with false */ waitUntil(predicate: ((...args: any[]) => Promise | T | boolean) | WaitUntilOptions | T, timeout?: number, interval?: number, rejectOnTimeout?: boolean): Promise; /** * alias for [[waitUntil]] */ until: typeof DriverWait.prototype.waitUntil; /** * Tries to represent a predicate as a string. It accept functions, strings and [WaitForDataOptions] */ static printWaitUntilPredicate(predicate: string | ({ originalPredicate?: any; } & ((...args: any[]) => any)) | WaitForDataOptions | any): string; /** * Wait until new data matches given predicate. If not predicate is given will return the next data chunk that * comes. Based on [[waitUntil]] * @param predicate condition stdout must comply with in other to stop waiting for. If none it will wait until * next data chunk is received. If function that's the predicate function the data must comply with. If string, * the predicate will be that new data contains this string * @param timeout wait timeout in ms * @param interval wait interval in ms * @param afterTimestamp if provided it will ork with data after that given timestamp. By default this timestamp * is the last write()'s * @param rejectOnTimeout By default waitUntil (and all wait* methods) will reject the promise on timeout. Set * this to false so they resolve the promise with false value instead * @return resolved with the matched data or rejected if no data comply with predicate before timeout */ waitForData(predicate?: ((data: string) => boolean) | string | WaitForDataOptions, timeout?: number, interval?: number, afterTimestamp?: number, rejectOnTimeout?: boolean): Promise; /** * An alias for [waitForData] but it will always resolve as string or throw an error otherwise. */ wait(...args: Parameters): Promise; /** * alias for [[waitForData]] */ forData: typeof DriverWait.prototype.waitForData; /** * @param commandToEnter same as in [[write]] * @param predicate same as in [[waitForData]] * @param timeout same as in [[waitForData]] * @param interval same as in [[waitForData]] * @param afterTimestamp same as in [[waitForData]] * @param rejectOnTimeout By default waitUntil (and all wait* methods) will reject the promise on timeout. Set * this to false so they resolve the promise with false value instead * @return same as in [[waitForData]] */ enterAndWaitForData(input: string | WriteAndWaitForDataOptions, predicate: ((data: string) => boolean) | string, timeout?: number, interval?: number, afterTimestamp?: number, rejectOnTimeout?: boolean): Promise; /** * An alias for [enterAndWaitForData] but it will always resolve as string or throw an error otherwise. */ enterAndWait(...args: Parameters): Promise; /** * @param commandToEnter same as in [[write]] * @param predicate same as in [[waitForData]] * @param timeout same as in [[waitForData]] * @param interval same as in [[waitForData]] * @param afterTimestamp same as in [[waitForData]] * @param rejectOnTimeout By default waitUntil (and all wait* methods) will reject the promise on timeout. Set * this to false so they resolve the promise with false value instead * @return same as in [[waitForData]] */ writeAndWaitForData(input: string | WriteAndWaitForDataOptions, predicate: ((data: string) => boolean) | string, timeout?: number, interval?: number, afterTimestamp?: number, rejectOnTimeout?: boolean): Promise; /** * @param predicate same as in [[waitForData]] * @param commandToEnter same as in [[write]] * @param timeout same as in [[waitForData]] * @param interval same as in [[waitForData]] * @param afterTimestamp same as in [[waitForData]] * @param rejectOnTimeout By default waitUntil (and all wait* methods) will reject the promise on timeout. Set * this to false so they resolve the promise with false value instead * @return {Promise} same as in [[waitForData]] */ waitForDataAndEnter(predicate: ((data: string) => boolean) | string | WriteAndWaitForDataOptions, input: string, timeout?: number, interval?: number, afterTimestamp?: number, rejectOnTimeout?: boolean): Promise; /** * An alias for [waitForDataAndEnter] but it will always resolve as string or throw an error otherwise. */ waitAndEnter(...args: Parameters): Promise; /** * An alias for [waitAndEnter]. */ andEnter: (predicate: string | WriteAndWaitForDataOptions | ((data: string) => boolean), input: string, timeout?: number, interval?: number, afterTimestamp?: number, rejectOnTimeout?: boolean) => Promise; /** * alias for [[waitForDataAndEnter]] */ forDataAndEnter: typeof DriverWait.prototype.waitForDataAndEnter; /** * @param predicate same as in [[waitForData]] * @param input same as in [[write]] * @param timeout same as in [[waitForData]] * @param interval same as in [[waitForData]] * @param afterTimestamp same as in [[waitForData]] * @param rejectOnTimeout By default waitUntil (and all wait* methods) will reject the promise on timeout. Set * this to false so they resolve the promise with false value instead * @return {Promise} same as in [[waitForData]] */ waitForDataAndWrite(predicate: ((data: string) => boolean) | string | WriteAndWaitForDataOptions, input: string, timeout?: number, interval?: number, afterTimestamp?: number, rejectOnTimeout?: boolean): Promise; /** * alias for [[waitForDataAndWrite]] */ forDataAndWrite: typeof DriverWait.prototype.waitForDataAndWrite; }