Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

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.26
to
1.0.27
+160
lib/jasmine-node/cs.js
/**
* @license cs 0.4.2 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/require-cs for details
*/
/*jslint */
/*global define, window, XMLHttpRequest, importScripts, Packages, java,
ActiveXObject, process, require */
define(['coffee-script'], function (CoffeeScript) {
'use strict';
var fs, getXhr,
progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'],
fetchText = function () {
throw new Error('Environment unsupported.');
},
buildMap = {};
if (typeof process !== "undefined" &&
process.versions &&
!!process.versions.node) {
//Using special require.nodeRequire, something added by r.js.
fs = require.nodeRequire('fs');
fetchText = function (path, callback) {
callback(fs.readFileSync(path, 'utf8'));
};
} else if ((typeof window !== "undefined" && window.navigator && window.document) || typeof importScripts !== "undefined") {
// Browser action
getXhr = function () {
//Would love to dump the ActiveX crap in here. Need IE 6 to die first.
var xhr, i, progId;
if (typeof XMLHttpRequest !== "undefined") {
return new XMLHttpRequest();
} else {
for (i = 0; i < 3; i++) {
progId = progIds[i];
try {
xhr = new ActiveXObject(progId);
} catch (e) {}
if (xhr) {
progIds = [progId]; // so faster next time
break;
}
}
}
if (!xhr) {
throw new Error("getXhr(): XMLHttpRequest not available");
}
return xhr;
};
fetchText = function (url, callback) {
var xhr = getXhr();
xhr.open('GET', url, true);
xhr.onreadystatechange = function (evt) {
//Do not explicitly handle errors, those should be
//visible via console output in the browser.
if (xhr.readyState === 4) {
callback(xhr.responseText);
}
};
xhr.send(null);
};
// end browser.js adapters
} else if (typeof Packages !== 'undefined') {
//Why Java, why is this so awkward?
fetchText = function (path, callback) {
var encoding = "utf-8",
file = new java.io.File(path),
lineSeparator = java.lang.System.getProperty("line.separator"),
input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), encoding)),
stringBuffer, line,
content = '';
try {
stringBuffer = new java.lang.StringBuffer();
line = input.readLine();
// Byte Order Mark (BOM) - The Unicode Standard, version 3.0, page 324
// http://www.unicode.org/faq/utf_bom.html
// Note that when we use utf-8, the BOM should appear as "EF BB BF", but it doesn't due to this bug in the JDK:
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058
if (line && line.length() && line.charAt(0) === 0xfeff) {
// Eat the BOM, since we've already found the encoding on this file,
// and we plan to concatenating this buffer with others; the BOM should
// only appear at the top of a file.
line = line.substring(1);
}
stringBuffer.append(line);
while ((line = input.readLine()) !== null) {
stringBuffer.append(lineSeparator);
stringBuffer.append(line);
}
//Make sure we return a JavaScript string and not a Java string.
content = String(stringBuffer.toString()); //String
} finally {
input.close();
}
callback(content);
};
}
return {
get: function () {
return CoffeeScript;
},
write: function (pluginName, name, write) {
if (buildMap.hasOwnProperty(name)) {
var text = buildMap[name];
write.asModule(pluginName + "!" + name, text);
}
},
version: '0.4.2',
load: function (name, parentRequire, load, config) {
var path = parentRequire.toUrl(name + '.coffee');
fetchText(path, function (text) {
//Do CoffeeScript transform.
try {
text = CoffeeScript.compile(text, config.CoffeeScript);
}
catch (err) {
err.message = "In " + path + ", " + err.message;
throw(err);
}
//Hold on to the transformed text if a build.
if (config.isBuild) {
buildMap[name] = text;
}
//IE with conditional comments on cannot handle the
//sourceURL trick, so skip it if enabled.
/*@if (@_jscript) @else @*/
if (!config.isBuild) {
text += "\r\n//@ sourceURL=" + path;
}
/*@end@*/
load.fromText(name, text);
//Give result to load. Need to wait until the module
//is fully parse, which will happen after this
//execution.
parentRequire([name], function (value) {
load(value);
});
});
}
};
});
define ->
name: 'CoffeeScript To Test'
method: (input) -> 2 * input
require [ "cs!requirecs.sut" ], (sut) ->
describe "RequireJs basic tests with spec and sut in CoffeeScript", ->
it "should load coffeescript sut", ->
expect(sut.name).toBe "CoffeeScript To Test"
expect(sut.method(2)).toBe 4
require [ "requirejs.sut" ], (sut) ->
describe "RequireJs basic tests with spec in CoffeeScript", ->
it "should load javascript sut", ->
expect(sut.name).toBe "Subject To Test"
expect(sut.method(2)).toBe 3
+2
-1

