Home / Function/ assertConsoleLogsCleared() — react Function Reference

assertConsoleLogsCleared() — react Function Reference

Architecture documentation for the assertConsoleLogsCleared() function in consoleMock.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  faf02e94_8b1b_114a_84ab_33c15d1cf4f2["assertConsoleLogsCleared()"]
  9565063b_3ea2_9cbf_86d6_3ee1e66bf4cc["consoleMock.js"]
  faf02e94_8b1b_114a_84ab_33c15d1cf4f2 -->|defined in| 9565063b_3ea2_9cbf_86d6_3ee1e66bf4cc
  649f12be_3313_b4be_bac2_9cdf587b5e58["assertYieldsWereCleared()"]
  649f12be_3313_b4be_bac2_9cdf587b5e58 -->|calls| faf02e94_8b1b_114a_84ab_33c15d1cf4f2
  dcab7879_15a5_b8dd_721e_6e835779837f["clearLogs()"]
  faf02e94_8b1b_114a_84ab_33c15d1cf4f2 -->|calls| dcab7879_15a5_b8dd_721e_6e835779837f
  215ba5c2_433a_0922_d95b_9b64d1bda54b["clearWarnings()"]
  faf02e94_8b1b_114a_84ab_33c15d1cf4f2 -->|calls| 215ba5c2_433a_0922_d95b_9b64d1bda54b
  daf494a6_d701_fe7c_a4a3_0560eead925b["clearErrors()"]
  faf02e94_8b1b_114a_84ab_33c15d1cf4f2 -->|calls| daf494a6_d701_fe7c_a4a3_0560eead925b
  style faf02e94_8b1b_114a_84ab_33c15d1cf4f2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/internal-test-utils/consoleMock.js lines 101–146

export function assertConsoleLogsCleared() {
  const logs = clearLogs();
  const warnings = clearWarnings();
  const errors = clearErrors();

  if (logs.length > 0 || errors.length > 0 || warnings.length > 0) {
    let message = `${chalk.dim('asserConsoleLogsCleared')}(${chalk.red(
      'expected',
    )})\n`;

    if (logs.length > 0) {
      message += `\nconsole.log was called without assertConsoleLogDev:\n${diff(
        '',
        logs.join('\n'),
        {
          omitAnnotationLines: true,
        },
      )}\n`;
    }

    if (warnings.length > 0) {
      message += `\nconsole.warn was called without assertConsoleWarnDev:\n${diff(
        '',
        warnings.map(normalizeComponentStack).join('\n'),
        {
          omitAnnotationLines: true,
        },
      )}\n`;
    }
    if (errors.length > 0) {
      message += `\nconsole.error was called without assertConsoleErrorDev:\n${diff(
        '',
        errors.map(normalizeComponentStack).join('\n'),
        {
          omitAnnotationLines: true,
        },
      )}\n`;
    }

    message += `\nYou must call one of the assertConsoleDev helpers between each act call.`;

    const error = Error(message);
    Error.captureStackTrace(error, assertConsoleLogsCleared);
    throw error;
  }
}

Domain

Subdomains

Frequently Asked Questions

What does assertConsoleLogsCleared() do?
assertConsoleLogsCleared() is a function in the react codebase, defined in packages/internal-test-utils/consoleMock.js.
Where is assertConsoleLogsCleared() defined?
assertConsoleLogsCleared() is defined in packages/internal-test-utils/consoleMock.js at line 101.
What does assertConsoleLogsCleared() call?
assertConsoleLogsCleared() calls 3 function(s): clearErrors, clearLogs, clearWarnings.
What calls assertConsoleLogsCleared()?
assertConsoleLogsCleared() is called by 1 function(s): assertYieldsWereCleared.

Analyze Your Own Codebase

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

Try Supermodel Free