jasmine-node
Advanced tools
Comparing version 1.0.20 to 1.0.21
@@ -1,2 +0,1 @@ | ||
var findit = require('findit'); | ||
@@ -34,34 +33,34 @@ var collection = require('./spec-collection'); | ||
exports.start = function(loadpath, pattern) { | ||
var finder = findit.find(loadpath); | ||
var files = []; | ||
var watchFile = function(file, stat) { | ||
finder.on('file', function(file, stat) { | ||
var basename = path.basename(file); | ||
if(pattern.test(basename)) { | ||
fs.watchFile(file, function(prev, curr) { | ||
if(!curr.isFile()) { | ||
fs.unwatchFile(file); | ||
return; | ||
} | ||
if(prev.mtime.getTime() != curr.mtime.getTime()) { | ||
console.log("Changed " + basename); | ||
var file = path.normalize(file) | ||
// narrow down a pattern to reduce the specs runned | ||
var match = path.basename(file, path.extname(file)) + ".*"; | ||
match = match.replace(new RegExp("spec", "i"), ""); | ||
var prevStats = stat; | ||
var watcher = fs.watch(file, function(ev) { | ||
// so we need to rerun the jasmine suite | ||
var argv = [].concat(baseArgv, ["--match", match]); | ||
run_external(argv.shift(), argv, function(code) { | ||
// run everything if we fixed some bugs | ||
if(code == 0) { | ||
if(!last_run_succesful) { | ||
run_everything(); | ||
} | ||
last_run_succesful = true; | ||
} else { | ||
last_run_succesful = false; | ||
} | ||
}); | ||
if(!path.existsSync(file)) { | ||
watcher.close(); | ||
return; | ||
} | ||
var currStats = fs.statSync( file ); | ||
if(prevStats.mtime.getTime() != currStats.mtime.getTime()) { | ||
// narrow down a pattern to reduce the specs runned | ||
var match = path.basename(file, path.extname(file)) + ".*"; | ||
match = match.replace(new RegExp("spec", "i"), ""); | ||
// so we need to rerun the jasmine suite | ||
var argv = [].concat(baseArgv, ["--match", match]); | ||
run_external(argv.shift(), argv, function(code) { | ||
// run everything if we fixed some bugs | ||
if(code == 0) { | ||
if(!last_run_succesful) { | ||
run_everything(); | ||
} | ||
last_run_succesful = true; | ||
} else { | ||
last_run_succesful = false; | ||
} | ||
@@ -71,4 +70,19 @@ }); | ||
}); | ||
} | ||
exports.start = function(loadpath, pattern) { | ||
var finder = findit.find(loadpath); | ||
finder.on('file', function(file, stat) { | ||
var basename = path.basename(file); | ||
if(pattern.test(basename)) { | ||
watchFile(file,stat); | ||
} | ||
}); | ||
run_everything(); | ||
} |
@@ -23,2 +23,3 @@ var jasmine = require('./index'); | ||
var match = '.'; | ||
var matchall = false; | ||
var autotest = false; | ||
@@ -59,5 +60,11 @@ var useHelpers = true; | ||
break; | ||
case '--matchall': | ||
matchall = true; | ||
break; | ||
case '--junitreport': | ||
junitreport.report = true; | ||
break; | ||
case '--output': | ||
junitreport.savePath = args.shift(); | ||
break; | ||
case '--teamcity': | ||
@@ -87,3 +94,7 @@ teamcity = true; | ||
if (arg.match(/^--/)) help(); | ||
specFolder = Path.join(process.cwd(), arg); | ||
if (arg.match(/^\/.*/)) { | ||
specFolder = arg; | ||
} else { | ||
specFolder = Path.join(process.cwd(), arg); | ||
} | ||
break; | ||
@@ -121,4 +132,5 @@ } | ||
var regExpSpec = new RegExp(match + (matchall ? "" : "spec\\.") + "(" + extentions + ")$", 'i') | ||
helperCollection.load(specFolder, new RegExp(match + "spec\\.(" + extentions + ")$", 'i')); | ||
helperCollection.load(specFolder, regExpSpec); | ||
@@ -140,3 +152,3 @@ if(helperCollection.getSpecs().length === 0) { | ||
useRequireJs, | ||
new RegExp(match + "spec\\.(" + extentions + ")$", 'i'), | ||
regExpSpec, | ||
junitreport); | ||
@@ -153,5 +165,7 @@ | ||
, ' -m, --match REGEXP - load only specs containing "REGEXPspec"' | ||
, ' --matchall - relax requirement of "spec" in spec file names' | ||
, ' --verbose - print extra information per each test run' | ||
, ' --coffee - load coffee-script which allows execution .coffee files' | ||
, ' --junitreport - export tests results as junitreport xml format' | ||
, ' --output - defines the output folder for junitreport files' | ||
, ' --teamcity - converts all console output to teamcity custom test runner commands. (Normally auto detected.)' | ||
@@ -158,0 +172,0 @@ , ' --runWithRequireJs - loads all specs using requirejs instead of node\'s native require method' |
@@ -79,3 +79,3 @@ var fs = require('fs'); | ||
if(junitreport.report) { | ||
if(junitreport && junitreport.report) { | ||
if(!path.existsSync(junitreport.savePath)) { | ||
@@ -82,0 +82,0 @@ util.puts('creating junit xml report save path: ' + junitreport.savePath); |
@@ -40,2 +40,4 @@ (function() { | ||
this.callback_ = config.onComplete || false | ||
this.suites_ = []; | ||
@@ -109,2 +111,3 @@ this.specResults_ = {}; | ||
this.finished_ = true; | ||
if(this.callback_) { this.callback_(runner); } | ||
}, | ||
@@ -111,0 +114,0 @@ |
{ | ||
"name" : "jasmine-node" | ||
, "version" : "1.0.20" | ||
, "version" : "1.0.21" | ||
, "description" : "DOM-less simple JavaScript BDD testing framework for Node" | ||
@@ -18,2 +18,3 @@ , "homepage" : [ "http://pivotal.github.com/jasmine" | ||
, "maintainers" : "Martin Häger <martin.haeger@gmail.com>" | ||
, "contributors" : [ "Mike Swift <theycallmeswift@gmail.com> (http://theycallmeswift.com)" ] | ||
, "licenses" : ["MIT"] | ||
@@ -20,0 +21,0 @@ , "dependencies" : { "coffee-script" : ">=1.0.1" |
@@ -51,2 +51,15 @@ var jasmineNode = require(__dirname + "/../lib/jasmine-node/reporter").jasmineNode; | ||
}); | ||
it('sets the callback_ property to false by default', function() { | ||
var config = {} | ||
this.reporter = new jasmineNode.TerminalReporter(config); | ||
expect(this.reporter.callback_).toEqual(false) | ||
}); | ||
it('sets the callback_ property to onComplete if supplied', function() { | ||
var foo = function() { } | ||
var config = { onComplete: foo } | ||
this.reporter = new jasmineNode.TerminalReporter(config); | ||
expect(this.reporter.callback_).toBe(foo) | ||
}); | ||
}); | ||
@@ -128,2 +141,4 @@ | ||
var callbackSpy = spyOn(this.reporter, 'callback_'); | ||
var runner = { | ||
@@ -142,2 +157,3 @@ results: function() { | ||
expect(this.printLineSpy).toHaveBeenCalled(); | ||
expect(callbackSpy).toHaveBeenCalled(); | ||
}); | ||
@@ -144,0 +160,0 @@ }); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
138054
3470