setSystemTime
Cambia il tempo di sistema con un nuovo valore attuale. Il valore attuale può essere un timestamp, un oggetto data, o non passato il che lo imposta di default a 0. Nessun timer verrà chiamato, né cambierà il tempo rimasto prima che vengano attivati.
Usage
const clock = await browser.emulate('clock', { ... })
await clock.setSystemTime(date)
Parameters
Name | Type | Details |
---|---|---|
date | Date , number | La nuova data da impostare come tempo di sistema. |
Example
setSystemTime.js
const clock = await browser.emulate('clock', { now: new Date(2021, 3, 14) })
console.log(await browser.execute(() => new Date().getTime())) // returns 1618383600000
await clock.setSystemTime(new Date(2011, 3, 15))
console.log(await browser.execute(() => new Date().getTime())) // returns 1302850800000
Returns
- <
Promise<void>
>