How to use the jest-cli/build.runCLI function in jest-cli

To help you get started, we’ve selected a few jest-cli 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 dsheiko / puppetry / app / main / test-runner.js View on Github external
options = {
          projects: [ cwd ],
          _: targetFiles,
          silent: true,
          // Shall disable output, but instead switch to stderr
          // https://github.com/facebook/jest/issues/5064
          json: true,
          showConfig: false
        };

  strErrCapturer.contents = [];
  // Override stderr
  const save = process.stderr.write.bind( process.stderr );
  process.stderr.write = strErrCapturer.write.bind( strErrCapturer );
  // Run JEST
  const report = await runCLI( options, options.projects );

  // Restore stderr (hopefully)
  process.stderr.write = save;

  return {
    report,
    stdErr: strErrCapturer.contents.join( "\n" )
  };

};