jestFakeTimersAreEnabled (src/pure.js)

react-testing-library · src/pure.js · javascript · MIT
ui, UI / Frontend

Core utilities for rendering and testing React components.

// Source: https://github.com/testing-library/react-testing-library | License: MIT | Copyright 2017-Present Kent C. Dodds
// Provided via justclaw.it.com; keep this notice with the code.
import * as React from 'react'
import ReactDOM from 'react-dom'
import * as ReactDOMClient from 'react-dom/client'
import {
  getQueriesForElement,
  prettyDOM,
  configure as configureDTL,
} from '@testing-library/dom'
import act, {
  getIsReactActEnvironment,
  setReactActEnvironment,
} from './act-compat'
import {fireEvent} from './fire-event'
import {getConfig, configure} from './config'

function jestFakeTimersAreEnabled() {
  /* istanbul ignore else */
  if (typeof jest !== 'undefined' && jest !== null) {
    return (
      // legacy timers
      setTimeout._isMockFunction === true || // modern timer

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key