Skip to content

Commit

Permalink
use stream path
Browse files Browse the repository at this point in the history
  • Loading branch information
Dakuan committed Aug 20, 2014
1 parent 4cc2d1d commit c9352a8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 29 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ var jest = require('jest-cli'),
gutil = require('gulp-util'),
through = require('through2');

module.exports = function (options) {
module.exports = function (options) {
options = options || {};
return through.obj(function (file, enc, cb) {
options.rootDir = options.rootDir || file.path;
try {
jest.runCLI({
config: options
Expand Down
51 changes: 26 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,45 @@
"description": "gulp-jest =========",
"main": "index.js",
"scripts": {
"test": "mocha test.js -t 10000"
"test": "mocha test.js -t 10000"
},
"repository": {
"type": "git",
"url": "git://github.com/Dakuan/gulp-jest.git"
"type": "git",
"url": "git://github.com/Dakuan/gulp-jest.git"
},
"author": {
"name": "Dominic Barker",
"email": "[email protected]",
"url": "http://www.dombarker.co.uk"
"name": "Dominic Barker",
"email": "[email protected]",
"url": "http://www.dombarker.co.uk"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/Dakuan/gulp-jest/issues"
"url": "https://github.com/Dakuan/gulp-jest/issues"
},
"homepage": "https://github.com/Dakuan/gulp-jest",
"dependencies": {
"jest-cli": "^0.1.18",
"gulp-util": "^3.0.0",
"through2": "^0.5.1",
"react-tools": "^0.11.1"
"jest-cli": "^0.1.18",
"gulp-util": "^3.0.0",
"through2": "^0.5.1",
"react-tools": "^0.11.1"
},
"devDependencies": {
"assert": "^1.1.1",
"mocha": "^1.21.3"
"assert": "^1.1.1",
"mocha": "^1.21.3",
"gulp": "^3.8.7"
},
"keywords": [
"gulpplugin",
"jest",
"test",
"testing",
"unit",
"framework",
"runner",
"tdd",
"bdd",
"qunit",
"spec",
"tap"
"gulpplugin",
"jest",
"test",
"testing",
"unit",
"framework",
"runner",
"tdd",
"bdd",
"qunit",
"spec",
"tap"
]
}
22 changes: 19 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
'use strict';
var assert = require('assert');
var gulp = require('gulp')
var gutil = require('gulp-util');
var jest = require('./index');
var through2 = require('through2');
var out = process.stdout.write.bind(process.stdout);

it('should run unit test and pass', function (cb) {
it('should take a rootDir as an option', function (cb) {
var stream = jest({
rootDir: __dirname
rootDir: '__tests__'
});

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

stream.write(new gutil.File({
path: '__tests__/fixture.js',
path: '__tests__',
contents: new Buffer('')
}));

stream.end();
});


it('should use the scream path as the rootDir', function (cb) {
var stream = gulp.src('__tests__')
.pipe(jest());

process.stdout.write = function (str) {
out(str);
if (/test passed/.test(str)) {
assert(true);
process.stdout.write = out;
cb();
}
};
});

0 comments on commit c9352a8

Please sign in to comment.