Skip to content

Commit

Permalink
Fixed weird problem where the fix disappeared
Browse files Browse the repository at this point in the history
  • Loading branch information
alansouzati committed Nov 2, 2017
1 parent b6f445d commit c0beda3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
26 changes: 14 additions & 12 deletions __tests__/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
14 changes: 6 additions & 8 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
})
});
};

0 comments on commit c0beda3

Please sign in to comment.