Home / Function/ unstable_toMatchRenderedOutput() — react Function Reference

unstable_toMatchRenderedOutput() — react Function Reference

Architecture documentation for the unstable_toMatchRenderedOutput() function in JestReact.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  02ba167f_fe6e_f314_15bd_26d5552907e9["unstable_toMatchRenderedOutput()"]
  6e8c1123_cee1_9b1d_49c3_11cbcce7cb2e["JestReact.js"]
  02ba167f_fe6e_f314_15bd_26d5552907e9 -->|defined in| 6e8c1123_cee1_9b1d_49c3_11cbcce7cb2e
  d1911126_8775_8673_b2ea_1710f866c972["assertYieldsWereCleared()"]
  02ba167f_fe6e_f314_15bd_26d5552907e9 -->|calls| d1911126_8775_8673_b2ea_1710f866c972
  825f3274_7f61_8309_ad58_ab8424a4b063["jsonChildToJSXChild()"]
  02ba167f_fe6e_f314_15bd_26d5552907e9 -->|calls| 825f3274_7f61_8309_ad58_ab8424a4b063
  57be722b_59e4_4765_8d23_a700ab4dc173["jsonChildrenToJSXChildren()"]
  02ba167f_fe6e_f314_15bd_26d5552907e9 -->|calls| 57be722b_59e4_4765_8d23_a700ab4dc173
  35bb813c_b5a5_b08c_6f38_adf936445607["createJSXElementForTestComparison()"]
  02ba167f_fe6e_f314_15bd_26d5552907e9 -->|calls| 35bb813c_b5a5_b08c_6f38_adf936445607
  5d8d65b2_75e4_f1b1_07c6_d6f74b221cad["captureAssertion()"]
  02ba167f_fe6e_f314_15bd_26d5552907e9 -->|calls| 5d8d65b2_75e4_f1b1_07c6_d6f74b221cad
  style 02ba167f_fe6e_f314_15bd_26d5552907e9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/jest-react/src/JestReact.js lines 69–98

export function unstable_toMatchRenderedOutput(root, expectedJSX) {
  assertYieldsWereCleared(root);
  const actualJSON = root.toJSON();

  let actualJSX;
  if (actualJSON === null || typeof actualJSON === 'string') {
    actualJSX = actualJSON;
  } else if (isArray(actualJSON)) {
    if (actualJSON.length === 0) {
      actualJSX = null;
    } else if (actualJSON.length === 1) {
      actualJSX = jsonChildToJSXChild(actualJSON[0]);
    } else {
      const actualJSXChildren = jsonChildrenToJSXChildren(actualJSON);
      if (actualJSXChildren === null || typeof actualJSXChildren === 'string') {
        actualJSX = actualJSXChildren;
      } else {
        actualJSX = createJSXElementForTestComparison(REACT_FRAGMENT_TYPE, {
          children: actualJSXChildren,
        });
      }
    }
  } else {
    actualJSX = jsonChildToJSXChild(actualJSON);
  }

  return captureAssertion(() => {
    expect(actualJSX).toEqual(expectedJSX);
  });
}

Domain

Subdomains

Frequently Asked Questions

What does unstable_toMatchRenderedOutput() do?
unstable_toMatchRenderedOutput() is a function in the react codebase, defined in packages/jest-react/src/JestReact.js.
Where is unstable_toMatchRenderedOutput() defined?
unstable_toMatchRenderedOutput() is defined in packages/jest-react/src/JestReact.js at line 69.
What does unstable_toMatchRenderedOutput() call?
unstable_toMatchRenderedOutput() calls 5 function(s): assertYieldsWereCleared, captureAssertion, createJSXElementForTestComparison, jsonChildToJSXChild, jsonChildrenToJSXChildren.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free