@@ -44,3 +44,4 @@ var walkdir = require('walkdir');

if(!path.existsSync(file)) {
var existsSync = fs.existsSync || path.existsSync;
if(!existsSync(file)) {
watcher.close();

@@ -47,0 +48,0 @@ return;

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

if(!Path.existsSync(dir))
var existsSync = fs.existsSync || path.existsSync;
if(!existsSync(dir))
throw new Error("Test root path '" + dir + "' doesn't exist!");

@@ -96,2 +97,5 @@

default:
if (arg.match(/^--params=.*/)) {
break;
}
if (arg.match(/^--/)) help();

@@ -145,11 +149,16 @@ if (arg.match(/^\/.*/)) {

jasmine.executeSpecsInFolder(specFolder,
onComplete,
isVerbose,
showColors,
teamcity,
useRequireJs,
regExpSpec,
junitreport);
var options = {
specFolder: specFolder,
onComplete: onComplete,
isVerbose: isVerbose,
showColors: showColors,
teamcity: teamcity,
useRequireJs: useRequireJs,
regExpSpec: regExpSpec,
junitreport: junitreport
}
jasmine.executeSpecsInFolder(options);
function help(){

@@ -156,0 +165,0 @@ util.print([

@@ -12,8 +12,11 @@ var fs = require('fs');

var filename = __dirname + '/jasmine-2.0.0.rc1.js';
global.window = {
setTimeout: setTimeout,
clearTimeout: clearTimeout,
setInterval: setInterval,
clearInterval: clearInterval
};
var isWindowUndefined = typeof global.window === 'undefined';
if (isWindowUndefined) {
global.window = {
setTimeout: setTimeout,
clearTimeout: clearTimeout,
setInterval: setInterval,
clearInterval: clearInterval
};
}

@@ -32,3 +35,5 @@ var src = fs.readFileSync(filename);

delete global.window;
if (isWindowUndefined) {
delete global.window;
}
require("./async-callback");

@@ -66,14 +71,16 @@ require("jasmine-reporters");

jasmine.executeSpecsInFolder = function(folder,
done,
isVerbose,
showColors,
teamcity,
useRequireJs,
matcher,
junitreport){
jasmine.executeSpecsInFolder = function(options){
var folder = options['specFolder'];
var done = options['onComplete'];
var isVerbose = options['isVerbose'];
var showColors = options['showColors'];
var teamcity = options['teamcity'];
var useRequireJs = options['useRequireJs'];
var matcher = options['regExpSpec'];
var junitreport = options['junitreport'];
var fileMatcher = matcher || new RegExp(".(js)$", "i"),
colors = showColors || false,
specs = require('./spec-collection'),
jasmineEnv = jasmine.getEnv();
jasmineEnv = jasmine.currentEnv_ = new jasmine.Env();

@@ -83,3 +90,4 @@ specs.load(folder, fileMatcher);

if(junitreport && junitreport.report) {
if(!path.existsSync(junitreport.savePath)) {
var existsSync = fs.existsSync || path.existsSync;
if(!existsSync(junitreport.savePath)) {
util.puts('creating junit xml report save path: ' + junitreport.savePath);

@@ -117,2 +125,3 @@ fs.mkdirSync(junitreport.savePath, "0755");

var filename = specsList[i];
delete require.cache[filename.path()];
require(filename.path().replace(/\.\w+$/, ""));

@@ -119,0 +128,0 @@ }

@@ -162,3 +162,3 @@ (function() {

var failure = {
spec: spec.description,
spec: spec.suite.getFullName() + " " + spec.description,
message: failureItem.message,

@@ -165,0 +165,0 @@ stackTrace: failureItem.trace.stack

@@ -7,2 +7,3 @@ exports.executeJsRunner = function(specCollection, done, jasmineEnv) {

fs = require('fs'),
coffeescript = require('coffee-script'),
template = fs.readFileSync(__dirname + '/requirejs-wrapper-template.js', 'utf8'),

@@ -70,2 +71,5 @@ buildNewContext = function(spec){

if (s.filename().substr(-6).toLowerCase() == 'coffee') {
script = coffeescript.compile(script);
}
for(var i = 0; i < (colonMatches && colonMatches.length) || 0; i++){

@@ -76,3 +80,4 @@ dir = dir.replace(colonMatches[i], '/' + colonMatches[i].substring(0,1));

wrappedScript = template.replace(/#REPLACE URL#/, buildRelativeDirName(dir))
.replace(/#REPLACE TEST SCRIPT#/, script);
.replace(/#REPLACE TEST SCRIPT#/, script)
.replace(/#REPLACE REQUIRE-CS PATH#/, __dirname + '/cs');

@@ -79,0 +84,0 @@ vm.runInNewContext(wrappedScript, buildNewContext(s), s.path());

@@ -32,3 +32,6 @@ var test = function(require, define, undefined) { #REPLACE TEST SCRIPT#

baseUrl: baseUrl,
nodeRequire: require
nodeRequire: require,
paths: {
cs: '#REPLACE REQUIRE-CS PATH#'
}
});

@@ -35,0 +38,0 @@

var walkdir = require('walkdir');
var path = require('path');
var fs = require('fs');
var specs = [];
var specs;

@@ -18,2 +18,3 @@ var createSpecObj = function(path, root) {

var wannaBeSpecs = walkdir.sync(loadpath)
specs = [];

@@ -24,3 +25,4 @@ for (var i = 0; i < wannaBeSpecs.length; i++) {

if (fs.statSync(file).isFile()) {
if (!/.*node_modules.*/.test(file) && matcher.test(path.basename(file))) {
if (!/.*node_modules.*/.test(path.relative(loadpath, file)) &
matcher.test(path.basename(file))) {
specs.push(createSpecObj(file));

@@ -36,3 +38,8 @@ }

exports.getSpecs = function() {
// Sorts spec paths in ascending alphabetical order to be able to
// run tests in a deterministic order.
specs.sort(function(a, b) {
return a.path().localeCompare(b.path());
});
return specs;
};
{
"name" : "jasmine-node"
, "version" : "1.0.26"
, "version" : "1.0.27"
, "description" : "DOM-less simple JavaScript BDD testing framework for Node"

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

, "bin" : "bin/jasmine-node"
, "preferGlobal" : true
, "main" : "lib/jasmine-node"
, "scripts" : { "test" : "node lib/jasmine-node/cli.js spec" }
}

@@ -24,3 +24,3 @@ jasmine-node

jasmine-node
jasmine-node spec/

@@ -27,0 +27,0 @@ If you aren't using npm, you should add `pwd`/lib to the $NODE_PATH

@@ -86,3 +86,5 @@ var jasmineNode = require(__dirname + "/../lib/jasmine-node/reporter").jasmineNode;

it('sets the startedAt field', function() {
expect(this.reporter.startedAt instanceof Date).toBeTruthy();
// instanceof does not work cross-context (such as when run with requirejs)
var ts = Object.prototype.toString;
expect(ts.call(this.reporter.startedAt)).toBe(ts.call(new Date()));
});

@@ -201,2 +203,5 @@

var spec = {
suite: {
getFullName: function() { return 'Suite name' }
},
description: 'the spec',

@@ -227,3 +232,3 @@ results: function() {

var failure = failures[0];
expect(failure.spec).toEqual('the spec');
expect(failure.spec).toEqual('Suite name the spec');
expect(failure.message).toEqual('the message');

@@ -230,0 +235,0 @@ expect(failure.stackTrace).toEqual('the stack');

@@ -25,1 +25,8 @@ #!/usr/bin/env bash

echo -e "\033[1;35m--- Should have 41 tests and 76 assertions and 1 Failure. ---\033[0m"
echo ""
echo "Running all tests located in the spec-requirejs directory with requirejs and coffee option"
command=$entry"--runWithRequireJs --coffee spec-requirejs"
echo $command
time $command
echo -e "\033[1;35m--- Should have 3 tests and 6 assertions and 0 Failure. ---\033[0m"

Sorry, the diff of this file is not supported yet