Skip to content

Commit 3b9796c

Browse files
committed
Merge pull request Nerajno#1 from Dakuan/db/use-stream-path
use stream path
2 parents 4cc2d1d + 53aeee0 commit 3b9796c

File tree

4 files changed

+51
-39
lines changed

4 files changed

+51
-39
lines changed

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,17 @@ Gulp plugin for the Jest test library
77

88
## Installation
99

10-
As this plugin isn't quite ready it's not been published to NPM, so we need to install from github.
11-
12-
Add to `package.json`
13-
14-
``` json
15-
"gulp-jest": "git+https://github.com/Dakuan/gulp-jest"
10+
``` bash
11+
$ npm install gulp-jest
1612
```
1713

18-
1914
## Usage
2015

2116
``` javascript
2217
var jest = require('gulp-jest');
2318

2419
gulp.task('jest', function () {
25-
return gulp.src('client/js/app.js').pipe(jest({
26-
rootDir: __dirname,
20+
return gulp.src('__tests__').pipe(jest({
2721
scriptPreprocessor: "./spec/support/preprocessor.js",
2822
unmockedModulePathPatterns: [
2923
"node_modules/react"

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ var jest = require('jest-cli'),
44
gutil = require('gulp-util'),
55
through = require('through2');
66

7-
module.exports = function (options) {
7+
module.exports = function (options) {
88
options = options || {};
99
return through.obj(function (file, enc, cb) {
10+
options.rootDir = options.rootDir || file.path;
1011
try {
1112
jest.runCLI({
1213
config: options

package.json

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,48 @@
11
{
22
"name": "gulp-jest",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "gulp-jest =========",
55
"main": "index.js",
66
"scripts": {
7-
"test": "mocha test.js -t 10000"
7+
"test": "mocha test.js -t 10000"
88
},
99
"repository": {
10-
"type": "git",
11-
"url": "git://github.com/Dakuan/gulp-jest.git"
10+
"type": "git",
11+
"url": "git://github.com/Dakuan/gulp-jest.git"
1212
},
1313
"author": {
14-
"name": "Dominic Barker",
15-
"email": "[email protected]",
16-
"url": "http://www.dombarker.co.uk"
14+
"name": "Dominic Barker",
15+
"email": "[email protected]",
16+
"url": "http://www.dombarker.co.uk"
1717
},
1818
"license": "MIT",
1919
"bugs": {
20-
"url": "https://github.com/Dakuan/gulp-jest/issues"
20+
"url": "https://github.com/Dakuan/gulp-jest/issues"
2121
},
2222
"homepage": "https://github.com/Dakuan/gulp-jest",
2323
"dependencies": {
24-
"jest-cli": "^0.1.18",
25-
"gulp-util": "^3.0.0",
26-
"through2": "^0.5.1",
27-
"react-tools": "^0.11.1"
24+
"jest-cli": "^0.1.18",
25+
"gulp-util": "^3.0.0",
26+
"through2": "^0.5.1",
27+
"react-tools": "^0.11.1"
2828
},
2929
"devDependencies": {
30-
"assert": "^1.1.1",
31-
"mocha": "^1.21.3"
30+
"assert": "^1.1.1",
31+
"mocha": "^1.21.3",
32+
"gulp": "^3.8.7"
3233
},
3334
"keywords": [
34-
"gulpplugin",
35-
"jest",
36-
"test",
37-
"testing",
38-
"unit",
39-
"framework",
40-
"runner",
41-
"tdd",
42-
"bdd",
43-
"qunit",
44-
"spec",
45-
"tap"
35+
"gulpplugin",
36+
"jest",
37+
"test",
38+
"testing",
39+
"unit",
40+
"framework",
41+
"runner",
42+
"tdd",
43+
"bdd",
44+
"qunit",
45+
"spec",
46+
"tap"
4647
]
4748
}

test.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
'use strict';
22
var assert = require('assert');
3+
var gulp = require('gulp')
34
var gutil = require('gulp-util');
45
var jest = require('./index');
56
var through2 = require('through2');
67
var out = process.stdout.write.bind(process.stdout);
78

8-
it('should run unit test and pass', function (cb) {
9+
it('should take a rootDir as an option', function (cb) {
910
var stream = jest({
10-
rootDir: __dirname
11+
rootDir: '__tests__'
1112
});
1213

1314
process.stdout.write = function (str) {
@@ -20,9 +21,24 @@ it('should run unit test and pass', function (cb) {
2021
};
2122

2223
stream.write(new gutil.File({
23-
path: '__tests__/fixture.js',
24+
path: '__tests__',
2425
contents: new Buffer('')
2526
}));
2627

2728
stream.end();
2829
});
30+
31+
32+
it('should use the scream path as the rootDir', function (cb) {
33+
var stream = gulp.src('__tests__')
34+
.pipe(jest());
35+
36+
process.stdout.write = function (str) {
37+
out(str);
38+
if (/test passed/.test(str)) {
39+
assert(true);
40+
process.stdout.write = out;
41+
cb();
42+
}
43+
};
44+
});

0 commit comments

Comments
 (0)