@serenity-js/core
Version:
The core Serenity/JS framework, providing the Screenplay Pattern interfaces, as well as the test reporting and integration infrastructure
50 lines • 1.57 kB
TypeScript
import { type JSONObject } from 'tiny-types';
import { Duration } from './Duration';
import { Timestamp } from './Timestamp';
/**
* A [`Clock`](https://serenity-js.org/api/core/class/Clock/) tells the time. This abstraction allows Serenity/JS to have a single place
* in the framework responsible for telling the time, and one that can be easily mocked for internal testing.
*
* ```ts
* const now: Timestamp = new Clock().now()
* ```
*
* ## Learn more
* - [`Timestamp`](https://serenity-js.org/api/core/class/Timestamp/)
* - [`Duration`](https://serenity-js.org/api/core/class/Duration/)
*
* @group Time
*/
export declare class Clock {
private readonly checkTime;
private static resolution;
private timeAdjustment;
constructor(checkTime?: () => Date);
toJSON(): JSONObject;
/**
* Sets the clock ahead to force early resolution of promises
* returned by [`Clock.waitFor`](https://serenity-js.org/api/core/class/Clock/#waitFor).
*
* Useful for test purposes to avoid unnecessary delays.
*
* @param duration
*/
setAhead(duration: Duration): void;
/**
* Returns a Promise that resolves after one tick of the clock.
*
* Useful for test purposes to avoid unnecessary delays.
*/
tick(): Promise<void>;
/**
* Returns current time
*/
now(): Timestamp;
/**
* Returns a Promise that will be resolved after the given duration
*
* @param duration
*/
waitFor(duration: Duration): Promise<void>;
}
//# sourceMappingURL=Clock.d.ts.map