setupTests.js — react Source File
Architecture documentation for setupTests.js, a javascript file in the react codebase.
Entity Profile
Relationship Graph
Source Code
'use strict';
// This is mostly copypasta from toWarnDev.js matchers
// that we use in the main repo Jest configuration.
const expect = global.expect;
const {diff: jestDiff} = require('jest-diff');
const util = require('util');
function shouldIgnoreConsoleError(format, args) {
if (process.env.NODE_ENV !== 'production') {
if (typeof format === 'string') {
if (format.indexOf('Error: Uncaught [') === 0) {
// This looks like an uncaught error from invokeGuardedCallback() wrapper
// in development that is reported by jsdom. Ignore because it's noisy.
return true;
}
if (format.indexOf('The above error occurred') === 0) {
// This looks like an error addendum from ReactFiberErrorLogger.
// Ignore it too.
return true;
}
}
} else {
if (
format != null &&
typeof format.message === 'string' &&
typeof format.stack === 'string' &&
args.length === 0
) {
// In production, ReactFiberErrorLogger logs error objects directly.
// They are noisy too so we'll try to ignore them.
return true;
}
}
// Looks legit
return false;
}
function normalizeCodeLocInfo(str) {
if (typeof str !== 'string') {
return str;
}
// This special case exists only for the special source location in
// ReactElementValidator. That will go away if we remove source locations.
str = str.replace(/Check your code at .+?:\d+/g, 'Check your code at **');
// V8 format:
// at Component (/path/filename.js:123:45)
// React format:
// in Component (at filename.js:123)
return str.replace(/\n +(?:at|in) ([\S]+)[^\n]*/g, function (m, name) {
return '\n in ' + name + ' (at **)';
});
}
const createMatcherFor = (consoleMethod, matcherName) =>
function matcher(callback, expectedMessages, options = {}) {
if (process.env.NODE_ENV !== 'production') {
// Warn about incorrect usage of matcher.
// ... (249 more lines)
Domain
Subdomains
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, Entrypoint subdomain.
What functions are defined in setupTests.js?
setupTests.js defines 3 function(s): createMatcherFor, normalizeCodeLocInfo, shouldIgnoreConsoleError.
Where is setupTests.js in the architecture?
setupTests.js is located at fixtures/legacy-jsx-runtimes/setupTests.js (domain: BabelCompiler, subdomain: Entrypoint, directory: fixtures/legacy-jsx-runtimes).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free