New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jasmine-reporters

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jasmine-reporters - npm Package Compare versions

Comparing version

to
0.3.0

src/jasmine.tap_reporter.js

26

ext/jasmine-html.js

@@ -37,3 +37,3 @@ jasmine.TrivialReporter = function(doc) {

this.createDom('div', { className: 'logo' },
this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
this.createDom('span', { className: 'title' }, "Jasmine"),
this.createDom('span', { className: 'version' }, runner.env.versionString())),

@@ -74,4 +74,4 @@ this.createDom('div', { className: 'options' },

var self = this;
showPassed.onchange = function(evt) {
if (evt.target.checked) {
showPassed.onclick = function(evt) {
if (showPassed.checked) {
self.outerDiv.className += ' show-passed';

@@ -83,4 +83,4 @@ } else {

showSkipped.onchange = function(evt) {
if (evt.target.checked) {
showSkipped.onclick = function(evt) {
if (showSkipped.checked) {
self.outerDiv.className += ' show-skipped';

@@ -116,3 +116,3 @@ } else {

var status = results.passed() ? 'passed' : 'failed';
if (results.totalCount == 0) { // todo: change this to check results.skipped
if (results.totalCount === 0) { // todo: change this to check results.skipped
status = 'skipped';

@@ -169,3 +169,9 @@ }

var console = jasmine.getGlobal().console;
if (console && console.log) console.log.apply(console, arguments);
if (console && console.log) {
if (console.log.apply) {
console.log.apply(console, arguments);
} else {
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
}
}
};

@@ -185,4 +191,6 @@

if (!paramMap["spec"]) return true;
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
if (!paramMap.spec) {
return true;
}
return spec.getFullName().indexOf(paramMap.spec) === 0;
};

@@ -5,5 +5,5 @@ {

"description": "Reporters for the Jasmine BDD Framework",
"version": "0.2.1",
"version": "0.3.0",
"homepage": "https://github.com/larrymyers/jasmine-reporters",
"maintainers" : "Ben Loveridge <bloveridge@movenetworks.com>",
"maintainers": "Ben Loveridge <bloveridge@gmail.com>",
"repository": {

@@ -13,5 +13,11 @@ "type": "git",

},
"main" : "./src/load_reporters.js",
"main": "./src/load_reporters.js",
"dependencies": {},
"devDependencies": {}
"devDependencies": {},
"licenses": [
{
"type": "MIT",
"url": "https://raw.github.com/larrymyers/jasmine-reporters/master/LICENSE"
}
]
}

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

startGroup(runner.results(), 'tests');
for (var i in suites) {
for (var i=0; i<suites.length; i++) {
if (!suites[i].parentSuite) {

@@ -29,0 +29,0 @@ suiteResults(suites[i]);

(function() {
if (! jasmine) {
throw new Exception("jasmine library does not exist in global namespace!");
if (typeof jasmine == 'undefined') {
throw new Error("jasmine library does not exist in global namespace!");
}

@@ -27,7 +27,7 @@

function escapeInvalidXmlChars(str) {
return str.replace(/\&/g, "&amp;")
.replace(/</g, "&lt;")
return str.replace(/</g, "&lt;")
.replace(/\>/g, "&gt;")
.replace(/\"/g, "&quot;")
.replace(/\'/g, "&apos;");
.replace(/\'/g, "&apos;")
.replace(/\&/g, "&amp;");
}

@@ -46,11 +46,20 @@

* "Class init"); default: true
* @param {string} filePrefix is the string value that is prepended to the
* xml output file; default: 'TEST-'
*/
var JUnitXmlReporter = function(savePath, consolidate, useDotNotation) {
var JUnitXmlReporter = function(savePath, consolidate, useDotNotation, filePrefix) {
this.savePath = savePath || '';
this.consolidate = consolidate === jasmine.undefined ? true : consolidate;
this.useDotNotation = useDotNotation === jasmine.undefined ? true : useDotNotation;
this.filePrefix = filePrefix || 'TEST-';
};
JUnitXmlReporter.started_at = null; // will be updated when test runner start
JUnitXmlReporter.finished_at = null; // will be updated after all files have been written
JUnitXmlReporter.prototype = {
reportRunnerStarting: function() {
// When run test, make it known on JUnitXmlReporter
JUnitXmlReporter.started_at = (new Date()).getTime();
},
reportSpecStarting: function(spec) {

@@ -70,2 +79,5 @@ spec.startTime = new Date();

'" name="' + escapeInvalidXmlChars(spec.description) + '" time="' + spec.duration + '">';
if(results.skipped) {
spec.output = spec.output + "<skipped />";
}

@@ -80,7 +92,9 @@ var failure = "";

failures += 1;
failure += (failures + ": " + escapeInvalidXmlChars(result.message) + " ");
failure += '<failure type="' + result.type + '" message="' + trim(escapeInvalidXmlChars(result.message)) + '">';
failure += escapeInvalidXmlChars(result.trace.stack || result.message);
failure += "</failure>";
}
}
if (failure) {
spec.output += "<failure>" + trim(failure) + "</failure>";
spec.output += failure;
}

@@ -122,3 +136,3 @@ spec.output += "</testcase>";

var suite = suites[i];
var fileName = 'TEST-' + this.getFullName(suite, true) + '.xml';
var fileName = this.filePrefix + this.getFullName(suite, true) + '.xml';
var output = '<?xml version="1.0" encoding="UTF-8" ?>';

@@ -133,7 +147,7 @@ // if we are consolidating, only write out top-level suites

output += "\n</testsuites>";
this.writeFile(this.savePath + fileName, output);
this.writeFile(this.savePath, fileName, output);
}
else {
output += suite.output;
this.writeFile(this.savePath + fileName, output);
this.writeFile(this.savePath, fileName, output);
}

@@ -153,5 +167,23 @@ }

writeFile: function(filename, text) {
writeFile: function(path, filename, text) {
function getQualifiedFilename(separator) {
if (path && path.substr(-1) !== separator && filename.substr(0) !== separator) {
path += separator;
}
return path + filename;
}
// Rhino
try {
// turn filename into a qualified path
if (path) {
filename = getQualifiedFilename(java.lang.System.getProperty("file.separator"));
// create parent dir and ancestors if necessary
var file = java.io.File(filename);
var parentDir = file.getParentFile();
if (!parentDir.exists()) {
parentDir.mkdirs();
}
}
// finally write the file
var out = new java.io.BufferedWriter(new java.io.FileWriter(filename));

@@ -164,2 +196,4 @@ out.write(text);

try {
// turn filename into a qualified path
filename = getQualifiedFilename(window.fs_path_separator);
__phantom_writeFile(filename, text);

@@ -171,3 +205,4 @@ return;

var fs = require("fs");
var fd = fs.openSync(filename, "w");
var nodejs_path = require("path");
var fd = fs.openSync(nodejs_path.join(path, filename), "w");
fs.writeSync(fd, text, 0);

@@ -174,0 +209,0 @@ fs.closeSync(fd);

@@ -20,5 +20,9 @@ (function() {

TeamcityReporter.prototype = {
reportRunnerResults: function(runner) { },
reportRunnerResults: function(runner) {
this.log("##teamcity[progressFinish 'Running Jasmine Tests']");
},
reportRunnerStarting: function(runner) { },
reportRunnerStarting: function(runner) {
this.log("##teamcity[progressStart 'Running Jasmine Tests']");
},

@@ -25,0 +29,0 @@ reportSpecResults: function(spec) { },

require("./jasmine.console_reporter.js")
require("./jasmine.junit_reporter.js")
require("./jasmine.tap_reporter.js")
require("./jasmine.teamcity_reporter.js")
require("./jasmine.terminal_reporter.js")

@@ -51,2 +51,24 @@ (function(){

});
describe("file prepend", function(){
it("should default output file prepend to \'TEST-\'", function () {
expect(reporter.filePrefix).toBe("TEST-");
});
it("should allow the user to override the default xml output file prepend", function () {
reporter = new jasmine.JUnitXmlReporter("", true, true, "alt-prepend-");
expect(reporter.filePrefix).toBe("alt-prepend-");
});
it("should output the file with the modified prepend", function () {
reporter = new jasmine.JUnitXmlReporter("", true, true, "alt-prepend-");
spyOn(reporter, "writeFile");
triggerSuiteEvents([suite]);
reporter.reportRunnerResults(runner);
expect(reporter.writeFile).toHaveBeenCalledWith(reporter.savePath, "alt-prepend-ParentSuite.xml", jasmine.any(String));
});
});
});

@@ -59,3 +81,3 @@

});
it("shound add start time to the suite", function(){
it("should add start time to the suite", function(){
expect(suite.startTime).toBeUndefined();

@@ -79,5 +101,7 @@ reporter.reportSpecStarting(spec);

});
it("should compute duration", function(){
expect(spec.duration).not.toBeUndefined();
});
it("should generate <testcase> output", function(){

@@ -87,12 +111,17 @@ expect(spec.output).not.toBeUndefined();

});
it("should escape bad xml characters in spec description", function() {
expect(spec.output).toContain("&amp; &lt; &gt; &quot; &apos;");
expect(spec.output).toContain("&amp; &amp;lt; &amp;gt; &amp;quot; &amp;apos;");
});
it("should generate valid xml <failure> output if test failed", function(){
// this one takes a bit of setup to pretend a failure
spec = fakeSpec(suite, "should be a dummy");
reporter.reportSpecStarting(spec);
var expectationResult = new jasmine.ExpectationResult({
matcherName: "toEqual", passed: false, message: "Expected 'a' to equal '&'."
matcherName: "toEqual", passed: false,
message: "Expected 'a' to equal '&'.",
trace: { stack: "in test1.js:12\nin test2.js:123" }
});
var results = {

@@ -102,6 +131,11 @@ passed: function() { return false; },

};
spyOn(spec, "results").andReturn(results);
reporter.reportSpecResults(spec);
expect(spec.output).toContain("<failure>");
expect(spec.output).toContain("to equal &apos;&amp;");
expect(spec.output).toContain("<failure");
expect(spec.output).toContain("type=\"" + expectationResult.type + "\"");
expect(spec.output).toContain("message=\"Expected &amp;apos;a&amp;apos; to equal &amp;apos;&amp;&amp;apos;.\"");
expect(spec.output).toContain(">in test1.js:12\nin test2.js:123</failure>");
});

@@ -152,6 +186,6 @@ });

it("should remove invalid filename chars from the filename", function() {
expect(reporter.writeFile).toHaveBeenCalledWith("TEST-SiblingSuiteWithInvalidChars.xml", jasmine.any(String));
expect(reporter.writeFile).toHaveBeenCalledWith(reporter.savePath, "TEST-SiblingSuiteWithInvalidChars.xml", jasmine.any(String));
});
it("should remove invalid xml chars from the classname", function() {
expect(siblingSuite.output).toContain("SiblingSuite With Invalid Chars &amp; &lt; &gt; &quot; &apos; | : \\ /");
expect(siblingSuite.output).toContain("SiblingSuite With Invalid Chars &amp; &amp;lt; &amp;gt; &amp;quot; &amp;apos; | : \\ /");
});

@@ -171,7 +205,7 @@ });

it("should wrap output in <testsuites>", function(){
expect(reporter.writeFile.mostRecentCall.args[1]).toContain("<testsuites>");
expect(reporter.writeFile.mostRecentCall.args[2]).toContain("<testsuites>");
});
it("should include xml header in every file", function(){
for (var i = 0; i < reporter.writeFile.callCount; i++) {
expect(reporter.writeFile.argsForCall[i][1]).toContain("<?xml");
expect(reporter.writeFile.argsForCall[i][2]).toContain("<?xml");
}

@@ -190,7 +224,7 @@ });

it("should not wrap results in <testsuites>", function(){
expect(reporter.writeFile.mostRecentCall.args[1]).not.toContain("<testsuites>");
expect(reporter.writeFile.mostRecentCall.args[2]).not.toContain("<testsuites>");
});
it("should include xml header in every file", function(){
for (var i = 0; i < reporter.writeFile.callCount; i++) {
expect(reporter.writeFile.argsForCall[i][1]).toContain("<?xml");
expect(reporter.writeFile.argsForCall[i][2]).toContain("<?xml");
}

@@ -197,0 +231,0 @@ });

@@ -0,1 +1,2 @@

/* globals jasmine, phantom */
// Verify arguments

@@ -12,8 +13,11 @@ if (phantom.args.length === 0) {

var args = phantom.args;
var pages = [], page, address, resultsKey, i, l;
var fs = require("fs"),
pages = [],
page, address, resultsKey, i, l;
var setupPageFn = function(p, k) {
return function() {
overloadPageEvaluate(p);
setupWriteFileFunction(p, k);
setupWriteFileFunction(p, k, fs.separator);
};

@@ -39,2 +43,4 @@ };

pages.push(page);
page.onConsoleMessage = logAndWorkAroundDefaultLineBreaking;
}

@@ -59,2 +65,22 @@

/**
* Logs a message. Does not add a line-break for single characters '.' and 'F' or lines ending in ' ...'
*
* @param msg
*/
function logAndWorkAroundDefaultLineBreaking(msg) {
var interpretAsWithoutNewline = /(^(\033\[\d+m)*[\.F](\033\[\d+m)*$)|( \.\.\.$)/;
if (navigator.userAgent.indexOf("Windows") < 0 && interpretAsWithoutNewline.test(msg)) {
try {
var system = require('system');
system.stdout.write(msg);
} catch (e) {
var fs = require('fs');
fs.write('/dev/stdout', msg, 'w');
}
} else {
console.log(msg);
}
}
/**
* Stringifies the function, replacing any %placeholders% with mapped values.

@@ -98,9 +124,10 @@ *

// TODO: not bothering with error checking for now (closed environment)
function setupWriteFileFunction(page, key) {
function setupWriteFileFunction(page, key, path_separator) {
page.evaluate(function(){
window["%resultsObj%"] = {};
window.fs_path_separator = "%fs_path_separator%";
window.__phantom_writeFile = function(filename, text) {
window["%resultsObj%"][filename] = text;
};
}, {resultsObj: key});
}, {resultsObj: key, fs_path_separator: path_separator});
}

@@ -142,3 +169,3 @@

// if there's a JUnitXmlReporter, return a boolean indicating if it is finished
if (jasmine.JUnitXmlReporter) {
if (jasmine && jasmine.JUnitXmlReporter && jasmine.JUnitXmlReporter.started_at !== null) {
return jasmine.JUnitXmlReporter.finished_at !== null;

@@ -158,2 +185,4 @@ }

};
var timeout = 60000;
var loopInterval = 100;
var ival = setInterval(function(){

@@ -173,7 +202,4 @@ if (isFinished()) {

var results = getResults();
var specs = Number(results[1]);
var failures = Number(results[2]);
console.log("Results for url " + page.url + ":");
if (failures > 0) {
console.error(" FAILURE: " + results[0]);
page.__exit_code = 1;

@@ -183,3 +209,2 @@ clearInterval(ival);

else {
console.log(" SUCCESS: " + results[0]);
page.__exit_code = 0;

@@ -189,4 +214,12 @@ clearInterval(ival);

}
}, 100);
else {
timeout -= loopInterval;
if (timeout <= 0) {
console.log('Page has timed out; aborting.');
page.__exit_code = 2;
clearInterval(ival);
}
}
}, loopInterval);
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet