mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
Split jest task into two
This ensures that we don't make jest do the additional tracking it needs to make coverage work.
This commit is contained in:
@@ -111,10 +111,12 @@ module.exports = function(grunt) {
|
||||
]);
|
||||
grunt.registerTask('build:react-dom', require('./grunt/tasks/react-dom'));
|
||||
|
||||
grunt.registerTask('test', ['jest']);
|
||||
grunt.registerTask('npm:test', ['build', 'npm:pack']);
|
||||
var jestTasks = require('./grunt/tasks/jest');
|
||||
grunt.registerTask('jest:normal', jestTasks.normal);
|
||||
grunt.registerTask('jest:coverage', jestTasks.coverage);
|
||||
|
||||
grunt.registerTask('jest', require('./grunt/tasks/jest'));
|
||||
grunt.registerTask('test', ['jest:normal']);
|
||||
grunt.registerTask('npm:test', ['build', 'npm:pack']);
|
||||
|
||||
// Optimized build task that does all of our builds. The subtasks will be run
|
||||
// in order so we can take advantage of that and only run build-modules once.
|
||||
|
||||
@@ -64,29 +64,48 @@ function writeTempConfig(callback) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = function() {
|
||||
var done = this.async();
|
||||
|
||||
function run(done, configPath) {
|
||||
grunt.log.writeln('running jest (this may take a while)');
|
||||
|
||||
var args = ['--harmony', path.join('node_modules', 'jest-cli', 'bin', 'jest')];
|
||||
if (configPath) {
|
||||
args.push('--config', configPath);
|
||||
}
|
||||
grunt.util.spawn({
|
||||
cmd: 'node',
|
||||
args: args,
|
||||
opts: { stdio: 'inherit', env: { NODE_ENV: 'test' } },
|
||||
}, function(spawnErr, result, code) {
|
||||
if (spawnErr) {
|
||||
onError(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();
|
||||
|
||||
writeTempConfig(function(writeErr) {
|
||||
if (writeErr) {
|
||||
onError(writeErr);
|
||||
return;
|
||||
}
|
||||
grunt.util.spawn({
|
||||
cmd: 'node',
|
||||
args: ['--harmony', path.join('node_modules', 'jest-cli', 'bin', 'jest'), '--config', tempConfigPath],
|
||||
opts: { stdio: 'inherit', env: { NODE_ENV: 'test' } },
|
||||
}, function(spawnErr, result, code) {
|
||||
if (spawnErr) {
|
||||
onError(spawnErr);
|
||||
} else {
|
||||
grunt.log.ok('jest passed');
|
||||
}
|
||||
grunt.log.writeln(result.stdout);
|
||||
|
||||
done(code === 0);
|
||||
});
|
||||
run(done, tempConfigPath);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
normal: runJestNormally,
|
||||
coverage: runJestWithCoverage,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user