Refactor to package JS resources in jar
Instead of requiring each project to have their own copy of the supporting JavaScript and HTML resources (like jasmine.js), package them into this project's JAR and load the resources from the classpath.
This commit is contained in:
parent
e3e6dc55f8
commit
2b639d921d
|
@ -4,6 +4,7 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
class JasmineSpecRunnerGenerator {
|
||||
|
||||
|
@ -66,12 +67,17 @@ class JasmineSpecRunnerGenerator {
|
|||
}
|
||||
|
||||
private String loadTemplate() {
|
||||
String template = null;
|
||||
try {
|
||||
template = FileUtils.readFileToString(new File(suite.jsRootDir() + "/lib/specRunner.tpl"));
|
||||
return IOUtils.toString(
|
||||
Thread
|
||||
.currentThread()
|
||||
.getContextClassLoader()
|
||||
.getResourceAsStream("js/lib/specRunner.tpl")
|
||||
);
|
||||
} catch (NullPointerException e) {
|
||||
throw new IllegalStateException("spec runner template file not found!");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("spec runner template file not found!", e);
|
||||
throw new IllegalStateException("spec runner template file could not be read!", e);
|
||||
}
|
||||
return template;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@ import java.lang.annotation.Annotation;
|
|||
import java.lang.reflect.Method;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.Description;
|
||||
|
@ -18,7 +21,9 @@ import be.klak.rhino.RhinoContext;
|
|||
public class JasmineTestRunner extends Runner {
|
||||
|
||||
private static final int SLEEP_TIME_MILISECONDS = 50;
|
||||
private static final String JASMINE_LIB_DIR = "/lib/jasmine-1.0.2/";
|
||||
|
||||
// relative to classpath
|
||||
private static final String JASMINE_LIB_DIR = "js/lib/jasmine-1.0.2";
|
||||
|
||||
private JasmineDescriptions jasmineSuite;
|
||||
|
||||
|
@ -63,8 +68,8 @@ public class JasmineTestRunner extends Runner {
|
|||
}
|
||||
|
||||
private void setUpJasmine(RhinoContext context) {
|
||||
context.load(getJsLibDir() + "jasmine.js");
|
||||
context.load(getJsLibDir() + "jasmine.delegator_reporter.js");
|
||||
context.loadFromClasspath(JASMINE_LIB_DIR + "/jasmine.js");
|
||||
context.loadFromClasspath(JASMINE_LIB_DIR + "/jasmine.delegator_reporter.js");
|
||||
|
||||
context.evalJS("jasmine.getEnv().addReporter(new jasmine.DelegatorJUnitReporter());");
|
||||
}
|
||||
|
@ -102,11 +107,26 @@ public class JasmineTestRunner extends Runner {
|
|||
}
|
||||
|
||||
private void resetEnvjsWindowSpace() {
|
||||
this.rhinoContext.evalJS("window.location = '" + suiteAnnotation.jsRootDir() + "/lib/blank.html';");
|
||||
}
|
||||
URL blankUrl = Thread
|
||||
.currentThread()
|
||||
.getContextClassLoader()
|
||||
.getResource("js/lib/blank.html");
|
||||
|
||||
private String getJsLibDir() {
|
||||
return suiteAnnotation.jsRootDir() + JASMINE_LIB_DIR;
|
||||
if (blankUrl == null) {
|
||||
throw new IllegalStateException("Unable to load js/lib/blank.html from classpath");
|
||||
}
|
||||
|
||||
String blankUrlStr = blankUrl.toExternalForm();
|
||||
|
||||
// "file:/path/to/file" is not legal, but "file:///path/to/file" is
|
||||
if (blankUrlStr.startsWith("file:/") && (! blankUrlStr.startsWith("file:///"))) {
|
||||
blankUrlStr = "file://" + blankUrlStr.substring(5);
|
||||
}
|
||||
|
||||
this.rhinoContext.evalJS(String.format(
|
||||
"window.location = '%s';",
|
||||
blankUrlStr
|
||||
));
|
||||
}
|
||||
|
||||
private JasmineDescriptions getJasmineDescriptions() {
|
||||
|
|
|
@ -128,8 +128,8 @@ public class RhinoContext {
|
|||
}
|
||||
|
||||
public void loadEnv(String jsDir) {
|
||||
load(jsDir + "/lib/env.rhino.1.2.js");
|
||||
load(jsDir + "/lib/env.utils.js");
|
||||
loadFromClasspath("js/lib/env.rhino.1.2.js");
|
||||
loadFromClasspath("js/lib/env.utils.js");
|
||||
load(jsDir + "/envJsOptions.js");
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,190 +1,189 @@
|
|||
|
||||
/**
|
||||
* Rhino and Envjs additions, filling the missing pieces such as a decent stacktrace
|
||||
* 1) Firefox knows new Error().stack but Envjs does not.
|
||||
*/
|
||||
(function() {
|
||||
var NEWLINE = "\r\n";
|
||||
|
||||
function manuallyTriggerException() {
|
||||
var manuallyTriggeredExMessage = "";
|
||||
try {
|
||||
OEIWABEZIG
|
||||
} catch(e) {
|
||||
// TODO knip- en plakwerk: de eerste lijn moet natuurlijk weg etc...
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
function stripRhinoSpecificExceptionLines(stack) {
|
||||
var ignoreTracingInStackFor = [ "env.utils.js", "org.mozilla.javascript" ];
|
||||
|
||||
return stack.split(NEWLINE).filter(function(stackLine) {
|
||||
return ignoreTracingInStackFor.every(function(ignoreThisInTrace) {
|
||||
return stackLine.indexOf(ignoreThisInTrace) < 0;
|
||||
});
|
||||
}).reduce(function(prev, curr) {
|
||||
return prev + NEWLINE + curr;
|
||||
});
|
||||
}
|
||||
|
||||
window.Error.writeStackTrace = function(e) {
|
||||
var stringWriter = new java.io.StringWriter();
|
||||
var printWriter = new java.io.PrintWriter(stringWriter);
|
||||
e.rhinoException.printStackTrace(printWriter);
|
||||
return stringWriter.toString() + "" // I don't want the java.lang.String object!
|
||||
};
|
||||
|
||||
window.Error.prototype.getStackTrace = function() {
|
||||
// TODO add other stuff from Object.keys(new Error("bla")) (see Firebug)
|
||||
var trace = this.message + NEWLINE;
|
||||
if(this.stack) {
|
||||
trace += this.stack;
|
||||
} else if(this.rhinoException) {
|
||||
trace += window.Error.writeStackTrace(this.rhinoException);
|
||||
} else {
|
||||
trace += stripRhinoSpecificExceptionLines(window.Error.writeStackTrace(manuallyTriggerException()));
|
||||
}
|
||||
|
||||
return trace;
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
/**
|
||||
* Envjs specific hacks
|
||||
* 1) Fix Envjs relative path system to work with Windows path systems
|
||||
* 2) Fix CSS2Properties support for parsing style attributes: get from raw node context.
|
||||
* 3) Fix CSS2Properties support for setting values: all properties have the same objmaps, wtf?
|
||||
* 4) Fix focus() which sets document.activeElement correctly for jQuery:focus
|
||||
* 5) Fix Input click() behavior for checkboxes. Warning: jQ's click() <-> DOM's click (checked value too late set)!
|
||||
**/
|
||||
(function() {
|
||||
|
||||
var oldEnvjsUriFn = Envjs.uri;
|
||||
Envjs.uri = function(path, baseDir) {
|
||||
if(baseDir) {
|
||||
return oldEnvjsUriFn(path, baseDir);
|
||||
}
|
||||
return oldEnvjsUriFn(path, "file:///" + ("" + Envjs.getcwd()).replace(/\\/g, '/') + "/");
|
||||
};
|
||||
|
||||
(function(Element) {
|
||||
|
||||
var style = "style";
|
||||
function lookupStyleInNodeAttributes(el) {
|
||||
if(el.attributes) {
|
||||
for(var i = 0; i < el.attributes.length; i++) {
|
||||
if(el.attributes[i].nodeName === style) {
|
||||
return el.attributes[i].nodeValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var styleSetFn = Element.__lookupGetter__(style);
|
||||
Element.__defineGetter__(style, function() {
|
||||
if(!this.cssText) {
|
||||
this.cssText = lookupStyleInNodeAttributes(this);
|
||||
}
|
||||
return styleSetFn.apply(this);
|
||||
});
|
||||
|
||||
})(HTMLElement.prototype);
|
||||
|
||||
(function(input) {
|
||||
var oldClick = input.prototype.click;
|
||||
input.prototype.click = function() {
|
||||
if(this.type === "checkbox") {
|
||||
this.checked = !this.checked;
|
||||
}
|
||||
oldClick.apply(this, arguments);
|
||||
}
|
||||
})(HTMLInputElement);
|
||||
|
||||
(function(Input, Textarea, document) {
|
||||
var activeElement;
|
||||
function fixFocusForPrototype(element) {
|
||||
var originalFocus = element.prototype.focus;
|
||||
element.prototype.focus = function(element) {
|
||||
activeElement = this;
|
||||
originalFocus.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
fixFocusForPrototype(Input);
|
||||
fixFocusForPrototype(Textarea);
|
||||
|
||||
document.__defineGetter__("activeElement", function() {
|
||||
return activeElement;
|
||||
});
|
||||
|
||||
})(HTMLInputElement, HTMLTextAreaElement, document);
|
||||
|
||||
(function(css) {
|
||||
|
||||
var setCssProperty = css.prototype.setProperty;
|
||||
css.prototype.setProperty = function(name, value) {
|
||||
// create a shallow clone of __supportedStyles__ (styleIndex' default value) if prototype not yet set
|
||||
if(Object.keys(Object.getPrototypeOf(this.styleIndex)).length === 0) {
|
||||
this.styleIndex = Object.create(this.styleIndex);
|
||||
}
|
||||
|
||||
return setCssProperty.call(this, name, value);
|
||||
}
|
||||
})(CSS2Properties);
|
||||
})();
|
||||
|
||||
/**
|
||||
* Envjs timeout fixes which use native Java code to re-implement setTimeout and setInterval
|
||||
* also sets clearTimeout & clearInterval on same level.
|
||||
*/
|
||||
(function() {
|
||||
var threadTimeoutPool = new java.util.HashMap();
|
||||
|
||||
window.setTimeout = function(closure, timeout) {
|
||||
var thread = spawn(function() {
|
||||
try {
|
||||
java.lang.Thread.sleep(timeout);
|
||||
closure();
|
||||
} catch(e) {
|
||||
// ignore InterruptedExceptions, is probably due to clearTimeout
|
||||
if (!(e.javaException instanceof java.lang.InterruptedException)) {
|
||||
throw(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
threadTimeoutPool.put(thread.getId(), thread);
|
||||
return thread.getId();
|
||||
};
|
||||
|
||||
window.setInterval = function(closure, timeout) {
|
||||
var thread = spawn(function() {
|
||||
try {
|
||||
while(true) {
|
||||
java.lang.Thread.sleep(timeout);
|
||||
closure();
|
||||
}
|
||||
} catch(e) {
|
||||
// ignore InterruptedExceptions, is probably due to clearTimeout
|
||||
if (!(e.javaException instanceof java.lang.InterruptedException)) {
|
||||
throw(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
threadTimeoutPool.put(thread.getId(), thread);
|
||||
return thread.getId();
|
||||
};
|
||||
|
||||
window.clearTimeout = function(threadId) {
|
||||
if (threadId) {
|
||||
if(threadTimeoutPool.containsKey(threadId)) {
|
||||
threadTimeoutPool.remove(threadId).interrupt();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.clearInterval = window.clearTimeout;
|
||||
})();
|
||||
/**
|
||||
* Rhino and Envjs additions, filling the missing pieces such as a decent stacktrace
|
||||
* 1) Firefox knows new Error().stack but Envjs does not.
|
||||
*/
|
||||
(function() {
|
||||
var NEWLINE = "\r\n";
|
||||
|
||||
function manuallyTriggerException() {
|
||||
var manuallyTriggeredExMessage = "";
|
||||
try {
|
||||
OEIWABEZIG
|
||||
} catch(e) {
|
||||
// TODO knip- en plakwerk: de eerste lijn moet natuurlijk weg etc...
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
function stripRhinoSpecificExceptionLines(stack) {
|
||||
var ignoreTracingInStackFor = [ "env.utils.js", "org.mozilla.javascript" ];
|
||||
|
||||
return stack.split(NEWLINE).filter(function(stackLine) {
|
||||
return ignoreTracingInStackFor.every(function(ignoreThisInTrace) {
|
||||
return stackLine.indexOf(ignoreThisInTrace) < 0;
|
||||
});
|
||||
}).reduce(function(prev, curr) {
|
||||
return prev + NEWLINE + curr;
|
||||
});
|
||||
}
|
||||
|
||||
window.Error.writeStackTrace = function(e) {
|
||||
var stringWriter = new java.io.StringWriter();
|
||||
var printWriter = new java.io.PrintWriter(stringWriter);
|
||||
e.rhinoException.printStackTrace(printWriter);
|
||||
return stringWriter.toString() + "" // I don't want the java.lang.String object!
|
||||
};
|
||||
|
||||
window.Error.prototype.getStackTrace = function() {
|
||||
// TODO add other stuff from Object.keys(new Error("bla")) (see Firebug)
|
||||
var trace = this.message + NEWLINE;
|
||||
if(this.stack) {
|
||||
trace += this.stack;
|
||||
} else if(this.rhinoException) {
|
||||
trace += window.Error.writeStackTrace(this.rhinoException);
|
||||
} else {
|
||||
trace += stripRhinoSpecificExceptionLines(window.Error.writeStackTrace(manuallyTriggerException()));
|
||||
}
|
||||
|
||||
return trace;
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
/**
|
||||
* Envjs specific hacks
|
||||
* 1) Fix Envjs relative path system to work with Windows path systems
|
||||
* 2) Fix CSS2Properties support for parsing style attributes: get from raw node context.
|
||||
* 3) Fix CSS2Properties support for setting values: all properties have the same objmaps, wtf?
|
||||
* 4) Fix focus() which sets document.activeElement correctly for jQuery:focus
|
||||
* 5) Fix Input click() behavior for checkboxes. Warning: jQ's click() <-> DOM's click (checked value too late set)!
|
||||
**/
|
||||
(function() {
|
||||
|
||||
var oldEnvjsUriFn = Envjs.uri;
|
||||
Envjs.uri = function(path, baseDir) {
|
||||
if(baseDir) {
|
||||
return oldEnvjsUriFn(path, baseDir);
|
||||
}
|
||||
return oldEnvjsUriFn(path, "file:///" + ("" + Envjs.getcwd()).replace(/\\/g, '/') + "/");
|
||||
};
|
||||
|
||||
(function(Element) {
|
||||
|
||||
var style = "style";
|
||||
function lookupStyleInNodeAttributes(el) {
|
||||
if(el.attributes) {
|
||||
for(var i = 0; i < el.attributes.length; i++) {
|
||||
if(el.attributes[i].nodeName === style) {
|
||||
return el.attributes[i].nodeValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var styleSetFn = Element.__lookupGetter__(style);
|
||||
Element.__defineGetter__(style, function() {
|
||||
if(!this.cssText) {
|
||||
this.cssText = lookupStyleInNodeAttributes(this);
|
||||
}
|
||||
return styleSetFn.apply(this);
|
||||
});
|
||||
|
||||
})(HTMLElement.prototype);
|
||||
|
||||
(function(input) {
|
||||
var oldClick = input.prototype.click;
|
||||
input.prototype.click = function() {
|
||||
if(this.type === "checkbox") {
|
||||
this.checked = !this.checked;
|
||||
}
|
||||
oldClick.apply(this, arguments);
|
||||
}
|
||||
})(HTMLInputElement);
|
||||
|
||||
(function(Input, Textarea, document) {
|
||||
var activeElement;
|
||||
function fixFocusForPrototype(element) {
|
||||
var originalFocus = element.prototype.focus;
|
||||
element.prototype.focus = function(element) {
|
||||
activeElement = this;
|
||||
originalFocus.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
fixFocusForPrototype(Input);
|
||||
fixFocusForPrototype(Textarea);
|
||||
|
||||
document.__defineGetter__("activeElement", function() {
|
||||
return activeElement;
|
||||
});
|
||||
|
||||
})(HTMLInputElement, HTMLTextAreaElement, document);
|
||||
|
||||
(function(css) {
|
||||
|
||||
var setCssProperty = css.prototype.setProperty;
|
||||
css.prototype.setProperty = function(name, value) {
|
||||
// create a shallow clone of __supportedStyles__ (styleIndex' default value) if prototype not yet set
|
||||
if(Object.keys(Object.getPrototypeOf(this.styleIndex)).length === 0) {
|
||||
this.styleIndex = Object.create(this.styleIndex);
|
||||
}
|
||||
|
||||
return setCssProperty.call(this, name, value);
|
||||
}
|
||||
})(CSS2Properties);
|
||||
})();
|
||||
|
||||
/**
|
||||
* Envjs timeout fixes which use native Java code to re-implement setTimeout and setInterval
|
||||
* also sets clearTimeout & clearInterval on same level.
|
||||
*/
|
||||
(function() {
|
||||
var threadTimeoutPool = new java.util.HashMap();
|
||||
|
||||
window.setTimeout = function(closure, timeout) {
|
||||
var thread = spawn(function() {
|
||||
try {
|
||||
java.lang.Thread.sleep(timeout);
|
||||
closure();
|
||||
} catch(e) {
|
||||
// ignore InterruptedExceptions, is probably due to clearTimeout
|
||||
if (!(e.javaException instanceof java.lang.InterruptedException)) {
|
||||
throw(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
threadTimeoutPool.put(thread.getId(), thread);
|
||||
return thread.getId();
|
||||
};
|
||||
|
||||
window.setInterval = function(closure, timeout) {
|
||||
var thread = spawn(function() {
|
||||
try {
|
||||
while(true) {
|
||||
java.lang.Thread.sleep(timeout);
|
||||
closure();
|
||||
}
|
||||
} catch(e) {
|
||||
// ignore InterruptedExceptions, is probably due to clearTimeout
|
||||
if (!(e.javaException instanceof java.lang.InterruptedException)) {
|
||||
throw(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
threadTimeoutPool.put(thread.getId(), thread);
|
||||
return thread.getId();
|
||||
};
|
||||
|
||||
window.clearTimeout = function(threadId) {
|
||||
if (threadId) {
|
||||
if(threadTimeoutPool.containsKey(threadId)) {
|
||||
threadTimeoutPool.remove(threadId).interrupt();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.clearInterval = window.clearTimeout;
|
||||
})();
|
|
@ -1,20 +1,20 @@
|
|||
Copyright (c) 2008-2010 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
Copyright (c) 2008-2010 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,188 +1,188 @@
|
|||
jasmine.TrivialReporter = function(doc) {
|
||||
this.document = doc || document;
|
||||
this.suiteDivs = {};
|
||||
this.logRunningSpecs = false;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
||||
var el = document.createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(document.createTextNode(child));
|
||||
} else {
|
||||
if (child) { el.appendChild(child); }
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == "className") {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
var showPassed, showSkipped;
|
||||
|
||||
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
|
||||
this.createDom('div', { className: 'banner' },
|
||||
this.createDom('div', { className: 'logo' },
|
||||
this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
|
||||
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
||||
this.createDom('div', { className: 'options' },
|
||||
"Show ",
|
||||
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
||||
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
||||
)
|
||||
),
|
||||
|
||||
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
||||
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
||||
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
||||
);
|
||||
|
||||
this.document.body.appendChild(this.outerDiv);
|
||||
|
||||
var suites = runner.suites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
var suiteDiv = this.createDom('div', { className: 'suite' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
||||
this.suiteDivs[suite.id] = suiteDiv;
|
||||
var parentDiv = this.outerDiv;
|
||||
if (suite.parentSuite) {
|
||||
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
||||
}
|
||||
parentDiv.appendChild(suiteDiv);
|
||||
}
|
||||
|
||||
this.startedAt = new Date();
|
||||
|
||||
var self = this;
|
||||
showPassed.onclick = function(evt) {
|
||||
if (showPassed.checked) {
|
||||
self.outerDiv.className += ' show-passed';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
||||
}
|
||||
};
|
||||
|
||||
showSkipped.onclick = function(evt) {
|
||||
if (showSkipped.checked) {
|
||||
self.outerDiv.className += ' show-skipped';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
||||
var results = runner.results();
|
||||
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
||||
this.runnerDiv.setAttribute("class", className);
|
||||
//do it twice for IE
|
||||
this.runnerDiv.setAttribute("className", className);
|
||||
var specs = runner.specs();
|
||||
var specCount = 0;
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
if (this.specFilter(specs[i])) {
|
||||
specCount++;
|
||||
}
|
||||
}
|
||||
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
||||
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
||||
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
||||
|
||||
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||
var results = suite.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.totalCount == 0) { // todo: change this to check results.skipped
|
||||
status = 'skipped';
|
||||
}
|
||||
this.suiteDivs[suite.id].className += " " + status;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
||||
if (this.logRunningSpecs) {
|
||||
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||
var results = spec.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
||||
title: spec.getFullName()
|
||||
}, spec.description));
|
||||
|
||||
|
||||
var resultItems = results.getItems();
|
||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (messagesDiv.childNodes.length > 0) {
|
||||
specDiv.appendChild(messagesDiv);
|
||||
}
|
||||
|
||||
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.log = function() {
|
||||
var console = jasmine.getGlobal().console;
|
||||
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
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.getLocation = function() {
|
||||
return this.document.location;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
||||
var paramMap = {};
|
||||
var params = this.getLocation().search.substring(1).split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
|
||||
if (!paramMap["spec"]) return true;
|
||||
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
|
||||
};
|
||||
jasmine.TrivialReporter = function(doc) {
|
||||
this.document = doc || document;
|
||||
this.suiteDivs = {};
|
||||
this.logRunningSpecs = false;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
||||
var el = document.createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(document.createTextNode(child));
|
||||
} else {
|
||||
if (child) { el.appendChild(child); }
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == "className") {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
var showPassed, showSkipped;
|
||||
|
||||
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
|
||||
this.createDom('div', { className: 'banner' },
|
||||
this.createDom('div', { className: 'logo' },
|
||||
this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
|
||||
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
||||
this.createDom('div', { className: 'options' },
|
||||
"Show ",
|
||||
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
||||
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
||||
)
|
||||
),
|
||||
|
||||
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
||||
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
||||
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
||||
);
|
||||
|
||||
this.document.body.appendChild(this.outerDiv);
|
||||
|
||||
var suites = runner.suites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
var suiteDiv = this.createDom('div', { className: 'suite' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
||||
this.suiteDivs[suite.id] = suiteDiv;
|
||||
var parentDiv = this.outerDiv;
|
||||
if (suite.parentSuite) {
|
||||
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
||||
}
|
||||
parentDiv.appendChild(suiteDiv);
|
||||
}
|
||||
|
||||
this.startedAt = new Date();
|
||||
|
||||
var self = this;
|
||||
showPassed.onclick = function(evt) {
|
||||
if (showPassed.checked) {
|
||||
self.outerDiv.className += ' show-passed';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
||||
}
|
||||
};
|
||||
|
||||
showSkipped.onclick = function(evt) {
|
||||
if (showSkipped.checked) {
|
||||
self.outerDiv.className += ' show-skipped';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
||||
var results = runner.results();
|
||||
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
||||
this.runnerDiv.setAttribute("class", className);
|
||||
//do it twice for IE
|
||||
this.runnerDiv.setAttribute("className", className);
|
||||
var specs = runner.specs();
|
||||
var specCount = 0;
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
if (this.specFilter(specs[i])) {
|
||||
specCount++;
|
||||
}
|
||||
}
|
||||
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
||||
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
||||
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
||||
|
||||
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||
var results = suite.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.totalCount == 0) { // todo: change this to check results.skipped
|
||||
status = 'skipped';
|
||||
}
|
||||
this.suiteDivs[suite.id].className += " " + status;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
||||
if (this.logRunningSpecs) {
|
||||
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||
var results = spec.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
||||
title: spec.getFullName()
|
||||
}, spec.description));
|
||||
|
||||
|
||||
var resultItems = results.getItems();
|
||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (messagesDiv.childNodes.length > 0) {
|
||||
specDiv.appendChild(messagesDiv);
|
||||
}
|
||||
|
||||
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.log = function() {
|
||||
var console = jasmine.getGlobal().console;
|
||||
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
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.getLocation = function() {
|
||||
return this.document.location;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
||||
var paramMap = {};
|
||||
var params = this.getLocation().search.substring(1).split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
|
||||
if (!paramMap["spec"]) return true;
|
||||
return spec.getFullName().indexOf(paramMap["spec"]) == 0;
|
||||
};
|
|
@ -1,64 +1,64 @@
|
|||
(function() {
|
||||
|
||||
if (! jasmine) {
|
||||
throw new Exception("jasmine library does not exist in global namespace!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic reporter that outputs spec results to the browser console.
|
||||
* Useful if you need to test an html page and don't want the TrivialReporter
|
||||
* markup mucking things up.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* jasmine.getEnv().addReporter(new jasmine.ConsoleReporter());
|
||||
* jasmine.getEnv().execute();
|
||||
*/
|
||||
var ConsoleReporter = function() {
|
||||
this.started = false;
|
||||
this.finished = false;
|
||||
};
|
||||
|
||||
ConsoleReporter.prototype = {
|
||||
reportRunnerResults: function(runner) {
|
||||
this.finished = true;
|
||||
this.log("Runner Finished.");
|
||||
},
|
||||
|
||||
reportRunnerStarting: function(runner) {
|
||||
this.started = true;
|
||||
this.log("Runner Started.");
|
||||
},
|
||||
|
||||
reportSpecResults: function(spec) {
|
||||
var resultText = "Failed.";
|
||||
|
||||
if (spec.results().passed()) {
|
||||
resultText = "Passed.";
|
||||
}
|
||||
|
||||
this.log(resultText);
|
||||
},
|
||||
|
||||
reportSpecStarting: function(spec) {
|
||||
this.log(spec.suite.description + ' : ' + spec.description + ' ... ');
|
||||
},
|
||||
|
||||
reportSuiteResults: function(suite) {
|
||||
var results = suite.results();
|
||||
|
||||
this.log(suite.description + ": " + results.passedCount + " of " + results.totalCount + " passed.");
|
||||
},
|
||||
|
||||
log: function(str) {
|
||||
var console = jasmine.getGlobal().console;
|
||||
|
||||
if (console && console.log) {
|
||||
console.log(str);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// export public
|
||||
jasmine.ConsoleReporter = ConsoleReporter;
|
||||
})();
|
||||
(function() {
|
||||
|
||||
if (! jasmine) {
|
||||
throw new Exception("jasmine library does not exist in global namespace!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic reporter that outputs spec results to the browser console.
|
||||
* Useful if you need to test an html page and don't want the TrivialReporter
|
||||
* markup mucking things up.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* jasmine.getEnv().addReporter(new jasmine.ConsoleReporter());
|
||||
* jasmine.getEnv().execute();
|
||||
*/
|
||||
var ConsoleReporter = function() {
|
||||
this.started = false;
|
||||
this.finished = false;
|
||||
};
|
||||
|
||||
ConsoleReporter.prototype = {
|
||||
reportRunnerResults: function(runner) {
|
||||
this.finished = true;
|
||||
this.log("Runner Finished.");
|
||||
},
|
||||
|
||||
reportRunnerStarting: function(runner) {
|
||||
this.started = true;
|
||||
this.log("Runner Started.");
|
||||
},
|
||||
|
||||
reportSpecResults: function(spec) {
|
||||
var resultText = "Failed.";
|
||||
|
||||
if (spec.results().passed()) {
|
||||
resultText = "Passed.";
|
||||
}
|
||||
|
||||
this.log(resultText);
|
||||
},
|
||||
|
||||
reportSpecStarting: function(spec) {
|
||||
this.log(spec.suite.description + ' : ' + spec.description + ' ... ');
|
||||
},
|
||||
|
||||
reportSuiteResults: function(suite) {
|
||||
var results = suite.results();
|
||||
|
||||
this.log(suite.description + ": " + results.passedCount + " of " + results.totalCount + " passed.");
|
||||
},
|
||||
|
||||
log: function(str) {
|
||||
var console = jasmine.getGlobal().console;
|
||||
|
||||
if (console && console.log) {
|
||||
console.log(str);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// export public
|
||||
jasmine.ConsoleReporter = ConsoleReporter;
|
||||
})();
|
|
@ -1,166 +1,166 @@
|
|||
body {
|
||||
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
|
||||
}
|
||||
|
||||
|
||||
.jasmine_reporter a:visited, .jasmine_reporter a {
|
||||
color: #303;
|
||||
}
|
||||
|
||||
.jasmine_reporter a:hover, .jasmine_reporter a:active {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.run_spec {
|
||||
float:right;
|
||||
padding-right: 5px;
|
||||
font-size: .8em;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.jasmine_reporter {
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.banner {
|
||||
color: #303;
|
||||
background-color: #fef;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
float: left;
|
||||
font-size: 1.1em;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.logo .version {
|
||||
font-size: .6em;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.runner.running {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
|
||||
.options {
|
||||
text-align: right;
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.suite {
|
||||
border: 1px outset gray;
|
||||
margin: 5px 0;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.suite .suite {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.suite.passed {
|
||||
background-color: #dfd;
|
||||
}
|
||||
|
||||
.suite.failed {
|
||||
background-color: #fdd;
|
||||
}
|
||||
|
||||
.spec {
|
||||
margin: 5px;
|
||||
padding-left: 1em;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.spec.failed, .spec.passed, .spec.skipped {
|
||||
padding-bottom: 5px;
|
||||
border: 1px solid gray;
|
||||
}
|
||||
|
||||
.spec.failed {
|
||||
background-color: #fbb;
|
||||
border-color: red;
|
||||
}
|
||||
|
||||
.spec.passed {
|
||||
background-color: #bfb;
|
||||
border-color: green;
|
||||
}
|
||||
|
||||
.spec.skipped {
|
||||
background-color: #bbb;
|
||||
}
|
||||
|
||||
.messages {
|
||||
border-left: 1px dashed gray;
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
.passed {
|
||||
background-color: #cfc;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.failed {
|
||||
background-color: #fbb;
|
||||
}
|
||||
|
||||
.skipped {
|
||||
color: #777;
|
||||
background-color: #eee;
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
/*.resultMessage {*/
|
||||
/*white-space: pre;*/
|
||||
/*}*/
|
||||
|
||||
.resultMessage span.result {
|
||||
display: block;
|
||||
line-height: 2em;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.resultMessage .mismatch {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.stackTrace {
|
||||
white-space: pre;
|
||||
font-size: .8em;
|
||||
margin-left: 10px;
|
||||
max-height: 5em;
|
||||
overflow: auto;
|
||||
border: 1px inset red;
|
||||
padding: 1em;
|
||||
background: #eef;
|
||||
}
|
||||
|
||||
.finished-at {
|
||||
padding-left: 1em;
|
||||
font-size: .6em;
|
||||
}
|
||||
|
||||
.show-passed .passed,
|
||||
.show-skipped .skipped {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
#jasmine_content {
|
||||
position:fixed;
|
||||
right: 100%;
|
||||
}
|
||||
|
||||
.runner {
|
||||
border: 1px solid gray;
|
||||
display: block;
|
||||
margin: 5px 0;
|
||||
padding: 2px 0 2px 10px;
|
||||
}
|
||||
body {
|
||||
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
|
||||
}
|
||||
|
||||
|
||||
.jasmine_reporter a:visited, .jasmine_reporter a {
|
||||
color: #303;
|
||||
}
|
||||
|
||||
.jasmine_reporter a:hover, .jasmine_reporter a:active {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
.run_spec {
|
||||
float:right;
|
||||
padding-right: 5px;
|
||||
font-size: .8em;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.jasmine_reporter {
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.banner {
|
||||
color: #303;
|
||||
background-color: #fef;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
float: left;
|
||||
font-size: 1.1em;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.logo .version {
|
||||
font-size: .6em;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.runner.running {
|
||||
background-color: yellow;
|
||||
}
|
||||
|
||||
|
||||
.options {
|
||||
text-align: right;
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.suite {
|
||||
border: 1px outset gray;
|
||||
margin: 5px 0;
|
||||
padding-left: 1em;
|
||||
}
|
||||
|
||||
.suite .suite {
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.suite.passed {
|
||||
background-color: #dfd;
|
||||
}
|
||||
|
||||
.suite.failed {
|
||||
background-color: #fdd;
|
||||
}
|
||||
|
||||
.spec {
|
||||
margin: 5px;
|
||||
padding-left: 1em;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.spec.failed, .spec.passed, .spec.skipped {
|
||||
padding-bottom: 5px;
|
||||
border: 1px solid gray;
|
||||
}
|
||||
|
||||
.spec.failed {
|
||||
background-color: #fbb;
|
||||
border-color: red;
|
||||
}
|
||||
|
||||
.spec.passed {
|
||||
background-color: #bfb;
|
||||
border-color: green;
|
||||
}
|
||||
|
||||
.spec.skipped {
|
||||
background-color: #bbb;
|
||||
}
|
||||
|
||||
.messages {
|
||||
border-left: 1px dashed gray;
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
}
|
||||
|
||||
.passed {
|
||||
background-color: #cfc;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.failed {
|
||||
background-color: #fbb;
|
||||
}
|
||||
|
||||
.skipped {
|
||||
color: #777;
|
||||
background-color: #eee;
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
/*.resultMessage {*/
|
||||
/*white-space: pre;*/
|
||||
/*}*/
|
||||
|
||||
.resultMessage span.result {
|
||||
display: block;
|
||||
line-height: 2em;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.resultMessage .mismatch {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.stackTrace {
|
||||
white-space: pre;
|
||||
font-size: .8em;
|
||||
margin-left: 10px;
|
||||
max-height: 5em;
|
||||
overflow: auto;
|
||||
border: 1px inset red;
|
||||
padding: 1em;
|
||||
background: #eef;
|
||||
}
|
||||
|
||||
.finished-at {
|
||||
padding-left: 1em;
|
||||
font-size: .6em;
|
||||
}
|
||||
|
||||
.show-passed .passed,
|
||||
.show-skipped .skipped {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
#jasmine_content {
|
||||
position:fixed;
|
||||
right: 100%;
|
||||
}
|
||||
|
||||
.runner {
|
||||
border: 1px solid gray;
|
||||
display: block;
|
||||
margin: 5px 0;
|
||||
padding: 2px 0 2px 10px;
|
||||
}
|
|
@ -1,53 +1,53 @@
|
|||
(function() {
|
||||
|
||||
if (!jasmine) {
|
||||
throw new Exception("jasmine library does not exist in global namespace!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooks up into the JUnit TestRunner system to allow Jasmine tests to run in Eclipse!
|
||||
* Also sets a "done" flag on the spec itself since there is nothing like it in Jasmine
|
||||
*/
|
||||
var DelegatorJUnitReporter = function() {
|
||||
this.javaReporter = jasmine.DelegatorJUnitReporter.javaReporter;
|
||||
};
|
||||
|
||||
DelegatorJUnitReporter.prototype = {
|
||||
reportRunnerStarting: function(runner) {
|
||||
if(this.javaReporter) {
|
||||
this.javaReporter.reportRunnerStarting(runner);
|
||||
}
|
||||
},
|
||||
|
||||
reportSpecStarting: function(spec) {
|
||||
spec.done = false;
|
||||
|
||||
if(this.javaReporter) {
|
||||
this.javaReporter.reportSpecStarting(spec);
|
||||
}
|
||||
},
|
||||
|
||||
reportSpecResults: function(spec) {
|
||||
spec.done = true;
|
||||
|
||||
if(this.javaReporter) {
|
||||
this.javaReporter.reportSpecResults(spec);
|
||||
}
|
||||
},
|
||||
|
||||
reportSuiteResults: function(suite) {
|
||||
if(this.javaReporter) {
|
||||
this.javaReporter.reportSuiteResults(suite);
|
||||
}
|
||||
},
|
||||
|
||||
reportRunnerResults: function(runner) {
|
||||
if(this.javaReporter) {
|
||||
this.javaReporter.reportRunnerResults(runner);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// export public
|
||||
jasmine.DelegatorJUnitReporter = DelegatorJUnitReporter;
|
||||
})();
|
||||
(function() {
|
||||
|
||||
if (!jasmine) {
|
||||
throw new Exception("jasmine library does not exist in global namespace!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Hooks up into the JUnit TestRunner system to allow Jasmine tests to run in Eclipse!
|
||||
* Also sets a "done" flag on the spec itself since there is nothing like it in Jasmine
|
||||
*/
|
||||
var DelegatorJUnitReporter = function() {
|
||||
this.javaReporter = jasmine.DelegatorJUnitReporter.javaReporter;
|
||||
};
|
||||
|
||||
DelegatorJUnitReporter.prototype = {
|
||||
reportRunnerStarting: function(runner) {
|
||||
if(this.javaReporter) {
|
||||
this.javaReporter.reportRunnerStarting(runner);
|
||||
}
|
||||
},
|
||||
|
||||
reportSpecStarting: function(spec) {
|
||||
spec.done = false;
|
||||
|
||||
if(this.javaReporter) {
|
||||
this.javaReporter.reportSpecStarting(spec);
|
||||
}
|
||||
},
|
||||
|
||||
reportSpecResults: function(spec) {
|
||||
spec.done = true;
|
||||
|
||||
if(this.javaReporter) {
|
||||
this.javaReporter.reportSpecResults(spec);
|
||||
}
|
||||
},
|
||||
|
||||
reportSuiteResults: function(suite) {
|
||||
if(this.javaReporter) {
|
||||
this.javaReporter.reportSuiteResults(suite);
|
||||
}
|
||||
},
|
||||
|
||||
reportRunnerResults: function(runner) {
|
||||
if(this.javaReporter) {
|
||||
this.javaReporter.reportRunnerResults(runner);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// export public
|
||||
jasmine.DelegatorJUnitReporter = DelegatorJUnitReporter;
|
||||
})();
|
File diff suppressed because it is too large
Load Diff
|
@ -1,204 +1,204 @@
|
|||
(function() {
|
||||
|
||||
if (! jasmine) {
|
||||
throw new Exception("jasmine library does not exist in global namespace!");
|
||||
}
|
||||
|
||||
function elapsed(startTime, endTime) {
|
||||
return (endTime - startTime)/1000;
|
||||
}
|
||||
|
||||
function ISODateString(d) {
|
||||
function pad(n) { return n < 10 ? '0'+n : n; }
|
||||
|
||||
return d.getFullYear() + '-'
|
||||
+ pad(d.getMonth()+1) +'-'
|
||||
+ pad(d.getDate()) + 'T'
|
||||
+ pad(d.getHours()) + ':'
|
||||
+ pad(d.getMinutes()) + ':'
|
||||
+ pad(d.getSeconds());
|
||||
}
|
||||
|
||||
function trim(str) {
|
||||
return str.replace(/^\s+/, "" ).replace(/\s+$/, "" );
|
||||
}
|
||||
|
||||
function escapeInvalidXmlChars(str) {
|
||||
return str.replace(/\&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/\>/g, ">")
|
||||
.replace(/\"/g, """)
|
||||
.replace(/\'/g, "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates JUnit XML for the given spec run.
|
||||
* Allows the test results to be used in java based CI
|
||||
* systems like CruiseControl and Hudson.
|
||||
*
|
||||
* @param {string} savePath where to save the files
|
||||
* @param {boolean} consolidate whether to save nested describes within the
|
||||
* same file as their parent; default: true
|
||||
* @param {boolean} useDotNotation whether to separate suite names with
|
||||
* dots rather than spaces (ie "Class.init" not
|
||||
* "Class init"); default: true
|
||||
*/
|
||||
var JUnitXmlReporter = function(savePath, consolidate, useDotNotation) {
|
||||
this.savePath = savePath || '';
|
||||
this.consolidate = consolidate === jasmine.undefined ? true : consolidate;
|
||||
this.useDotNotation = useDotNotation === jasmine.undefined ? true : useDotNotation;
|
||||
};
|
||||
|
||||
JUnitXmlReporter.prototype = {
|
||||
reportRunnerStarting: function(runner) {
|
||||
this.log("Runner Started.");
|
||||
},
|
||||
|
||||
reportSpecStarting: function(spec) {
|
||||
spec.startTime = new Date();
|
||||
|
||||
if (! spec.suite.startTime) {
|
||||
spec.suite.startTime = spec.startTime;
|
||||
}
|
||||
|
||||
this.log(spec.suite.description + ' : ' + spec.description + ' ... ');
|
||||
},
|
||||
|
||||
reportSpecResults: function(spec) {
|
||||
var results = spec.results();
|
||||
spec.didFail = !results.passed();
|
||||
spec.status = spec.didFail ? 'Failed.' : 'Passed.';
|
||||
if (results.skipped) {
|
||||
spec.status = 'Skipped.';
|
||||
}
|
||||
this.log(spec.status);
|
||||
|
||||
spec.duration = elapsed(spec.startTime, new Date());
|
||||
spec.output = '<testcase classname="' + this.getFullName(spec.suite) +
|
||||
'" name="' + escapeInvalidXmlChars(spec.description) + '" time="' + spec.duration + '">';
|
||||
|
||||
var failure = "";
|
||||
var failures = 0;
|
||||
var resultItems = results.getItems();
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
failures += 1;
|
||||
failure += (failures + ": " + escapeInvalidXmlChars(result.trace ? result.trace.getStackTrace() : result.message) + " ");
|
||||
}
|
||||
}
|
||||
if (failure) {
|
||||
spec.output += "<failure>" + trim(failure) + "</failure>";
|
||||
}
|
||||
spec.output += "</testcase>";
|
||||
},
|
||||
|
||||
reportSuiteResults: function(suite) {
|
||||
var results = suite.results();
|
||||
var specs = suite.specs();
|
||||
var specOutput = "";
|
||||
// for JUnit results, let's only include directly failed tests (not nested suites')
|
||||
var failedCount = 0;
|
||||
|
||||
suite.status = results.passed() ? 'Passed.' : 'Failed.';
|
||||
if (results.totalCount === 0) { // todo: change this to check results.skipped
|
||||
suite.status = 'Skipped.';
|
||||
}
|
||||
|
||||
// if a suite has no (active?) specs, reportSpecStarting is never called
|
||||
// and thus the suite has no startTime -- account for that here
|
||||
suite.startTime = suite.startTime || new Date();
|
||||
suite.duration = elapsed(suite.startTime, new Date());
|
||||
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
failedCount += specs[i].didFail ? 1 : 0;
|
||||
specOutput += "\n " + specs[i].output;
|
||||
}
|
||||
suite.output = '\n<testsuite name="' + this.getFullName(suite) +
|
||||
'" errors="0" tests="' + specs.length + '" failures="' + failedCount +
|
||||
'" time="' + suite.duration + '" timestamp="' + ISODateString(suite.startTime) + '">';
|
||||
suite.output += specOutput;
|
||||
suite.output += "\n</testsuite>";
|
||||
this.log(suite.description + ": " + results.passedCount + " of " + results.totalCount + " expectations passed.");
|
||||
},
|
||||
|
||||
reportRunnerResults: function(runner) {
|
||||
this.log("Runner Finished.");
|
||||
var suites = runner.suites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
var fileName = 'TEST-' + this.getFullName(suite, true) + '.xml';
|
||||
var output = '<?xml version="1.0" encoding="UTF-8" ?>';
|
||||
// if we are consolidating, only write out top-level suites
|
||||
if (this.consolidate && suite.parentSuite) {
|
||||
continue;
|
||||
}
|
||||
else if (this.consolidate) {
|
||||
output += "\n<testsuites>";
|
||||
output += this.getNestedOutput(suite);
|
||||
output += "\n</testsuites>";
|
||||
this.writeFile(this.savePath + fileName, output);
|
||||
}
|
||||
else {
|
||||
output += suite.output;
|
||||
this.writeFile(this.savePath + fileName, output);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getNestedOutput: function(suite) {
|
||||
var output = suite.output;
|
||||
for (var i = 0; i < suite.suites().length; i++) {
|
||||
output += this.getNestedOutput(suite.suites()[i]);
|
||||
}
|
||||
return output;
|
||||
},
|
||||
|
||||
writeFile: function(filename, text) {
|
||||
// Rhino
|
||||
try {
|
||||
var out = new java.io.BufferedWriter(new java.io.FileWriter(filename));
|
||||
out.write(text);
|
||||
out.close();
|
||||
} catch (e) {}
|
||||
// PhantomJS, via pyphantomjs and the saveToFile plugin
|
||||
// http://dev.umaclan.com/projects/pyphantomjs/wiki/Plugins#Save-to-File
|
||||
try {
|
||||
phantom.saveToFile(text, filename);
|
||||
} catch (f) {
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
getFullName: function(suite, isFilename) {
|
||||
var fullName;
|
||||
if (this.useDotNotation) {
|
||||
fullName = suite.description;
|
||||
for (var parentSuite = suite.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
|
||||
fullName = parentSuite.description + '.' + fullName;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fullName = suite.getFullName();
|
||||
}
|
||||
|
||||
// Either remove or escape invalid XML characters
|
||||
if (isFilename) {
|
||||
return fullName.replace(/[^\w]/g, "");
|
||||
}
|
||||
return escapeInvalidXmlChars(fullName);
|
||||
},
|
||||
|
||||
log: function(str) {
|
||||
var console = jasmine.getGlobal().console;
|
||||
|
||||
if (console && console.log) {
|
||||
console.log(str);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// export public
|
||||
jasmine.JUnitXmlReporter = JUnitXmlReporter;
|
||||
})();
|
||||
(function() {
|
||||
|
||||
if (! jasmine) {
|
||||
throw new Exception("jasmine library does not exist in global namespace!");
|
||||
}
|
||||
|
||||
function elapsed(startTime, endTime) {
|
||||
return (endTime - startTime)/1000;
|
||||
}
|
||||
|
||||
function ISODateString(d) {
|
||||
function pad(n) { return n < 10 ? '0'+n : n; }
|
||||
|
||||
return d.getFullYear() + '-'
|
||||
+ pad(d.getMonth()+1) +'-'
|
||||
+ pad(d.getDate()) + 'T'
|
||||
+ pad(d.getHours()) + ':'
|
||||
+ pad(d.getMinutes()) + ':'
|
||||
+ pad(d.getSeconds());
|
||||
}
|
||||
|
||||
function trim(str) {
|
||||
return str.replace(/^\s+/, "" ).replace(/\s+$/, "" );
|
||||
}
|
||||
|
||||
function escapeInvalidXmlChars(str) {
|
||||
return str.replace(/\&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/\>/g, ">")
|
||||
.replace(/\"/g, """)
|
||||
.replace(/\'/g, "'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates JUnit XML for the given spec run.
|
||||
* Allows the test results to be used in java based CI
|
||||
* systems like CruiseControl and Hudson.
|
||||
*
|
||||
* @param {string} savePath where to save the files
|
||||
* @param {boolean} consolidate whether to save nested describes within the
|
||||
* same file as their parent; default: true
|
||||
* @param {boolean} useDotNotation whether to separate suite names with
|
||||
* dots rather than spaces (ie "Class.init" not
|
||||
* "Class init"); default: true
|
||||
*/
|
||||
var JUnitXmlReporter = function(savePath, consolidate, useDotNotation) {
|
||||
this.savePath = savePath || '';
|
||||
this.consolidate = consolidate === jasmine.undefined ? true : consolidate;
|
||||
this.useDotNotation = useDotNotation === jasmine.undefined ? true : useDotNotation;
|
||||
};
|
||||
|
||||
JUnitXmlReporter.prototype = {
|
||||
reportRunnerStarting: function(runner) {
|
||||
this.log("Runner Started.");
|
||||
},
|
||||
|
||||
reportSpecStarting: function(spec) {
|
||||
spec.startTime = new Date();
|
||||
|
||||
if (! spec.suite.startTime) {
|
||||
spec.suite.startTime = spec.startTime;
|
||||
}
|
||||
|
||||
this.log(spec.suite.description + ' : ' + spec.description + ' ... ');
|
||||
},
|
||||
|
||||
reportSpecResults: function(spec) {
|
||||
var results = spec.results();
|
||||
spec.didFail = !results.passed();
|
||||
spec.status = spec.didFail ? 'Failed.' : 'Passed.';
|
||||
if (results.skipped) {
|
||||
spec.status = 'Skipped.';
|
||||
}
|
||||
this.log(spec.status);
|
||||
|
||||
spec.duration = elapsed(spec.startTime, new Date());
|
||||
spec.output = '<testcase classname="' + this.getFullName(spec.suite) +
|
||||
'" name="' + escapeInvalidXmlChars(spec.description) + '" time="' + spec.duration + '">';
|
||||
|
||||
var failure = "";
|
||||
var failures = 0;
|
||||
var resultItems = results.getItems();
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
failures += 1;
|
||||
failure += (failures + ": " + escapeInvalidXmlChars(result.trace ? result.trace.getStackTrace() : result.message) + " ");
|
||||
}
|
||||
}
|
||||
if (failure) {
|
||||
spec.output += "<failure>" + trim(failure) + "</failure>";
|
||||
}
|
||||
spec.output += "</testcase>";
|
||||
},
|
||||
|
||||
reportSuiteResults: function(suite) {
|
||||
var results = suite.results();
|
||||
var specs = suite.specs();
|
||||
var specOutput = "";
|
||||
// for JUnit results, let's only include directly failed tests (not nested suites')
|
||||
var failedCount = 0;
|
||||
|
||||
suite.status = results.passed() ? 'Passed.' : 'Failed.';
|
||||
if (results.totalCount === 0) { // todo: change this to check results.skipped
|
||||
suite.status = 'Skipped.';
|
||||
}
|
||||
|
||||
// if a suite has no (active?) specs, reportSpecStarting is never called
|
||||
// and thus the suite has no startTime -- account for that here
|
||||
suite.startTime = suite.startTime || new Date();
|
||||
suite.duration = elapsed(suite.startTime, new Date());
|
||||
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
failedCount += specs[i].didFail ? 1 : 0;
|
||||
specOutput += "\n " + specs[i].output;
|
||||
}
|
||||
suite.output = '\n<testsuite name="' + this.getFullName(suite) +
|
||||
'" errors="0" tests="' + specs.length + '" failures="' + failedCount +
|
||||
'" time="' + suite.duration + '" timestamp="' + ISODateString(suite.startTime) + '">';
|
||||
suite.output += specOutput;
|
||||
suite.output += "\n</testsuite>";
|
||||
this.log(suite.description + ": " + results.passedCount + " of " + results.totalCount + " expectations passed.");
|
||||
},
|
||||
|
||||
reportRunnerResults: function(runner) {
|
||||
this.log("Runner Finished.");
|
||||
var suites = runner.suites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
var fileName = 'TEST-' + this.getFullName(suite, true) + '.xml';
|
||||
var output = '<?xml version="1.0" encoding="UTF-8" ?>';
|
||||
// if we are consolidating, only write out top-level suites
|
||||
if (this.consolidate && suite.parentSuite) {
|
||||
continue;
|
||||
}
|
||||
else if (this.consolidate) {
|
||||
output += "\n<testsuites>";
|
||||
output += this.getNestedOutput(suite);
|
||||
output += "\n</testsuites>";
|
||||
this.writeFile(this.savePath + fileName, output);
|
||||
}
|
||||
else {
|
||||
output += suite.output;
|
||||
this.writeFile(this.savePath + fileName, output);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getNestedOutput: function(suite) {
|
||||
var output = suite.output;
|
||||
for (var i = 0; i < suite.suites().length; i++) {
|
||||
output += this.getNestedOutput(suite.suites()[i]);
|
||||
}
|
||||
return output;
|
||||
},
|
||||
|
||||
writeFile: function(filename, text) {
|
||||
// Rhino
|
||||
try {
|
||||
var out = new java.io.BufferedWriter(new java.io.FileWriter(filename));
|
||||
out.write(text);
|
||||
out.close();
|
||||
} catch (e) {}
|
||||
// PhantomJS, via pyphantomjs and the saveToFile plugin
|
||||
// http://dev.umaclan.com/projects/pyphantomjs/wiki/Plugins#Save-to-File
|
||||
try {
|
||||
phantom.saveToFile(text, filename);
|
||||
} catch (f) {
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
getFullName: function(suite, isFilename) {
|
||||
var fullName;
|
||||
if (this.useDotNotation) {
|
||||
fullName = suite.description;
|
||||
for (var parentSuite = suite.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
|
||||
fullName = parentSuite.description + '.' + fullName;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fullName = suite.getFullName();
|
||||
}
|
||||
|
||||
// Either remove or escape invalid XML characters
|
||||
if (isFilename) {
|
||||
return fullName.replace(/[^\w]/g, "");
|
||||
}
|
||||
return escapeInvalidXmlChars(fullName);
|
||||
},
|
||||
|
||||
log: function(str) {
|
||||
var console = jasmine.getGlobal().console;
|
||||
|
||||
if (console && console.log) {
|
||||
console.log(str);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// export public
|
||||
jasmine.JUnitXmlReporter = JUnitXmlReporter;
|
||||
})();
|
|
@ -1,23 +1,23 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Test Runner</title>
|
||||
<link rel="stylesheet" type="text/css" href="./../lib/jasmine-1.0.2/jasmine.css">
|
||||
<script type="text/javascript" src="./../lib/jasmine-1.0.2/jasmine.js"></script>
|
||||
<script type="text/javascript" src="./../lib/jasmine-1.0.2/jasmine-html.js"></script>
|
||||
|
||||
<!-- dit zijn de productie source js files: -->
|
||||
<!--SourceFileIncludes-->
|
||||
|
||||
<!-- dit zijn de jasmine spec js files: -->
|
||||
<!--SpecFileIncludes-->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
||||
jasmine.getEnv().execute();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Test Runner</title>
|
||||
<link rel="stylesheet" type="text/css" href="./../lib/jasmine-1.0.2/jasmine.css">
|
||||
<script type="text/javascript" src="./../lib/jasmine-1.0.2/jasmine.js"></script>
|
||||
<script type="text/javascript" src="./../lib/jasmine-1.0.2/jasmine-html.js"></script>
|
||||
|
||||
<!-- dit zijn de productie source js files: -->
|
||||
<!--SourceFileIncludes-->
|
||||
|
||||
<!-- dit zijn de jasmine spec js files: -->
|
||||
<!--SpecFileIncludes-->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
||||
jasmine.getEnv().execute();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -13,7 +13,7 @@ public class EnvUtilsTest {
|
|||
|
||||
@Before
|
||||
public void loadJasmineJQueryMatchers(RhinoContext context) {
|
||||
context.load("src/test/javascript/lib/jasmine-1.0.2/jasmine-jquery-rhino.js");
|
||||
context.loadFromClasspath("js/lib/jasmine-1.0.2/jasmine-jquery-rhino.js");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Test Runner</title>
|
||||
<link rel="stylesheet" type="text/css" href="./../lib/jasmine-1.0.2/jasmine.css">
|
||||
<script type="text/javascript" src="./../lib/jasmine-1.0.2/jasmine.js"></script>
|
||||
<script type="text/javascript" src="./../lib/jasmine-1.0.2/jasmine-html.js"></script>
|
||||
|
||||
<!-- dit zijn de productie source js files: -->
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Test Runner</title>
|
||||
<link rel="stylesheet" type="text/css" href="./../lib/jasmine-1.0.2/jasmine.css">
|
||||
<script type="text/javascript" src="./../lib/jasmine-1.0.2/jasmine.js"></script>
|
||||
<script type="text/javascript" src="./../lib/jasmine-1.0.2/jasmine-html.js"></script>
|
||||
|
||||
<!-- dit zijn de productie source js files: -->
|
||||
<script type='text/javascript' src='./../../../main/webapp/js/source1.js'></script>
|
||||
<script type='text/javascript' src='./../../../main/webapp/js/source2.js'></script>
|
||||
|
||||
|
||||
<!-- dit zijn de jasmine spec js files: -->
|
||||
|
||||
|
||||
<!-- dit zijn de jasmine spec js files: -->
|
||||
<script type='text/javascript' src='./../specs/spec1.js'></script>
|
||||
<script type='text/javascript' src='./../specs/spec2.js'></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
||||
jasmine.getEnv().execute();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
||||
jasmine.getEnv().execute();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Reference in New Issue