Nerajno / gulp-jest

Gulp plugin for the Jest test lib
MIT License
53 stars 43 forks source link

gulp.watch gulp-jest doesn't get file changes #10

Closed sfeldkamp closed 8 years ago

sfeldkamp commented 9 years ago

gulp-jest is working well on it's own, but I want to add it as the first step in my build process that runs automatically from gulp.watch.

When I set it up as below, the watch task break because I'm emitting an 'end' event when a test fails. However, when the next file change is detected, the jest task doesn't receive the new file, it is still holding on to the old version. Is there a way to successfully set gulp-jest up to run under a gulp.watch task?

here is the relevant part of my gulpfile

var gulp = require('gulp');
var jest = require('gulp-jest');

gulp.task('watch', function(){
    return gulp.watch([
      './src/**/*.jsx',
      './src/**/*.js',
      './src/**/*.less',
      './src/**/*.html'
      ], ['jest']);
  });

 gulp.task('jest', function(){
    return gulp
      .src('./src/**/__tests__')
      .pipe(jest(jestConfig).on("error", handleError));
  });

var jestConfig = {
  rootDir:'./src',
  scriptPreprocessor: "<rootDir>/_app/util/preprocessor.js",
  unmockedModulePathPatterns: [
      "node_modules/react"
  ],
  testPathIgnorePatterns: [
      "node_modules",
      "spec/support"
  ],
  moduleFileExtensions: [
      "js",
      "json",
      "jsx"
  ]
};

 function handleError(err) {
    this.emit('end');
  }
yeehaa123 commented 9 years ago

Having the same problem... doing this without the gulp-jest (just using gulp-cli) gives the same result. Guess the problem lies with the preprocessor...

kcrwfrd commented 9 years ago

Don't believe this is an issue with the preprocessor, but with Jest itself. See https://github.com/facebook/jest/issues/222

alansouzati commented 8 years ago

this plugin has been updated to use Jest 15.0.0 I cannot reproduce this issue anymore