Home / File/ ReactMismatchedVersions-test.js — react Source File

ReactMismatchedVersions-test.js — react Source File

Architecture documentation for ReactMismatchedVersions-test.js, a javascript file in the react codebase. 2 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  f8ec1cfe_3970_11c8_6423_918b1318f108["ReactMismatchedVersions-test.js"]
  b4b4ffa5_162b_c949_ece9_cc2ed4d878d7["patchMessageChannel.js"]
  f8ec1cfe_3970_11c8_6423_918b1318f108 --> b4b4ffa5_162b_c949_ece9_cc2ed4d878d7
  5a4bf3d5_e4a3_b336_6db6_6c30351e37f2["patchMessageChannel"]
  f8ec1cfe_3970_11c8_6423_918b1318f108 --> 5a4bf3d5_e4a3_b336_6db6_6c30351e37f2
  style f8ec1cfe_3970_11c8_6423_918b1318f108 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.
 *
 * @emails react-core
 */

'use strict';

import {patchMessageChannel} from '../../../../scripts/jest/patchMessageChannel';

describe('ReactMismatchedVersions-test', () => {
  // Polyfills for test environment
  global.ReadableStream =
    require('web-streams-polyfill/ponyfill/es6').ReadableStream;
  global.TextEncoder = require('util').TextEncoder;

  let React;
  let actualReactVersion;

  beforeEach(() => {
    jest.resetModules();

    patchMessageChannel();

    jest.mock('react', () => {
      const actualReact = jest.requireActual('react');
      return {
        ...actualReact,
        version: '18.0.0-whoa-this-aint-the-right-react',
        __actualVersion: actualReact.version,
      };
    });
    React = require('react');
    actualReactVersion = React.__actualVersion;
  });

  it('importing "react-dom/client" throws if version does not match React version', async () => {
    expect(() => require('react-dom/client')).toThrow(
      'Incompatible React versions: The "react" and "react-dom" packages ' +
        'must have the exact same version. Instead got:\n' +
        '  - react:      18.0.0-whoa-this-aint-the-right-react\n' +
        `  - react-dom:  ${actualReactVersion}`,
    );
  });

  // When running in source mode, we lazily require the implementation to
  // simulate the static config dependency injection we do at build time. So it
  // only errors once you call something and trigger the require. Running the
  // test in build mode is sufficient.
  // @gate !source
  it('importing "react-dom/server" throws if version does not match React version', async () => {
    expect(() => require('react-dom/server')).toThrow(
      'Incompatible React versions: The "react" and "react-dom" packages ' +
        'must have the exact same version. Instead got:\n' +
        '  - react:      18.0.0-whoa-this-aint-the-right-react\n' +
        `  - react-dom:  ${actualReactVersion}`,
    );
// ... (90 more lines)

Domain

Frequently Asked Questions

What does ReactMismatchedVersions-test.js do?
ReactMismatchedVersions-test.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What does ReactMismatchedVersions-test.js depend on?
ReactMismatchedVersions-test.js imports 2 module(s): patchMessageChannel, patchMessageChannel.js.
Where is ReactMismatchedVersions-test.js in the architecture?
ReactMismatchedVersions-test.js is located at packages/react/src/__tests__/ReactMismatchedVersions-test.js (domain: BabelCompiler, directory: packages/react/src/__tests__).

Analyze Your Own Codebase

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

Try Supermodel Free