Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Playwright React17 CT Mount

From Leeroopedia

Template:Implementation Page

Overview

React 17 CT Mount provides the browser-side component mounting logic for Playwright's React 17 component testing, using the legacy ReactDOM.render API instead of React 18's createRoot.

Description

This module is the React 17 variant of the component testing mount source. It uses ReactDOM.render and ReactDOM.unmountComponentAtNode instead of the React 18 createRoot API. The JSX transformation logic is similar to the React 18 version, converting Playwright's component descriptors into React.createElement calls.

Key differences from the React 18 version:

  • Uses ReactDOM.render(element, container) for mounting
  • Uses ReactDOM.unmountComponentAtNode(container) for unmounting
  • Does not support React.Fragment via __pw_jsx_fragment
  • Update is handled by re-rendering into the same container

Usage

Automatically injected when using @playwright/experimental-ct-react17 for component testing with React 17 projects.

Code Reference

Source Location

packages/playwright-ct-react17/registerSource.mjs (101 lines)

Key Functions

window.playwrightMount = async (component, rootElement, hooksConfig) => { ... }
window.playwrightUnmount = async (rootElement) => { ... }
window.playwrightUpdate = async (rootElement, component) => { ... }

Import

Injected as text into the browser; no direct import.

I/O Contract

Inputs

  • component -- Playwright JSX component descriptor
  • rootElement -- DOM element to mount into
  • hooksConfig -- lifecycle hook configuration

Outputs

  • Rendered React 17 component in the DOM via ReactDOM.render

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment