facebook/jest — pull request #84 by leebyron (2014-07-03 07:59:40+00:00)
Title: Make jest easier to use from node instead of CLI

This makes jest much easier to use from node by way of a few changes:

* Declare a main JS file, so you can require('jest-cli').
* Allow an optional callback function to `runCLI` which is called with completionData instead of ending the process.
* Allow for `testPathPattern` to be provided directly instead of via bash args, which makes passing `{testPathPattern: "(my.*custom)|pattern"}` as options to `runCLI`.
* Set a default empty `argv`, to allow for passing null.

For example, after this change, writing a grunt task to run your tests is super straightforward:

```
grunt.registerTask('jest', function() {
var onCompleteTask = this.async();
require('jest-cli').runCLI(null, __dirname, function (completionData) {
onCompleteTask(completionData.numFailedTests === 0);
});
});
```