Files
react/grunt/tasks/jest.js
T
Christopher ChedeauandGitHub 839697f60c Restore coverage in Travis (#7628)
We disabled coverage in Travis because the implementation was crashing ( https://github.com/facebook/react/issues/6290 ). Since we upgraded to Jest 15, the entire coverage implementation is brand new so we should give it another try.
2016-09-02 14:23:58 -07:00

51 lines
951 B
JavaScript

'use strict';
var grunt = require('grunt');
var path = require('path');
function run(done, coverage) {
grunt.log.writeln('running jest');
var args = [
path.join('node_modules', 'jest', 'bin', 'jest'),
];
if (coverage) {
args.push('--coverage');
}
grunt.util.spawn({
cmd: 'node',
args: args,
opts: {
stdio: 'inherit',
env: Object.assign({}, process.env, {
NODE_ENV: 'test',
}),
},
}, function(spawnErr, result, code) {
if (spawnErr) {
grunt.log.error('jest failed');
grunt.log.error(spawnErr);
} else {
grunt.log.ok('jest passed');
}
grunt.log.writeln(result.stdout);
done(code === 0);
});
}
function runJestNormally() {
var done = this.async();
run(done);
}
function runJestWithCoverage() {
var done = this.async();
run(done, /* coverage */ true);
}
module.exports = {
normal: runJestNormally,
coverage: runJestWithCoverage,
};