How to use the jest-util.BufferedConsole function in jest-util

To help you get started, we’ve selected a few jest-util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebook-atom / jest-electron-runner / packages / nuclide-e2e / src / rpc / NuclideE2ERPC.js View on Github external
const setupConsole = () => {
  const testConsole = new BufferedConsole(() => {});
  const originalWrite = BufferedConsole.write;
  BufferedConsole.write = (...args) => {
    // make sure the stack trace still points to the original .log origin.
    args[3] = 5;
    return originalWrite(...args);
  };

  const rendererConsole = global.console;
  const mergedConsole = {};
  Object.getOwnPropertyNames(rendererConsole)
    .filter(prop => typeof rendererConsole[prop] === 'function')
    .forEach(prop => {
      mergedConsole[prop] =
        typeof testConsole[prop] === 'function'
          ? (...args) => {
              testConsole[prop](...args);