Skip to content

Commit c0beda3

Browse files
committed
Fixed weird problem where the fix disappeared
1 parent b6f445d commit c0beda3

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

__tests__/index-test.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ import jest from '../src/index';
44
it('should pass a test', (done) => {
55
gulp.src('__tests__')
66
.pipe(jest({
7-
config: {
8-
rootDir: process.cwd(),
9-
testEnvironment: 'node',
10-
testRegex: 'fixture-pass.*-test.js'
11-
}
7+
rootDir: process.cwd(),
8+
testEnvironment: 'node',
9+
testRegex: 'fixture-pass.*-test.js'
1210
}))
1311
.on('error', (error) => {
1412
fail('Test should not fail', error);
@@ -18,17 +16,21 @@ it('should pass a test', (done) => {
1816
});
1917

2018
it('should fail a test', (done) => {
19+
let failed = false;
2120
gulp.src('__tests__')
2221
.pipe(jest({
23-
config: {
24-
rootDir: process.cwd(),
25-
testEnvironment: 'node',
26-
testRegex: 'fixture-fail.*-test.js'
27-
}
22+
rootDir: process.cwd(),
23+
testEnvironment: 'node',
24+
testRegex: 'fixture-fail.*-test.js'
2825
}))
29-
.on('error', () => done())
26+
.on('error', () => {
27+
failed = true;
28+
})
3029
.on('finish', () => {
31-
fail('Test should fail');
30+
if (!failed) {
31+
fail('Test should fail');
32+
}
33+
3234
done();
3335
});
3436
});

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gulp-jest",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "Gulp plugin for running your Jest tests",
55
"main": "lib/index.js",
66
"scripts": {

src/index.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ import through2 from 'through2';
44

55
export default (options = {}) => {
66
return through2.obj((file, enc, cb) => {
7-
options = Object.assign({}, options, {
8-
config: Object.assign({
9-
rootDir: file ? file.path : undefined
10-
}, options.config)
11-
});
7+
options = Object.assign({
8+
rootDir: file ? file.path : undefined
9+
}, options);
1210

13-
jest.runCLI(options, [options.config.rootDir], (result) => {
14-
if(result.numFailedTests || result.numFailedTestSuites) {
11+
jest.runCLI(options, [options.rootDir]).then(({ results }) => {
12+
if(results.numFailedTests || results.numFailedTestSuites) {
1513
cb(new gutil.PluginError('gulp-jest', { message: 'Tests Failed' }));
1614
} else {
1715
cb();
1816
}
1917
});
20-
})
18+
});
2119
};

0 commit comments

Comments
 (0)