From bfbe072a50c53ceb4921450b3c95c7f622e17954 Mon Sep 17 00:00:00 2001 From: michaelw85 Date: Mon, 18 Feb 2019 15:12:05 +0100 Subject: [PATCH] fix(jest task): Return error when tests fail Callback always resolved successfully even when test failed Incorrect data was accessed in result data to determine failure Closes #1052 --- lib/resources/tasks/jest.js | 6 +++--- lib/resources/tasks/jest.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/resources/tasks/jest.js b/lib/resources/tasks/jest.js index 3df63f960..9d4963e56 100644 --- a/lib/resources/tasks/jest.js +++ b/lib/resources/tasks/jest.js @@ -13,9 +13,9 @@ export default (cb) => { process.env.BABEL_TARGET = 'node'; - jest.runCLI(options, [path.resolve(__dirname, '../../')]).then((result) => { - if (result.numFailedTests || result.numFailedTestSuites) { - cb(new PluginError('gulp-jest', { message: 'Tests Failed' })); + jest.runCLI(options, [path.resolve(__dirname, '../../')]).then(({ results }) => { + if (results.numFailedTests || results.numFailedTestSuites) { + cb(new PluginError('jest-cli', { message: 'Tests Failed' })); } else { cb(); } diff --git a/lib/resources/tasks/jest.ts b/lib/resources/tasks/jest.ts index 9e490bfd0..067464aee 100644 --- a/lib/resources/tasks/jest.ts +++ b/lib/resources/tasks/jest.ts @@ -12,9 +12,9 @@ export default (cb) => { Object.assign(options, { watch: true}); } - jest.runCLI(options, [path.resolve(__dirname, '../../')]).then((result) => { - if(result.numFailedTests || result.numFailedTestSuites) { - cb(new PluginError('gulp-jest', { message: 'Tests Failed' })); + jest.runCLI(options, [path.resolve(__dirname, '../../')]).then(({ results }) => { + if (results.numFailedTests || results.numFailedTestSuites) { + cb(new PluginError('jest-cli', { message: 'Tests Failed' })); } else { cb(); }