Socket
Socket
Sign inDemoInstall

jasmine-node

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jasmine-node - npm Package Compare versions

Comparing version 1.0.15 to 1.0.16

lib/jasmine-node/requirejs-wrapper-template.js

14

lib/jasmine-node/cli.js

@@ -21,3 +21,4 @@ var jasmine = require('./index');

var extentions = "js";
var match = '.'
var match = '.';
var useHelpers = true;

@@ -65,2 +66,5 @@ var junitreport = {

break;
case '--nohelpers':
useHelpers = false;
break;
case '--test-dir':

@@ -105,4 +109,7 @@ var dir = args.shift();

jasmine.loadHelpersInFolder(specFolder,
new RegExp("[-_]helper\\.(" + extentions + ")$"));
if(useHelpers){
jasmine.loadHelpersInFolder(specFolder,
new RegExp("[-_]helper\\.(" + extentions + ")$"));
}
jasmine.executeSpecsInFolder(specFolder,

@@ -131,2 +138,3 @@ onComplete,

, ' --test-dir - the absolute root directory path where tests are located'
, ' --nohelpers - does not load helpers.'
, ' -h, --help - display this help and exit'

@@ -133,0 +141,0 @@ , ''

@@ -43,3 +43,3 @@ var fs = require('fs');

helperCollection.load(folder, matcher);
helpers = helperCollection.getSpecPaths();
helpers = helperCollection.getSpecs();

@@ -107,3 +107,3 @@ for (var i = 0, len = helpers.length; i < len; ++i)

} else {
var specsList = specs.getSpecPaths();
var specsList = specs.getSpecs();

@@ -110,0 +110,0 @@ for (var i = 0, len = specsList.length; i < len; ++i) {

@@ -5,20 +5,67 @@ exports.executeJsRunner = function(specCollection, done, jasmineEnv) {

requirejs = require('requirejs'),
fs = require('fs');
vm = require('vm'),
fs = require('fs'),
template = fs.readFileSync(__dirname + '/requirejs-wrapper-template.js', 'utf8'),
buildNewContext = function(){
return {
describe: describe,
it: it,
xdescribe: xdescribe,
xit: xit,
jasmine: jasmine,
expect: expect,
require: require,
console: console,
process: process,
module: module,
specLoader: specLoader
};
},
buildRelativeDirName = function(dir){
var retVal = "",
thisDir = process.cwd();//.replace(/.:/, '\\c').split('\\'),
toDir = dir.split('/'),
index = 0,
colonMatches = __dirname.match(/.:/);
specs = specCollection.getRelativeSpecPaths();
for(var i = 0; i < colonMatches.length; i++){
thisDir = thisDir.replace(colonMatches[i], '\\' + colonMatches[i].substring(0,1));
}
process.chdir(specCollection.getRootPath());
thisDir = thisDir.split('\\');
requirejs.config({
baseUrl: './',
nodeRequire: require
});
for(; index < thisDir.length || index < toDir.length; index++) {
if(thisDir[index] != toDir[index]){
for(var i = index; i < thisDir.length; i++){
retVal += '../';
}
specLoader.defineLoader(requirejs);
for(var i = index; i < toDir.length; i++){
retVal += toDir[i] + '/';
}
for (var i = 0, len = specs.length; i < len; i++) {
requirejs(specs[i]);
}
break;
}
}
return retVal.trim('/');
};
specCollection.getSpecs().forEach(function(s){
var script = fs.readFileSync(s.path(), 'utf8'),
dir = s.directory(),
colonMatches = dir.match(/.:/),
wrappedScript;
for(var i = 0; i < colonMatches.length; i++){
dir = dir.replace(colonMatches[i], '/' + colonMatches[i].substring(0,1));
}
wrappedScript = template.replace(/#REPLACE URL#/, buildRelativeDirName(dir))
.replace(/#REPLACE TEST SCRIPT#/, script);
vm.runInNewContext(wrappedScript, buildNewContext(), s.path());
});
specLoader.executeWhenAllSpecsAreComplete(jasmineEnv);
};

@@ -1,3 +0,26 @@

var collection = (function() {
var fs = require('fs'),
createSpecObj = function(path, root) {
return {
path: function() { return path; },
relativePath: function() { return path.replace(root, '').replace(/^[\/\\]/, ''); },
directory: function() { return path.replace(/[\/\\][\s\w\.-]*$/, ""); },
relativeDirectory: function() { return relativePath().replace(/[\/\\][\s\w\.-]*$/, ""); },
filename: function() { return path.replace(/^.*[\\\/]/, ''); }
};
},
getFiles = function(dir) {
if(isDir(dir)){
try {
return fs.readdirSync(dir);
} catch (err) {
if(err.code === 'ENOENT') {
return [];
} else {
throw err;
}
}
} else {
return [];
}
},
isFile = function(path) {

@@ -39,9 +62,9 @@ var isFile = false;

},
getAllSpecFiles = function(path, matcher) {
getAllSpecFiles = function(path, matcher, root) {
var specs = [];
if (fs.statSync(path).isFile() && path.match(matcher)) {
specs.push(path);
} else {
var files = fs.readdirSync(path);
if (isFile(path) && path.match(matcher)) {
specs.push(createSpecObj(path, root));
} else if(isDir(path)) {
var files = getFiles(path);

@@ -52,3 +75,3 @@ for (var i = 0, len = files.length; i < len; i++) {

if(isFile(filename) && filename.match(matcher)) {
specs.push(filename);
specs.push(createSpecObj(filename, root));
} else if (isDir(filename)) {

@@ -66,35 +89,20 @@ var subFiles = getAllSpecFiles(filename, matcher);

},
specs = [],
relativeSpecs = [],
root,
publicExposure = {
load: function(path, matcher) {
specs = getAllSpecFiles(path, matcher);
specs = [];
if (fs.statSync(path).isDirectory()) {
root = path;
} else {
root = path.replace(/[\/\\][\s\w\.-]*$/, "");
}
exports.load = function(path, matcher) {
var root;
for (var i = 0, len = specs.length; i < len; i++) {
relativeSpecs.push(specs[i].replace(root, '').replace(/^[\/\\]/, ''));
}
},
getRootPath: function() {
return root;
},
getRelativeSpecPaths: function() {
return relativeSpecs;
},
getSpecPaths: function() {
return specs;
}
};
if (isDir(path)) {
root = path;
} else {
root = path.replace(/[\/\\][\s\w\.-]*$/, "");
}
return publicExposure;
})();
getAllSpecFiles(path, matcher, root).forEach(function(s){
specs.push(s);
});
};
for (var key in collection) {
exports[key] = collection[key];
}
exports.getSpecs = function() {
return specs;
};
{
"name" : "jasmine-node"
, "version" : "1.0.15"
, "version" : "1.0.16"
, "description" : "DOM-less simple JavaScript BDD testing framework for Node"

@@ -5,0 +5,0 @@ , "homepage" : [ "http://pivotal.github.com/jasmine"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc