How to use the jest-cli.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 electron-userland / electron-builder / test / src / helpers / runTests.ts View on Github external
config,
    runInBand,
    projects: [rootDir],
  }

  if (testPatterns.length > 0) {
    jestOptions.testPathPattern = testPatterns
      .map(it => it.endsWith(".js") || it.endsWith("*") ? it : `${it}\\.js$`)
  }
  if (process.env.CIRCLECI != null || process.env.TEST_JUNIT_REPORT === "true") {
    jestOptions.reporters = ["default", "jest-junit"]
  }

  // console.log(JSON.stringify(jestOptions, null, 2))

  const testResult = await require("jest-cli").runCLI(jestOptions, jestOptions.projects)
  const exitCode = testResult.results == null || testResult.results.success ? 0 : testResult.globalConfig.testFailureExitCode
  if (isCi) {
    process.exit(exitCode)
  }

  await remove(APP_BUILDER_TMP_DIR)
  process.exitCode = exitCode
  if (testResult.globalConfig.forceExit) {
    process.exit(exitCode)
  }
}
github facebookarchive / atom-ide-ui / modules / nuclide-jest / bin / jest-node.js View on Github external
*/
/* eslint-disable no-console */

const jestCLI = require('jest-cli');
const config = require('../jest.config.js');
const yargs = require('yargs');
const {options} = require('jest-cli/build/cli/args');

// We reach into the internals of Jest to get the options it uses for arg
// parsing with yargs to ensure we parse the args consistently with Jest.
const {argv} = yargs(process.argv.slice(2)).options(options);
// Then we override some of the options with hardcoded values.
argv.watchman = true;
argv.config = JSON.stringify(config);

jestCLI
  .runCLI(argv, [process.cwd()])
  .then(response => process.exit(response.results.success ? 0 : 1));
github CondeNast / opensource-check / src / index.js View on Github external
const run = () => {
  const options = {
    roots: ["__checks__"],
    verbose: true,
    testPathIgnorePatterns: []
  };
  jest.runCLI(options, [__dirname]).then(({ results }) => {
    if (!results.success) {
      process.exit(1);
    }
  });
};
github zupzup / reactgym / gulpfile.js View on Github external
gulp.task('test', function(callback) {
    gulp.watch('__tests__/**/*.js', ['test']);
    gulp.watch('scripts/**/*.js', ['test']);
    var onComplete = function() {
        callback();
    };
    jest.runCLI({}, __dirname, onComplete);
});
github leebyron / grunt-jest / tasks / jest.js View on Github external
grunt.registerTask('jest', 'Run tests with Jest.', function() {
    require('jest-cli').runCLI(this.options(), process.cwd(), this.async());
  });
github aurelia / cli / lib / resources / tasks / jest.ts View on Github external
export default (cb) => {
  let options = packageJson.jest;
  
  if (CLIOptions.hasFlag('watch')) {
    Object.assign(options, { watch: true});
  }

  jest.runCLI(options, [path.resolve(__dirname, '../../')]).then((result) => {
    if(result.numFailedTests || result.numFailedTestSuites) {
      cb(new PluginError('gulp-jest', { message: 'Tests Failed' }));
    } else {
      cb();
    }
  });
};
github ghiscoding / aurelia-slickgrid / aurelia_project / tasks / jest.ts View on Github external
export default (cb) => {
  let options = packageJson.jest;

  if (CLIOptions.hasFlag('watch')) {
    Object.assign(options, { watch: true });
  }

  jest.runCLI(options, [path.resolve(__dirname, '../../')], (result) => {
    if (result.numFailedTests || result.numFailedTestSuites) {
      cb(new gutil.PluginError('gulp-jest', { message: 'Tests Failed' }));
    } else {
      cb();
    }
  });
};
github leandrowd / react-responsive-carousel / tasks / jest.js View on Github external
module.exports = function(callback) {
    jest.runCLI({ config: jestConfig }, configs.paths.source, function(result) {
        if (!result || !result.success) {
            callback('Jest tests failed');
        } else {
            callback();
        }
    });
};
github wix / haste / packages / haste-task-jest / src / index.js View on Github external
module.exports = async ({ config, projects = [process.cwd()] }) => {
  const argv = {
    config: JSON.stringify(config),
  };

  const { results } = await runCLI(argv, projects);

  if (!results.success) {
    throw new Error(`Jest failed with ${results.numFailedTests} failing tests`);
  }

  return results;
};
github Kunstmaan / KunstmaanBundlesCMS / src / Kunstmaan / GeneratorBundle / Resources / SensioGeneratorBundle / skeleton / layout / groundcontrol / bin / tasks / jest.js View on Github external
return function jest(done) {
        const onComplete = (runResults) => {
            if (runResults.success === false && failAfterError === true) {
                done(new Error('[jest] at least 1 test failed'));
            } else {
                done();
            }
        };

        jestCli.runCLI({ config }, root, onComplete);
    };
}