Home / Function/ onChange() — react Function Reference

onChange() — react Function Reference

Architecture documentation for the onChange() function in runner.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  6f987440_694d_ff09_5b9e_6bb4093380cc["onChange()"]
  1fd49604_fb16_2568_4971_9eca12fd6a73["runner.ts"]
  6f987440_694d_ff09_5b9e_6bb4093380cc -->|defined in| 1fd49604_fb16_2568_4971_9eca12fd6a73
  4b902db8_39ff_6c09_0a25_3a6bd51d0bf7["runTestCommand()"]
  4b902db8_39ff_6c09_0a25_3a6bd51d0bf7 -->|calls| 6f987440_694d_ff09_5b9e_6bb4093380cc
  8b079862_93aa_0084_8b1a_0473b6ef4307["runFixtures()"]
  6f987440_694d_ff09_5b9e_6bb4093380cc -->|calls| 8b079862_93aa_0084_8b1a_0473b6ef4307
  3231d288_7a22_d6ca_c3cc_bc226b0b74ef["update()"]
  6f987440_694d_ff09_5b9e_6bb4093380cc -->|calls| 3231d288_7a22_d6ca_c3cc_bc226b0b74ef
  4cc3311f_4441_948f_0625_b0189227e270["report()"]
  6f987440_694d_ff09_5b9e_6bb4093380cc -->|calls| 4cc3311f_4441_948f_0625_b0189227e270
  style 6f987440_694d_ff09_5b9e_6bb4093380cc fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/snap/src/runner.ts lines 475–533

async function onChange(
  worker: Worker & typeof runnerWorker,
  state: RunnerState,
  sync: boolean,
  verbose: boolean,
) {
  const {compilerVersion, isCompilerBuildValid, mode, filter, debug} = state;
  if (isCompilerBuildValid) {
    const start = performance.now();

    // console.clear() only works when stdout is connected to a TTY device.
    // we're currently piping stdout (see main.ts), so let's do a 'hack'
    console.log('\u001Bc');

    // we don't clear console after this point, since
    // it may contain debug console logging
    const results = await runFixtures(
      worker,
      mode.filter ? filter : null,
      compilerVersion,
      debug,
      true, // requireSingleFixture in watch mode
      sync,
    );
    const end = performance.now();

    // Track fixture status for autocomplete suggestions
    for (const [basename, result] of results) {
      const failed =
        result.actual !== result.expected || result.unexpectedError != null;
      state.fixtureLastRunStatus.set(basename, failed ? 'fail' : 'pass');
    }

    if (mode.action === RunnerAction.Update) {
      update(results);
      state.lastUpdate = end;
    } else {
      report(results, verbose);
    }
    console.log(`Completed in ${Math.floor(end - start)} ms`);
  } else {
    console.error(
      `${mode}: Found errors in Forget source code, skipping test fixtures.`,
    );
  }
  console.log(
    '\n' +
      (mode.filter
        ? `Current mode = FILTER, pattern = "${filter?.paths[0] ?? ''}".`
        : 'Current mode = NORMAL, run all test fixtures.') +
      '\nWaiting for input or file changes...\n' +
      'u     - update all fixtures\n' +
      `d     - toggle (turn ${debug ? 'off' : 'on'}) debug logging\n` +
      'p     - enter pattern to filter fixtures\n' +
      (mode.filter ? 'a     - run all tests (exit filter mode)\n' : '') +
      'q     - quit\n' +
      '[any] - rerun tests\n',
  );
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does onChange() do?
onChange() is a function in the react codebase, defined in compiler/packages/snap/src/runner.ts.
Where is onChange() defined?
onChange() is defined in compiler/packages/snap/src/runner.ts at line 475.
What does onChange() call?
onChange() calls 3 function(s): report, runFixtures, update.
What calls onChange()?
onChange() is called by 1 function(s): runTestCommand.

Analyze Your Own Codebase

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

Try Supermodel Free