jasmine-node
Advanced tools
Comparing version 1.0.27 to 1.0.28
@@ -72,4 +72,12 @@ var jasmine = require('./index'); | ||
break; | ||
case '--requireJsSetup': | ||
var setup = args.shift(); | ||
if(!Path.existsSync(setup)) | ||
throw new Error("RequireJS setup '" + setup + "' doesn't exist!"); | ||
useRequireJs = setup; | ||
break; | ||
case '--runWithRequireJs': | ||
useRequireJs = true; | ||
useRequireJs = useRequireJs || true; | ||
break; | ||
@@ -178,2 +186,3 @@ case '--nohelpers': | ||
, ' --runWithRequireJs - loads all specs using requirejs instead of node\'s native require method' | ||
, ' --requireJsSetup - file run before specs to include and configure RequireJS' | ||
, ' --test-dir - the absolute root directory path where tests are located' | ||
@@ -180,0 +189,0 @@ , ' --nohelpers - does not load helpers.' |
@@ -115,3 +115,8 @@ var fs = require('fs'); | ||
if (useRequireJs) { | ||
require('./requirejs-runner').executeJsRunner(specs, done, jasmineEnv); | ||
require('./requirejs-runner').executeJsRunner( | ||
specs, | ||
done, | ||
jasmineEnv, | ||
typeof useRequireJs === 'string' ? useRequireJs : null | ||
); | ||
} else { | ||
@@ -118,0 +123,0 @@ var specsList = specs.getSpecs(); |
@@ -1,2 +0,2 @@ | ||
exports.executeJsRunner = function(specCollection, done, jasmineEnv) { | ||
exports.executeJsRunner = function(specCollection, done, jasmineEnv, setupFile) { | ||
var specs, | ||
@@ -8,3 +8,9 @@ specLoader = require('./requirejs-spec-loader'), | ||
coffeescript = require('coffee-script'), | ||
template = fs.readFileSync(__dirname + '/requirejs-wrapper-template.js', 'utf8'), | ||
template = fs.readFileSync( | ||
setupFile || (__dirname + '/requirejs-wrapper-template.js'), | ||
'utf8' | ||
), | ||
ensureUnixPath = function(path){ | ||
return path.replace(/^(.):/, '/$1').replace(/\\/g, '/'); | ||
}, | ||
buildNewContext = function(spec){ | ||
@@ -28,3 +34,5 @@ var context = { | ||
__dirname: spec.directory(), | ||
__filename: spec.path() | ||
__filename: spec.path(), | ||
baseUrl: buildRelativeDirName(spec.directory()), | ||
csPath: __dirname + '/cs' | ||
}; | ||
@@ -38,13 +46,8 @@ | ||
var retVal = "", | ||
thisDir = process.cwd(), | ||
toDir = dir.split('/'), | ||
index = 0, | ||
colonMatches = __dirname.match(/^.:/); | ||
thisDir = ensureUnixPath(process.cwd()), | ||
toDir = ensureUnixPath(dir).split('/'), | ||
index = 0; | ||
for(var i = 0; i < (colonMatches && colonMatches.length) || 0; i++){ | ||
thisDir = thisDir.replace(colonMatches[i], '\\' + colonMatches[i].substring(0,1)); | ||
} | ||
thisDir = thisDir.split('/'); | ||
thisDir = thisDir.replace(/\\/g, '/').split('/'); | ||
for(; index < thisDir.length || index < toDir.length; index++) { | ||
@@ -69,4 +72,2 @@ if(thisDir[index] != toDir[index]){ | ||
var script = fs.readFileSync(s.path(), 'utf8'), | ||
dir = s.directory(), | ||
colonMatches = dir.match(/.:/), | ||
wrappedScript; | ||
@@ -77,9 +78,4 @@ | ||
} | ||
for(var i = 0; i < (colonMatches && colonMatches.length) || 0; i++){ | ||
dir = dir.replace(colonMatches[i], '/' + colonMatches[i].substring(0,1)); | ||
} | ||
wrappedScript = template.replace(/#REPLACE URL#/, buildRelativeDirName(dir)) | ||
.replace(/#REPLACE TEST SCRIPT#/, script) | ||
.replace(/#REPLACE REQUIRE-CS PATH#/, __dirname + '/cs'); | ||
wrappedScript = template + script; | ||
@@ -86,0 +82,0 @@ vm.runInNewContext(wrappedScript, buildNewContext(s), s.path()); |
@@ -1,8 +0,17 @@ | ||
var test = function(require, define, undefined) { #REPLACE TEST SCRIPT# | ||
}; | ||
var requirejsOrig = require('requirejs'), | ||
/* Setup file run before spec files to setup the context (and RequireJS | ||
* specifically) to execute the spec file. | ||
* | ||
* Defined by caller: | ||
* - Jasmine predefines | ||
* - require (Node require) | ||
* - __dirname, __filename | ||
* - baseUrl (Relative path to the directory containing this file) | ||
* - csPath (Path to require-cs module) | ||
* | ||
* See requirejs-runner source for full invocation details. | ||
*/ | ||
var define, | ||
requirejsOrig = require('requirejs'), | ||
ostring = Object.prototype.toString, | ||
path = require('path'), | ||
baseUrl = '#REPLACE URL#', | ||
isArray = function(it){ | ||
@@ -34,3 +43,3 @@ return ostring.call(it) === '[object Array]'; | ||
paths: { | ||
cs: '#REPLACE REQUIRE-CS PATH#' | ||
cs: csPath | ||
} | ||
@@ -69,2 +78,3 @@ }); | ||
test(requirejs, requirejs.define); | ||
require = requirejs; | ||
define = requirejs.define; |
{ | ||
"name" : "jasmine-node" | ||
, "version" : "1.0.27" | ||
, "version" : "1.0.28" | ||
, "description" : "DOM-less simple JavaScript BDD testing framework for Node" | ||
@@ -5,0 +5,0 @@ , "homepage" : [ "http://pivotal.github.com/jasmine" |
@@ -7,3 +7,7 @@ require(['requirejs.sut'], function(sut){ | ||
}); | ||
it('should run setup', function(){ | ||
expect(typeof setupHasRun).toBe('boolean'); | ||
}); | ||
}); | ||
}); |
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
131307
38
3741
15
2