setupTests.js — react Source File
Architecture documentation for setupTests.js, a javascript file in the react codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 7a8b988c_a832_ec08_c36e_22d30113be12["setupTests.js"] 919caa1d_1d73_30c4_0bb7_4a8d1e71759a["console"] 7a8b988c_a832_ec08_c36e_22d30113be12 --> 919caa1d_1d73_30c4_0bb7_4a8d1e71759a 4077b620_5c59_61c2_0910_273f565da757["bridge"] 7a8b988c_a832_ec08_c36e_22d30113be12 --> 4077b620_5c59_61c2_0910_273f565da757 style 7a8b988c_a832_ec08_c36e_22d30113be12 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.
*
* @flow
*/
import {CustomConsole} from '@jest/console';
import type {
BackendBridge,
FrontendBridge,
} from 'react-devtools-shared/src/bridge';
const {getTestFlags} = require('../../../../scripts/jest/TestFlags');
// Argument is serialized when passed from jest-cli script through to setupTests.
const compactConsole = process.env.compactConsole === 'true';
if (compactConsole) {
const formatter = (type, message) => {
switch (type) {
case 'error':
return '\x1b[31m' + message + '\x1b[0m';
case 'warn':
return '\x1b[33m' + message + '\x1b[0m';
case 'log':
default:
return message;
}
};
global.console = new CustomConsole(process.stdout, process.stderr, formatter);
}
const expectTestToFail = async (callback, error) => {
if (callback.length > 0) {
throw Error(
'Gated test helpers do not support the `done` callback. Return a ' +
'promise instead.',
);
}
try {
const maybePromise = callback();
if (
maybePromise !== undefined &&
maybePromise !== null &&
typeof maybePromise.then === 'function'
) {
await maybePromise;
}
} catch (testError) {
return;
}
throw error;
};
const gatedErrorMessage = 'Gated test was expected to fail, but it passed.';
global._test_gate = (gateFn, testName, callback) => {
// ... (239 more lines)
Domain
Subdomains
Functions
Dependencies
- bridge
- console
Source
Frequently Asked Questions
What does setupTests.js do?
setupTests.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in setupTests.js?
setupTests.js defines 6 function(s): expectTestToFail, formatter, global, patchConsoleForTestingBeforeHookInstallation, shouldIgnoreConsoleErrorOrWarn, unpatchConsoleAfterTesting.
What does setupTests.js depend on?
setupTests.js imports 2 module(s): bridge, console.
Where is setupTests.js in the architecture?
setupTests.js is located at packages/react-devtools-shared/src/__tests__/setupTests.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/__tests__).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free