@@ -454,6 +454,13 @@ class MockTimers{
454454) ;
455455}
456456
457+ /**
458+ * Advances the virtual time of MockTimers by the specified duration (in milliseconds).
459+ * This method simulates the passage of time and triggers any scheduled timers that are due.
460+ * @param {number } [time=1] - The amount of time (in milliseconds) to advance the virtual time.
461+ * @throws {ERR_INVALID_STATE } If MockTimers are not enabled.
462+ * @throws {ERR_INVALID_ARG_VALUE } If a negative time value is provided.
463+ */
457464tick ( time = 1 ) {
458465if ( ! this . #isEnabled) {
459466throw new ERR_INVALID_STATE (
@@ -487,6 +494,12 @@ class MockTimers{
487494}
488495}
489496
497+ /**
498+ * Enables MockTimers for the specified timers.
499+ * @param {string[] } timers - An array of timer types to enable, e.g., ['setTimeout', 'setInterval'].
500+ * @throws {ERR_INVALID_STATE } If MockTimers are already enabled.
501+ * @throws {ERR_INVALID_ARG_VALUE } If an unsupported timer type is specified.
502+ */
490503enable ( timers = SUPPORTED_TIMERS ) {
491504if ( this . #isEnabled) {
492505throw new ERR_INVALID_STATE (
@@ -512,10 +525,17 @@ class MockTimers{
512525this . #toggleEnableTimers( true ) ;
513526}
514527
528+ /**
529+ * An alias for `this.reset()`, allowing the disposal of the `MockTimers` instance.
530+ */
515531[ SymbolDispose ] ( ) {
516532this . reset ( ) ;
517533}
518534
535+ /**
536+ * Resets MockTimers, disabling any enabled timers and clearing the execution queue.
537+ * Does nothing if MockTimers are not enabled.
538+ */
519539reset ( ) {
520540// Ignore if not enabled
521541if ( ! this . #isEnabled) return ;
@@ -530,6 +550,10 @@ class MockTimers{
530550}
531551}
532552
553+ /**
554+ * Runs all scheduled timers until there are no more pending timers.
555+ * @throws {ERR_INVALID_STATE } If MockTimers are not enabled.
556+ */
533557runAll ( ) {
534558if ( ! this . #isEnabled) {
535559throw new ERR_INVALID_STATE (
0 commit comments