Repository: facebook/jest
File: packages/jest-runtime/src/index.ts (TypeScript)

Code before:
              'Your test environment does not support `jest.replaceProperty` - please ensure its Jest dependencies are updated to version 29.4 or later',
            );
          };

    const setTimeout = (timeout: number) => {
      this._environment.global[testTimeoutSymbol] = timeout;
      return jestObject;
    };

    const retryTimes: Jest['retryTimes'] = (numTestRetries, options) => {
      this._environment.global[retryTimesSymbol] = numTestRetries;
      this._environment.global[logErrorsBeforeRetrySymbol] =
        options?.logErrorsBeforeRetry;

      return jestObject;
    };

    const jestObject: Jest = {
      advanceTimersByTime: (msToRun: number) =>
        _getFakeTimers().advanceTimersByTime(msToRun),
      advanceTimersByTimeAsync: async (msToRun: number): Promise<void> => {
        const fakeTimers = _getFakeTimers();

        if (
          fakeTimers === this._environment.fakeTimersModern &&
          typeof fakeTimers.advanceTimersByTimeAsync === 'function'
        ) {
          await fakeTimers.advanceTimersByTimeAsync(msToRun);
        } else {
          throw new TypeError(
            '`jest.advanceTimersByTimeAsync()` is not available when using legacy fake timers.',
          );
        }
      },
      advanceTimersToNextTimer: (steps?: number) =>
        _getFakeTimers().advanceTimersToNextTimer(steps),
      advanceTimersToNextTimerAsync: async (): Promise<void> => {
        const fakeTimers = _getFakeTimers();

        if (
          fakeTimers === this._environment.fakeTimersModern &&
          typeof fakeTimers.advanceTimersToNextTimerAsync === 'function'
        ) {
          await fakeTimers.advanceTimersToNextTimerAsync();
        } else {
          throw new TypeError(
            '`jest.advanceTimersToNextTimerAsync()` is not available when using legacy fake timers.',
          );
        }
      },
      autoMockOff: disableAutomock,

Review comment (refactor):
This and other similar checks are just temporary, right?

```suggestion
          // TODO: remove this check in Jest 30
          typeof fakeTimers.advanceTimersByTimeAsync === 'function'
```

Code after:
              'Your test environment does not support `jest.replaceProperty` - please ensure its Jest dependencies are updated to version 29.4 or later',
            );
          };

    const setTimeout: Jest['setTimeout'] = timeout => {
      this._environment.global[testTimeoutSymbol] = timeout;
      return jestObject;
    };

    const retryTimes: Jest['retryTimes'] = (numTestRetries, options) => {
      this._environment.global[retryTimesSymbol] = numTestRetries;
      this._environment.global[logErrorsBeforeRetrySymbol] =
        options?.logErrorsBeforeRetry;

      return jestObject;
    };

    const jestObject: Jest = {
      advanceTimersByTime: msToRun =>
        _getFakeTimers().advanceTimersByTime(msToRun),
      advanceTimersByTimeAsync: async msToRun => {
        const fakeTimers = _getFakeTimers();

        if (fakeTimers === this._environment.fakeTimersModern) {
          // TODO: remove this check in Jest 30
          if (typeof fakeTimers.advanceTimersByTimeAsync !== 'function') {
            throw new TypeError(
              'Your test environment does not support async fake timers - please ensure its Jest dependencies are updated to version 29.5 or later',
            );
          }
          await fakeTimers.advanceTimersByTimeAsync(msToRun);
        } else {
          throw new TypeError(
            '`jest.advanceTimersByTimeAsync()` is not available when using legacy fake timers.',
          );
        }
      },
      advanceTimersToNextTimer: steps =>
        _getFakeTimers().advanceTimersToNextTimer(steps),
      advanceTimersToNextTimerAsync: async steps => {
        const fakeTimers = _getFakeTimers();

        if (fakeTimers === this._environment.fakeTimersModern) {
          // TODO: remove this check in Jest 30
          if (typeof fakeTimers.advanceTimersToNextTimerAsync !== 'function') {
            throw new TypeError(
              'Your test environment does not support async fake timers - please ensure its Jest dependencies are updated to version 29.5 or later',
            );
          }
          await fakeTimers.advanceTimersToNextTimerAsync(steps);
        } else {