jasmine-node
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -6,2 +6,4 @@ var walkdir = require('walkdir'); | ||
var child_process = require('child_process'); | ||
var gaze = require('gaze'); | ||
var _ = require('underscore'); | ||
@@ -32,3 +34,3 @@ var baseArgv = []; | ||
var argv = [].concat(baseArgv); | ||
run_external(argv.shift(), argv, function() { console.log(arguments) }); | ||
run_external(argv.shift(), argv); | ||
} | ||
@@ -38,54 +40,42 @@ | ||
var watchFile = function(file, stat) { | ||
exports.start = function(loadpath, pattern) { | ||
var file = path.normalize(file) | ||
// If loadpath is just a single file, we should just watch that file | ||
stats = fs.statSync(loadpath); | ||
if (stats.isFile()) { | ||
console.log(loadpath); | ||
pattern = loadpath; | ||
} | ||
var prevStats = stat; | ||
var watcher = fs.watch(file, function(ev) { | ||
changedFunc = function(file) { | ||
console.log(file + ' was changed'); | ||
var existsSync = fs.existsSync || path.existsSync; | ||
if(!existsSync(file)) { | ||
watcher.close(); | ||
return; | ||
} | ||
var match = path.basename(file, path.extname(file)) + ".*"; | ||
match = match.replace(new RegExp("spec", "i"), ""); | ||
var currStats = fs.statSync( file ); | ||
if(prevStats.mtime.getTime() != currStats.mtime.getTime()) { | ||
prevStats = currStats; | ||
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; | ||
} | ||
}); | ||
} | ||
// narrow down a pattern to reduce the specs runned | ||
var match = path.basename(file, path.extname(file)) + ".*"; | ||
match = match.replace(new RegExp("spec", "i"), ""); | ||
// Vim seems to change a file multiple times, with non-scientific testing | ||
// the only time we didn't duplicate the call to onChanged was at 2.5s | ||
// Passing true to have onChanged run on the leading edge of the timeout | ||
var onChanged = _.debounce(changedFunc, 2500, true); | ||
// 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; | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
gaze(pattern, function(err, watcher) { | ||
// Get all watched files | ||
console.log("Watching for changes"); | ||
exports.start = function(loadpath, pattern) { | ||
var finder = walkdir.find(loadpath); | ||
finder.on('file', function(file, stat) { | ||
var basename = path.basename(file); | ||
if(pattern.test(basename)) { | ||
watchFile(file,stat); | ||
} | ||
// On file changed | ||
this.on('changed', onChanged); | ||
}); | ||
@@ -92,0 +82,0 @@ |
@@ -1,5 +0,8 @@ | ||
var jasmine = require('./index'); | ||
var util, | ||
Path= require('path'), | ||
fs = require('fs'); | ||
var jasmine = require('./index'); | ||
try { | ||
@@ -15,2 +18,5 @@ util = require('util') | ||
// The following line keeps the jasmine setTimeout in the proper scope | ||
jasmine.setTimeout = jasmine.getGlobal().setTimeout; | ||
jasmine.setInterval = jasmine.getGlobal().setInterval; | ||
for (var key in jasmine) | ||
@@ -38,2 +44,3 @@ global[key] = jasmine[key]; | ||
var args = process.argv.slice(2); | ||
var existsSync = fs.existsSync || path.existsSync; | ||
@@ -78,3 +85,3 @@ while(args.length) { | ||
if(!Path.existsSync(setup)) | ||
if(!existsSync(setup)) | ||
throw new Error("RequireJS setup '" + setup + "' doesn't exist!"); | ||
@@ -93,3 +100,2 @@ | ||
var existsSync = fs.existsSync || path.existsSync; | ||
if(!existsSync(dir)) | ||
@@ -127,4 +133,11 @@ throw new Error("Test root path '" + dir + "' doesn't exist!"); | ||
if (autotest) { | ||
require('./autotest').start(specFolder, | ||
new RegExp(".+\\.(" + extentions + ")$", "i")); | ||
//TODO: this is ugly, maybe refactor? | ||
var glob = [Path.join(specFolder, '**/*.js')]; | ||
if (extentions.indexOf("coffee") !== -1) { | ||
glob.push(Path.join(specFolder, '**/*.coffee')); | ||
} | ||
require('./autotest').start(specFolder, glob); | ||
return; | ||
@@ -181,2 +194,3 @@ } | ||
function help(){ | ||
@@ -183,0 +197,0 @@ util.print([ |
@@ -23,13 +23,5 @@ var fs = require('fs'); | ||
var src = fs.readFileSync(filename); | ||
var jasmine; | ||
var minorVersion = process.version.match(/\d\.(\d)\.\d/)[1]; | ||
switch (minorVersion) { | ||
case "1": | ||
case "2": | ||
jasmine = process.compile(src + '\njasmine;', filename); | ||
break; | ||
default: | ||
jasmine = require('vm').runInThisContext(src + "\njasmine;", filename); | ||
} | ||
var jasmine = require('vm').runInThisContext(src + "\njasmine;", filename); | ||
if (isWindowUndefined) { | ||
@@ -43,4 +35,11 @@ delete global.window; | ||
jasmine.loadHelpersInFolder=function(folder, matcher) | ||
{ | ||
// Check to see if the folder is actually a file, if so, back up to the | ||
// parent directory and find some helpers | ||
folderStats = fs.statSync(folder); | ||
if (folderStats.isFile()) { | ||
folder = path.dirname(folder); | ||
} | ||
var helpers = [], | ||
@@ -81,2 +80,6 @@ helperCollection = require('./spec-collection'); | ||
// Overwriting it allows us to handle custom async specs | ||
it = function(desc, func, timeout) { | ||
return jasmine.getEnv().it(desc, func, timeout); | ||
} | ||
var fileMatcher = matcher || new RegExp(".(js)$", "i"), | ||
@@ -83,0 +86,0 @@ colors = showColors || false, |
@@ -161,2 +161,3 @@ (function() { | ||
failureItem = result.items_[i]; | ||
var failure = { | ||
@@ -231,4 +232,5 @@ spec: spec.suite.getFullName() + " " + spec.description, | ||
buildMessagesFromResults_: function(messages, results) { | ||
buildMessagesFromResults_: function(messages, results, depth) { | ||
var element, specResult, specIndentSpaces, msg = ''; | ||
depth = (depth === undefined) ? 0 : depth; | ||
@@ -242,7 +244,6 @@ var results_length = results.length; | ||
specIndentSpaces = this.indent_ + 2; | ||
if (specResult.result === 'passed') { | ||
msg = this.stringWithColor_(this.indentMessage_(element.name, specIndentSpaces), this.color_.pass()); | ||
msg = this.stringWithColor_(this.indentMessage_(element.name, depth), this.color_.pass()); | ||
} else { | ||
msg = this.stringWithColor_(this.indentMessage_(element.name, specIndentSpaces), this.color_.fail()); | ||
msg = this.stringWithColor_(this.indentMessage_(element.name, depth), this.color_.fail()); | ||
} | ||
@@ -252,9 +253,7 @@ | ||
} else { | ||
this.indent_ = element.suiteNestingLevel * 2; | ||
messages.push(''); | ||
messages.push(this.indentMessage_(element.name, this.indent_)); | ||
messages.push(this.indentMessage_(element.name, depth)); | ||
} | ||
this.buildMessagesFromResults_(messages, element.children); | ||
this.buildMessagesFromResults_(messages, element.children, depth + 2); | ||
} | ||
@@ -266,3 +265,3 @@ }, | ||
for (var i = 0; i < indentCount; i++) { | ||
_indent += ' '; | ||
_indent += ' '; | ||
} | ||
@@ -269,0 +268,0 @@ return (_indent + message); |
@@ -77,3 +77,7 @@ exports.executeJsRunner = function(specCollection, done, jasmineEnv, setupFile) { | ||
vm.runInNewContext(wrappedScript, buildNewContext(s), s.path()); | ||
var newContext = buildNewContext(s); | ||
newContext.setTimeout = jasmine.getGlobal().setTimeout; | ||
newContext.setInterval = jasmine.getGlobal().setInterval; | ||
vm.runInNewContext(wrappedScript, newContext, s.path()); | ||
}); | ||
@@ -80,0 +84,0 @@ |
{ | ||
"name" : "jasmine-node" | ||
, "version" : "1.1.0" | ||
, "description" : "DOM-less simple JavaScript BDD testing framework for Node" | ||
, "contributors" : [ "Chris Moultrie <chris@moultrie.org>" ] | ||
, "homepage" : [ "http://pivotal.github.com/jasmine" | ||
, "https://github.com/mhevery/jasmine-node"] | ||
, "repository" : { "type" : "git" | ||
, "url" : "https://github.com/mhevery/jasmine-node.git" | ||
} | ||
, "keywords" : ["testing", "bdd"] | ||
, "author" : "Misko Hevery <misko@hevery.com>" | ||
, "contributors" : [ "Rajan Agaskar <rajan@pivotallabs.com" | ||
, "Christian Williams <xian@pivotallabs.com" | ||
, "Davis W. Frank <dwfrank@pivotallabs.com>" | ||
, "Matteo Collina <matteo.collina@gmail.com>" | ||
] | ||
, "maintainers" : "Martin Häger <martin.haeger@gmail.com>" | ||
, "contributors" : [ "Mike Swift <theycallmeswift@gmail.com> (http://theycallmeswift.com)" ] | ||
, "licenses" : ["MIT"] | ||
, "dependencies" : { "coffee-script" : ">=1.0.1" | ||
, "jasmine-reporters" : ">=0.2.0" | ||
, "requirejs" : ">=0.27.1" | ||
, "walkdir" : ">= 0.0.1" | ||
, "underscore" : ">= 1.3.1" | ||
} | ||
, "bin" : "bin/jasmine-node" | ||
, "preferGlobal" : true | ||
, "main" : "lib/jasmine-node" | ||
, "scripts" : { "test" : "node lib/jasmine-node/cli.js spec" } | ||
"name": "jasmine-node", | ||
"version": "1.2.0", | ||
"description": "DOM-less simple JavaScript BDD testing framework for Node", | ||
"contributors": [ | ||
"Mike Swift <theycallmeswift@gmail.com> (http://theycallmeswift.com)" | ||
], | ||
"homepage": [ | ||
"http://pivotal.github.com/jasmine", | ||
"https://github.com/mhevery/jasmine-node" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mhevery/jasmine-node.git" | ||
}, | ||
"keywords": [ | ||
"testing", | ||
"bdd" | ||
], | ||
"author": "Misko Hevery <misko@hevery.com>", | ||
"maintainers": "Martin Häger <martin.haeger@gmail.com>", | ||
"contributors": [ | ||
"Chris Moultrie <chris@moultrie.org>" | ||
], | ||
"licenses": [ | ||
"MIT" | ||
], | ||
"dependencies": { | ||
"coffee-script": ">=1.0.1", | ||
"jasmine-reporters": ">=0.2.0", | ||
"requirejs": ">=0.27.1", | ||
"walkdir": ">= 0.0.1", | ||
"underscore": ">= 1.3.1", | ||
"gaze": "~0.3.2" | ||
}, | ||
"bin": "bin/jasmine-node", | ||
"preferGlobal": true, | ||
"main": "lib/jasmine-node", | ||
"scripts": { | ||
"test": "node lib/jasmine-node/cli.js spec" | ||
} | ||
} |
@@ -10,6 +10,25 @@ jasmine-node | ||
jasmine | ||
------- | ||
Version 1.3.1 of Jasmine is currently included with node-jasmine. | ||
what's new | ||
---------- | ||
* Jasmine Mock Clock now works! | ||
* Autotest now works! | ||
* Using the latest Jasmine! | ||
* Verbose mode tabs describe blocks much more accurately! | ||
* Now with more exclamation points!! | ||
install | ||
------ | ||
To install the latest official version, use NPM: | ||
npm install jasmine-node -g | ||
To install the latest _bleeding edge_ version, clone this repository and check | ||
out the `beta` branch. | ||
usage | ||
@@ -35,4 +54,3 @@ ------ | ||
* <code>--autotest</code>, provides automatic execution of specs after | ||
each changes | ||
* <code>--autotest</code>, provides automatic execution of specs after each change | ||
* <code>--coffee</code>, allow execution of .coffee specs | ||
@@ -42,6 +60,14 @@ * <code>--color</code>, indicates spec output should uses color to | ||
* <code>--noColor</code>, do not use color in the output | ||
* <code>-m, --match REGEXP</code>, match only specs comtaining "REGEXPspec" | ||
* <code>--matchall</code>, relax requirement of "spec" in spec file names | ||
* <code>--verbose</code>, verbose output as the specs are run | ||
* <code>--junitreport</code>, export tests results as junitreport xml format' | ||
* <code>--junitreport</code>, export tests results as junitreport xml format | ||
* <code>--output FOLDER</code>, defines the output folder for junitreport files | ||
* <code>--teamcity</code>, converts all console output to teamcity custom test runner commands. (Normally auto detected.) | ||
* <code>--runWithRequireJs</code>, loads all specs using requirejs instead of node's native require method | ||
* <code>--requireJsSetup</code>, file run before specs to include and configure RequireJS | ||
* <code>--test-dir</code>, the absolute root directory path where tests are located | ||
* <code>--nohelpers</code>, does not load helpers | ||
* <code>--forceexit</code>, force exit once tests complete | ||
Checkout spec/SampleSpecs.js to see how to use it. | ||
@@ -74,2 +100,14 @@ async tests | ||
Checkout spec/SampleSpecs.js to see how to use it. | ||
requirejs | ||
--------- | ||
There is a sample project in `/spec-requirejs`. It is comprised of: | ||
1. `requirejs-setup.js`, this pulls in our wrapper template (next) | ||
1. `requirejs-wrapper-template`, this builds up requirejs settings | ||
1. `requirejs.sut.js`, this is a __Su__bject To __T__est, something required by requirejs | ||
1. `requirejs.spec.js`, the actual jasmine spec for testing | ||
development | ||
@@ -84,7 +122,9 @@ ----------- | ||
scripts/specs | ||
specs.sh | ||
or | ||
__Note:__ Some tests are designed to fail in the specs.sh. After each of the | ||
individual runs completes, there is a line that lists what the expected | ||
Pass/Assert/Fail count should be. If you add/remove/edit tests, please be sure | ||
to update this with your PR. | ||
scripts/specs --verbose | ||
@@ -94,2 +134,4 @@ changelog | ||
* _1.2.0 - Fixed #149, #152, #171, #181, #195. --autotest now works as expected, jasmine clock now responds to the fake ticking as requested, and removed the path.exists warning_ | ||
* _1.1.1 - Fixed #173, #169 (Blocks were not indented in verbose properly, added more documentation to address #180_ | ||
* _1.1.0 - Updated Jasmine to 1.3.1, fixed fs missing, catching uncaught exceptions, other fixes_ |
@@ -343,3 +343,4 @@ var jasmineNode = require(__dirname + "/../lib/jasmine-node/reporter").jasmineNode; | ||
suiteNestingLevel: 0, | ||
children: [] | ||
children: [], | ||
getFullName: function() { return "A spec"; }, | ||
}; | ||
@@ -394,3 +395,3 @@ | ||
expect(messages.length).toEqual(1); | ||
expect(messages[0]).toEqual(' a spec block'); | ||
expect(messages[0]).toEqual('a spec block'); | ||
}); | ||
@@ -435,6 +436,6 @@ | ||
expect(messages[2]).toEqual(''); | ||
expect(messages[3]).toEqual(' a sub describe block'); | ||
expect(messages[4]).toEqual(' a spec block'); | ||
expect(messages[3]).toEqual(' a sub describe block'); | ||
expect(messages[4]).toEqual(' a spec block'); | ||
}); | ||
}); | ||
}); |
@@ -5,2 +5,56 @@ describe('jasmine-node-flat', function(){ | ||
}); | ||
}); | ||
}); | ||
describe('Testing some characters', function() { | ||
var chars = ['&', '\'', '"', '<', '>']; | ||
for(var i = 0; i < chars.length; i+=1) { | ||
currentChar = chars[i]; | ||
it('should reject ' + currentChar, (function(currentChar) { | ||
expect(false).toEqual(false); | ||
})(currentChar)); | ||
} | ||
}); | ||
describe('Testing waitsfor functionality', function() { | ||
it("Runs and then waitsFor", function() { | ||
runs(function() { | ||
1+1; | ||
}); | ||
waitsFor(function() { | ||
return true === false; | ||
}, "the impossible", 1000); | ||
runs(function() { | ||
expect(true).toBeTruthy(); | ||
}); | ||
}); | ||
}); | ||
describe('root', function () { | ||
describe('nested', function () { | ||
xit('nested statement', function () { | ||
expect(1).toBeTruthy(); | ||
}); | ||
}); | ||
it('root statement', function () { | ||
expect(1).toBeTruthy(); | ||
}); | ||
}); | ||
describe("Top level describe block", function() { | ||
it("first it block in top level describe", function() { | ||
expect(true).toEqual(true); | ||
}); | ||
describe("Second level describe block", function() { | ||
it("first it block in second level describe", function() { | ||
expect(true).toBe(true); | ||
}); | ||
}); | ||
it("second it block in top level describe", function() { | ||
expect(true).toEqual(true); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
140132
39
3918
132
6
+ Addedgaze@~0.3.2
+ Addedfileset@0.1.8(transitive)
+ Addedgaze@0.3.4(transitive)
+ Addedglob@3.2.11(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedlru-cache@2.7.3(transitive)
+ Addedminimatch@0.2.140.3.0(transitive)
+ Addedsigmund@1.0.1(transitive)