Replace grunt-jest with our own runner
This gives us more control
Paul O’Shannessy committed
Jul 23, 2015 at 17:52 UTC
83c88578e906dc6275db1adb1a6d6084546e55cd
3 files changed
+32
-1
Gruntfile.js
+2
@@ -118,6 +118,8 @@ module.exports = function(grunt) {
118
grunt.registerTask('test', ['jest']);
119
grunt.registerTask('npm:test', ['build', 'npm:pack']);
120
121
+ grunt.registerTask('jest', require('./grunt/tasks/jest'));
122
+
123
// Optimized build task that does all of our builds. The subtasks will be run
124
// in order so we can take advantage of that and only run build-modules once.
125
grunt.registerTask('build', [
grunt/tasks/jest.js
new
+30
@@ -0,0 +1,30 @@
1
+// We run our own grunt task instead of using grunt-jest so that we can have
2
+// more control. Specifically we want to set NODE_ENV and make sure stdio is
3
+// inherited. We also run with --harmony directly so that we don't have to
4
+// respawn immediately. We should be able to reduce some of this complexity
5
+// when jest 0.5 is run on top of iojs.
6
+
7
+'use strict';
8
+
9
+var grunt = require('grunt');
10
+var path = require('path');
11
+
12
+module.exports = function() {
13
+ var done = this.async();
14
+ grunt.log.writeln('running jest (this may take a while)');
15
+ grunt.util.spawn({
16
+ cmd: 'node',
17
+ args: ['--harmony', path.join('node_modules', 'jest-cli', 'bin', 'jest')],
18
+ opts: {stdio: 'inherit', env: {NODE_ENV: 'test'}},
19
+ }, function(err, result, code) {
20
+ if (err) {
21
+ grunt.log.error('jest failed');
22
+ grunt.log.error(err);
23
+ } else {
24
+ grunt.log.ok('jest passed');
25
+ }
26
+ grunt.log.writeln(result.stdout);
27
+
28
+ done(code === 0);
29
+ });
30
+};
package.json
-1
@@ -48,7 +48,6 @@
48
"grunt-compare-size": "^0.4.0",
49
"grunt-contrib-clean": "^0.6.0",
50
"grunt-contrib-compress": "^0.13.0",
51
- "grunt-jest": "^0.1.3",
51
"gulp": "^3.9.0",
52
"gulp-babel": "^5.1.0",
53
"gulp-flatten": "^0.1.0",