ReactTestRenderer-test.js — react Source File
Architecture documentation for ReactTestRenderer-test.js, a javascript file in the react codebase.
Entity Profile
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';
let ReactDOM;
let React;
let ReactCache;
let ReactTestRenderer;
let act;
let assertConsoleErrorDev;
describe('ReactTestRenderer', () => {
beforeEach(() => {
jest.resetModules();
ReactDOM = require('react-dom');
// Isolate test renderer.
jest.resetModules();
React = require('react');
ReactCache = require('react-cache');
ReactTestRenderer = require('react-test-renderer');
const InternalTestUtils = require('internal-test-utils');
act = InternalTestUtils.act;
assertConsoleErrorDev = InternalTestUtils.assertConsoleErrorDev;
});
it('should warn if used to render a ReactDOM portal', async () => {
const container = document.createElement('div');
let error;
await act(() => {
ReactTestRenderer.create(ReactDOM.createPortal('foo', container));
}).catch(e => (error = e));
assertConsoleErrorDev([
'An invalid container has been provided. ' +
'This may indicate that another renderer is being used in addition to the test renderer. ' +
'(For example, ReactDOM.createPortal inside of a ReactTestRenderer tree.) ' +
'This is not supported.',
]);
// After the update throws, a subsequent render is scheduled to
// unmount the whole tree. This update also causes an error, so React
// throws an AggregateError.
const errors = error.errors;
expect(errors.length).toBe(2);
expect(errors[0].message.includes('indexOf is not a function')).toBe(true);
expect(errors[1].message.includes('indexOf is not a function')).toBe(true);
});
it('find element by prop with suspended content', async () => {
const neverResolve = new Promise(() => {});
function TestComp({foo}) {
// ... (108 more lines)
Source
Frequently Asked Questions
What does ReactTestRenderer-test.js do?
ReactTestRenderer-test.js is a source file in the react codebase, written in javascript.
Where is ReactTestRenderer-test.js in the architecture?
ReactTestRenderer-test.js is located at packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.js (directory: packages/react-test-renderer/src/__tests__).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free