Home / File/ use-state.e2e.js — react Source File

use-state.e2e.js — react Source File

Architecture documentation for use-state.e2e.js, a javascript file in the react codebase. 5 imports, 0 dependents.

File javascript TestingUtilities E2E 5 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  5e899cb6_3612_413e_1a29_a9aab42c7271["use-state.e2e.js"]
  5a08878b_7e8d_9201_126f_b2be03bccb80["expectLogs.js"]
  5e899cb6_3612_413e_1a29_a9aab42c7271 --> 5a08878b_7e8d_9201_126f_b2be03bccb80
  9b5c28a1_7004_c572_dd53_c78918c8eb26["expectLogsAndClear"]
  5e899cb6_3612_413e_1a29_a9aab42c7271 --> 9b5c28a1_7004_c572_dd53_c78918c8eb26
  ce4848f8_46e9_ec40_9ee1_bb0abaf07e5b["log"]
  5e899cb6_3612_413e_1a29_a9aab42c7271 --> ce4848f8_46e9_ec40_9ee1_bb0abaf07e5b
  9adf9051_2ce4_6a22_5a47_ad6ee61b1f13["react"]
  5e899cb6_3612_413e_1a29_a9aab42c7271 --> 9adf9051_2ce4_6a22_5a47_ad6ee61b1f13
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  5e899cb6_3612_413e_1a29_a9aab42c7271 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  style 5e899cb6_3612_413e_1a29_a9aab42c7271 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import {render, screen, fireEvent} from '@testing-library/react';
import * as React from 'react';
import {useState} from 'react';
import {expectLogsAndClear, log} from './expectLogs';

function Counter() {
  let [state, setState] = useState(0);
  return (
    <div>
      <Title text="Counter" />
      <span>{state}</span>
      <button data-testid="button" onClick={() => setState(state + 1)}>
        increment
      </button>
    </div>
  );
}

function Title({text}) {
  log(`rendering: ${text}`);
  return <h1>{text}</h1>;
}

test('use-state', async () => {
  const {asFragment} = render(<Counter />);

  expect(asFragment()).toMatchInlineSnapshot(`
  <DocumentFragment>
    <div>
      <h1>
        Counter
      </h1>
      <span>
        0
      </span>
      <button
        data-testid="button"
      >
        increment
      </button>
    </div>
  </DocumentFragment>
  `);

  expectLogsAndClear(['rendering: Counter']);

  fireEvent.click(screen.getByTestId('button'));
  await screen.findByText('1');

  expectLogsAndClear(__FORGET__ ? [] : ['rendering: Counter']);
});

Subdomains

Functions

Dependencies

Frequently Asked Questions

What does use-state.e2e.js do?
use-state.e2e.js is a source file in the react codebase, written in javascript. It belongs to the TestingUtilities domain, E2E subdomain.
What functions are defined in use-state.e2e.js?
use-state.e2e.js defines 2 function(s): Counter, Title.
What does use-state.e2e.js depend on?
use-state.e2e.js imports 5 module(s): expectLogs.js, expectLogsAndClear, log, react, react.
Where is use-state.e2e.js in the architecture?
use-state.e2e.js is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/e2e/use-state.e2e.js (domain: TestingUtilities, subdomain: E2E, directory: compiler/packages/babel-plugin-react-compiler/src/__tests__/e2e).

Analyze Your Own Codebase

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

Try Supermodel Free