Skip to content

Commit

Permalink
fix(jest task): Return error when tests fail
Browse files Browse the repository at this point in the history
Callback always resolved successfully even when test failed
Incorrect data was accessed in result data to determine failure

Closes #1052
  • Loading branch information
michaelw85 committed Feb 18, 2019
1 parent 1455a35 commit bfbe072
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/resources/tasks/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
6 changes: 3 additions & 3 deletions lib/resources/tasks/jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit bfbe072

Please sign in to comment.