From c0beda36c6d2fd887d2d4af3681c94d08cd78bdd Mon Sep 17 00:00:00 2001 From: Alan Souza Date: Thu, 2 Nov 2017 14:20:55 -0700 Subject: [PATCH] Fixed weird problem where the fix disappeared --- __tests__/index-test.js | 26 ++++++++++++++------------ package.json | 2 +- src/index.js | 14 ++++++-------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/__tests__/index-test.js b/__tests__/index-test.js index a695dd7..88c30ca 100644 --- a/__tests__/index-test.js +++ b/__tests__/index-test.js @@ -4,11 +4,9 @@ import jest from '../src/index'; it('should pass a test', (done) => { gulp.src('__tests__') .pipe(jest({ - config: { - rootDir: process.cwd(), - testEnvironment: 'node', - testRegex: 'fixture-pass.*-test.js' - } + rootDir: process.cwd(), + testEnvironment: 'node', + testRegex: 'fixture-pass.*-test.js' })) .on('error', (error) => { fail('Test should not fail', error); @@ -18,17 +16,21 @@ it('should pass a test', (done) => { }); it('should fail a test', (done) => { + let failed = false; gulp.src('__tests__') .pipe(jest({ - config: { - rootDir: process.cwd(), - testEnvironment: 'node', - testRegex: 'fixture-fail.*-test.js' - } + rootDir: process.cwd(), + testEnvironment: 'node', + testRegex: 'fixture-fail.*-test.js' })) - .on('error', () => done()) + .on('error', () => { + failed = true; + }) .on('finish', () => { - fail('Test should fail'); + if (!failed) { + fail('Test should fail'); + } + done(); }); }); diff --git a/package.json b/package.json index 37152bd..5d85758 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gulp-jest", - "version": "3.0.0", + "version": "3.0.1", "description": "Gulp plugin for running your Jest tests", "main": "lib/index.js", "scripts": { diff --git a/src/index.js b/src/index.js index e25aa13..71f3c90 100644 --- a/src/index.js +++ b/src/index.js @@ -4,18 +4,16 @@ import through2 from 'through2'; export default (options = {}) => { return through2.obj((file, enc, cb) => { - options = Object.assign({}, options, { - config: Object.assign({ - rootDir: file ? file.path : undefined - }, options.config) - }); + options = Object.assign({ + rootDir: file ? file.path : undefined + }, options); - jest.runCLI(options, [options.config.rootDir], (result) => { - if(result.numFailedTests || result.numFailedTestSuites) { + jest.runCLI(options, [options.rootDir]).then(({ results }) => { + if(results.numFailedTests || results.numFailedTestSuites) { cb(new gutil.PluginError('gulp-jest', { message: 'Tests Failed' })); } else { cb(); } }); - }) + }); };