# Behavior traces — testing-library/react-testing-library

> Canonical page: https://codevetter.com/unpack/react-testing-library/behavior-traces

# Behavior traces — testing-library/react-testing-library

Scanned commit 20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800 (2026-08-27). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

The inspected flows cover import setup, component lifecycle, hydration, events, async queries, and hooks. Each trace follows runtime functions and relevant test usage rather than assuming behavior from filenames. These walks were read from source and were not executed.
- Startup: pure-module evaluation installs DOM timer/async/event wrappers; index.js then checks RTL_SKIP_AUTO_CLEANUP, registers afterEach or teardown, and registers beforeAll/afterAll act-environment management when both hooks exist. — [src/pure.js#L32-L77](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L32-L77) [src/index.js#L9-L38](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/index.js#L9-L38)
- Initial render: render validates options → defaults to document.body → appends a div → createConcurrentRoot calls createRoot → tracking is populated → renderRoot calls root.render inside act → query helpers are returned. — [src/pure.js#L125-L144](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L125-L144) [src/pure.js#L253-L294](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L253-L294) [src/pure.js#L306-L314](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L306-L314) [src/pure.js#L177-L235](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L177-L235)
- Update and teardown: result.rerender calls renderRoot with the captured root, wrapper, and scope; result.unmount calls root.unmount in act; cleanup later walks registered roots and clears their tracking. — [src/pure.js#L206-L220](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L206-L220) [src/pure.js#L317-L328](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L317-L328) [src/__tests__/rerender.js#L20-L26](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/__tests__/rerender.js#L20-L26)
- Hydration: render with hydrate:true creates a concurrent root through act(hydrateRoot); renderRoot subsequently calls the adapter's no-op hydrate, and rerender later uses root.render. The hydration test then clicks the existing button and asserts updated text. — [src/pure.js#L114-L144](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L114-L144) [src/pure.js#L177-L195](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L177-L195) [src/pure.js#L211-L218](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L211-L218) [src/__tests__/render.js#L189-L200](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/__tests__/render.js#L189-L200)
- Interaction: fireEvent.click forwards to the DOM helper; the configured eventWrapper runs its callback inside act, but nested wrapper invocations execute directly. The nesting regression dispatches input from an effect and checks both updates and act warnings. — [src/fire-event.js#L7-L11](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/fire-event.js#L7-L11) [src/pure.js#L62-L75](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L62-L75) [src/__tests__/event-wrapper-nesting.js#L6-L25](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/__tests__/event-wrapper-nesting.js#L6-L25) [src/__tests__/event-wrapper-nesting.js#L41-L51](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/__tests__/event-wrapper-nesting.js#L41-L51)
- Async query: a fixture effect schedules a promise or timer update → the test awaits waitFor/findBy → asyncWrapper disables the act flag, awaits its callback, drains microtasks via setTimeout(0), advances detected Jest fake timers, and restores the prior flag in finally. — [src/__tests__/end-to-end.js#L19-L42](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/__tests__/end-to-end.js#L19-L42) [src/__tests__/end-to-end.js#L55-L74](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/__tests__/end-to-end.js#L55-L74) [src/pure.js#L39-L60](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L39-L60)
- Hook flow: renderHook extracts initialProps → render mounts TestComponent → renderCallback computes output → useEffect writes result.current → returned rerender calls baseRerender with new props, while unmount is inherited from render. — [src/pure.js#L330-L366](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/pure.js#L330-L366) [src/__tests__/renderHook.js#L10-L50](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/__tests__/renderHook.js#L10-L50)
- Explicit act: withGlobalActEnvironment saves the prior flag and enables it; synchronous callbacks restore immediately, object thenables restore on resolution/rejection, and synchronous exceptions restore before rethrow. — [src/act-compat.js#L36-L79](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/act-compat.js#L36-L79) [src/__tests__/act.js#L47-L69](https://github.com/testing-library/react-testing-library/blob/20ce75f2907ca0e5c5a8ae595c0e9a4e368c7800/src/__tests__/act.js#L47-L69)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
