ReactFlightTurbopackDOMReply-test.js — react Source File
Architecture documentation for ReactFlightTurbopackDOMReply-test.js, a javascript file in the react codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 0ad72782_e27d_6857_d11f_044894bc74bf["ReactFlightTurbopackDOMReply-test.js"] b4b4ffa5_162b_c949_ece9_cc2ed4d878d7["patchMessageChannel.js"] 0ad72782_e27d_6857_d11f_044894bc74bf --> b4b4ffa5_162b_c949_ece9_cc2ed4d878d7 5a4bf3d5_e4a3_b336_6db6_6c30351e37f2["patchMessageChannel"] 0ad72782_e27d_6857_d11f_044894bc74bf --> 5a4bf3d5_e4a3_b336_6db6_6c30351e37f2 style 0ad72782_e27d_6857_d11f_044894bc74bf 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';
// Polyfills for test environment
global.ReadableStream =
require('web-streams-polyfill/ponyfill/es6').ReadableStream;
global.TextEncoder = require('util').TextEncoder;
global.TextDecoder = require('util').TextDecoder;
// let serverExports;
let assertConsoleErrorDev;
let turbopackServerMap;
let ReactServerDOMServer;
let ReactServerDOMClient;
let ReactServerScheduler;
describe('ReactFlightTurbopackDOMReply', () => {
beforeEach(() => {
jest.resetModules();
ReactServerScheduler = require('scheduler');
patchMessageChannel(ReactServerScheduler);
// Simulate the condition resolution
jest.mock('react', () => require('react/react.react-server'));
jest.mock('react-server-dom-turbopack/server', () =>
require('react-server-dom-turbopack/server.browser'),
);
const TurbopackMock = require('./utils/TurbopackMock');
// serverExports = TurbopackMock.serverExports;
turbopackServerMap = TurbopackMock.turbopackServerMap;
ReactServerDOMServer = require('react-server-dom-turbopack/server.browser');
jest.resetModules();
ReactServerDOMClient = require('react-server-dom-turbopack/client');
const InternalTestUtils = require('internal-test-utils');
assertConsoleErrorDev = InternalTestUtils.assertConsoleErrorDev;
});
it('can encode a reply', async () => {
const body = await ReactServerDOMClient.encodeReply({some: 'object'});
const decoded = await ReactServerDOMServer.decodeReply(
body,
turbopackServerMap,
);
expect(decoded).toEqual({some: 'object'});
});
it('warns with a tailored message if eval is not available in dev', async () => {
// eslint-disable-next-line no-eval
const previousEval = globalThis.eval.bind(globalThis);
// eslint-disable-next-line no-eval
globalThis.eval = () => {
throw new Error('eval is disabled');
};
try {
const body = await ReactServerDOMClient.encodeReply({some: 'object'});
assertConsoleErrorDev([
'eval() is not supported in this environment. ' +
'If this page was served with a `Content-Security-Policy` header, ' +
'make sure that `unsafe-eval` is included. ' +
'React requires eval() in development mode for various debugging features ' +
'like reconstructing callstacks from a different environment.\n' +
'React will never use eval() in production mode',
]);
await ReactServerDOMServer.decodeReply(body, turbopackServerMap);
assertConsoleErrorDev([]);
} finally {
// eslint-disable-next-line no-eval
globalThis.eval = previousEval;
}
});
});
Domain
Dependencies
Source
Frequently Asked Questions
What does ReactFlightTurbopackDOMReply-test.js do?
ReactFlightTurbopackDOMReply-test.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What does ReactFlightTurbopackDOMReply-test.js depend on?
ReactFlightTurbopackDOMReply-test.js imports 2 module(s): patchMessageChannel, patchMessageChannel.js.
Where is ReactFlightTurbopackDOMReply-test.js in the architecture?
ReactFlightTurbopackDOMReply-test.js is located at packages/react-server-dom-turbopack/src/__tests__/ReactFlightTurbopackDOMReply-test.js (domain: BabelCompiler, directory: packages/react-server-dom-turbopack/src/__tests__).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free