LoginSignup
6
5

More than 5 years have passed since last update.

Using Jest testing from Gulp

Last updated at Posted at 2014-11-01

I didn't find any good solutions searching around for "gulp jest testing", so I'm going to write up what I did.

Solution

var gulp = require('gulp');
var gutil = require('gulp-util');
var jest = require('jest-cli');
var chalk = require('chalk');

gulp.task('test:jest', function (callback) {
  var onComplete = function (result) {
    if (result) {
    } else {
      console.log(chalk.bgRed('!!! Jest tests failed! You should fix them soon. !!!'));
    }
    callback();
  }
  jest.runCLI({}, __dirname, onComplete);
});

Call for critique

Is there even a need to use jest-cli? Is there a simpler way I should do this? I only figured this out from reading jest-cli source code, since there's basically no documentation I found on the actual Jest docs site (or the README on Github).

Reference

I have a silly project on GitHub for basic React stuff that I continually slowly update. Check it out if you please: https://github.com/kimagure/ShowTrackerReact

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5