MACHIN
This commit is contained in:
3
6/node_modules/jasmine-reporters/.npmignore
generated
vendored
Normal file
3
6/node_modules/jasmine-reporters/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
*.pyc
|
||||
*.swp
|
||||
21
6/node_modules/jasmine-reporters/LICENSE
generated
vendored
Normal file
21
6/node_modules/jasmine-reporters/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2010 Larry Myers
|
||||
|
||||
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.
|
||||
59
6/node_modules/jasmine-reporters/README.markdown
generated
vendored
Normal file
59
6/node_modules/jasmine-reporters/README.markdown
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
This branch is for Jasmine 1.x.
|
||||
[Switch to the 2.x branch.](https://github.com/larrymyers/jasmine-reporters)
|
||||
|
||||
# Jasmine Reporters
|
||||
|
||||
Jasmine Reporters is a collection of javascript jasmine.Reporter classes that can be used with
|
||||
the [JasmineBDD testing framework](http://jasmine.github.io/).
|
||||
|
||||
Included reporters:
|
||||
|
||||
* ConsoleReporter - Report test results to the browser console.
|
||||
* JUnitXmlReporter - Report test results to a file in JUnit XML Report format.
|
||||
* NUnitXmlReporter - Report test results to a file in NUnit XML Report format.
|
||||
* TapReporter - Test Anything Protocol, report tests results to console.
|
||||
* TeamcityReporter - Basic reporter that outputs spec results to for the Teamcity build system.
|
||||
* TerminalReporter - Logs to a terminal (including colors) with variable verbosity.
|
||||
|
||||
## Usage
|
||||
|
||||
Examples are included in the test directory that show how to use the reporters,
|
||||
as well a basic runner scripts for Rhino + envjs, and a basic runner for
|
||||
[PhantomJS](https://github.com/ariya/phantomjs). Either of these methods could
|
||||
be used in a Continuous Integration project for running headless tests and
|
||||
generating JUnit XML output.
|
||||
|
||||
### Rhino + EnvJS
|
||||
|
||||
Everything needed to run the tests in Rhino + EnvJS is included in this
|
||||
repository inside the `ext` directory, specifically Rhino 1.7r2 and envjs 1.2
|
||||
for Rhino.
|
||||
|
||||
### PhantomJS
|
||||
|
||||
Should work in most versions of PhantomJS > 1.4.1
|
||||
I have used PhantomJS 1.4.1 through 1.9.6 on Mac OS X with no problems.
|
||||
|
||||
### Node.js
|
||||
|
||||
Most of these reporters also work in node.js by making use of the excellent
|
||||
[jasmine-node project](https://github.com/mhevery/jasmine-node).
|
||||
|
||||
# Protractor
|
||||
|
||||
Protractor 1.6.0 or above allows you to use either Jasmine 1 or Jasmine 2.
|
||||
If you are using Jasmine 1, make sure you install a 1.x-compatible version of jasmine-reporters:
|
||||
|
||||
npm install --save-dev jasmine-reporters@^1.0.0
|
||||
|
||||
Then set everything up inside your protractor.conf:
|
||||
|
||||
onPrepare: function() {
|
||||
// The require statement must be down here, since jasmine-reporters@1.0
|
||||
// expects jasmine to be in the global and protractor does not guarantee
|
||||
// this until inside the onPrepare function.
|
||||
require('jasmine-reporters');
|
||||
jasmine.getEnv().addReporter(
|
||||
new jasmine.JUnitXmlReporter('xmloutput', true, true)
|
||||
);
|
||||
}
|
||||
13989
6/node_modules/jasmine-reporters/ext/env.rhino.1.2.js
generated
vendored
Normal file
13989
6/node_modules/jasmine-reporters/ext/env.rhino.1.2.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
190
6/node_modules/jasmine-reporters/ext/jasmine-html.js
generated
vendored
Normal file
190
6/node_modules/jasmine-reporters/ext/jasmine-html.js
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
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('span', { className: 'title' }, "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;
|
||||
};
|
||||
166
6/node_modules/jasmine-reporters/ext/jasmine.css
generated
vendored
Normal file
166
6/node_modules/jasmine-reporters/ext/jasmine.css
generated
vendored
Normal file
@@ -0,0 +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;
|
||||
}
|
||||
2476
6/node_modules/jasmine-reporters/ext/jasmine.js
generated
vendored
Normal file
2476
6/node_modules/jasmine-reporters/ext/jasmine.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
6/node_modules/jasmine-reporters/ext/jline.jar
generated
vendored
Normal file
BIN
6/node_modules/jasmine-reporters/ext/jline.jar
generated
vendored
Normal file
Binary file not shown.
BIN
6/node_modules/jasmine-reporters/ext/js.jar
generated
vendored
Normal file
BIN
6/node_modules/jasmine-reporters/ext/js.jar
generated
vendored
Normal file
Binary file not shown.
23
6/node_modules/jasmine-reporters/package.json
generated
vendored
Normal file
23
6/node_modules/jasmine-reporters/package.json
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"author": "Larry Myers",
|
||||
"name": "jasmine-reporters",
|
||||
"description": "Reporters for the Jasmine BDD Framework",
|
||||
"version": "1.0.2",
|
||||
"homepage": "https://github.com/larrymyers/jasmine-reporters",
|
||||
"maintainers": "Ben Loveridge <bloveridge@gmail.com>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/larrymyers/jasmine-reporters.git"
|
||||
},
|
||||
"main": "./src/load_reporters.js",
|
||||
"dependencies": {
|
||||
"mkdirp": "~0.3.5"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://raw.github.com/larrymyers/jasmine-reporters/master/LICENSE"
|
||||
}
|
||||
]
|
||||
}
|
||||
4
6/node_modules/jasmine-reporters/publish.sh
generated
vendored
Normal file
4
6/node_modules/jasmine-reporters/publish.sh
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
git push origin master
|
||||
git push origin --tags
|
||||
npm publish
|
||||
16
6/node_modules/jasmine-reporters/release.sh
generated
vendored
Normal file
16
6/node_modules/jasmine-reporters/release.sh
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
VER=${1}
|
||||
shift
|
||||
DESC=$@
|
||||
|
||||
if [ -z "$DESC" ] ; then
|
||||
echo ":: ERROR! Please provide a brief description of the new version"
|
||||
exit 1
|
||||
fi
|
||||
echo :: Tagging and releasing ${VER} ::
|
||||
echo ${VER} - $@
|
||||
|
||||
sed -i "" -E "s/\"version\":.+/\"version\": \"${VER}\",/" package.json
|
||||
git add package.json
|
||||
git commit -m "${VER}"
|
||||
git tag ${VER} -am "${VER} - ${DESC}"
|
||||
144
6/node_modules/jasmine-reporters/src/jasmine.console_reporter.js
generated
vendored
Normal file
144
6/node_modules/jasmine-reporters/src/jasmine.console_reporter.js
generated
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
(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) {
|
||||
if (this.hasGroupedConsole()) {
|
||||
var suites = runner.suites();
|
||||
startGroup(runner.results(), 'tests');
|
||||
for (var i=0; i<suites.length; i++) {
|
||||
if (!suites[i].parentSuite) {
|
||||
suiteResults(suites[i]);
|
||||
}
|
||||
}
|
||||
console.groupEnd();
|
||||
}
|
||||
else {
|
||||
var dur = (new Date()).getTime() - this.start_time;
|
||||
var failed = this.executed_specs - this.passed_specs;
|
||||
var spec_str = this.executed_specs + (this.executed_specs === 1 ? " spec, " : " specs, ");
|
||||
var fail_str = failed + (failed === 1 ? " failure in " : " failures in ");
|
||||
|
||||
this.log("Runner Finished.");
|
||||
this.log(spec_str + fail_str + (dur/1000) + "s.");
|
||||
}
|
||||
this.finished = true;
|
||||
},
|
||||
|
||||
hasGroupedConsole: function() {
|
||||
var console = jasmine.getGlobal().console;
|
||||
return console && console.info && console.warn && console.group && console.groupEnd && console.groupCollapsed;
|
||||
},
|
||||
|
||||
reportRunnerStarting: function(runner) {
|
||||
this.started = true;
|
||||
if (!this.hasGroupedConsole()) {
|
||||
this.start_time = (new Date()).getTime();
|
||||
this.executed_specs = 0;
|
||||
this.passed_specs = 0;
|
||||
this.log("Runner Started.");
|
||||
}
|
||||
},
|
||||
|
||||
reportSpecResults: function(spec) {
|
||||
if (!this.hasGroupedConsole()) {
|
||||
var resultText = "Failed.";
|
||||
|
||||
if (spec.results().skipped ) {
|
||||
resultText = 'Skipped.';
|
||||
} else if (spec.results().passed()) {
|
||||
this.passed_specs++;
|
||||
resultText = "Passed.";
|
||||
}
|
||||
|
||||
this.log(resultText);
|
||||
}
|
||||
},
|
||||
|
||||
reportSpecStarting: function(spec) {
|
||||
if (!this.hasGroupedConsole()) {
|
||||
this.executed_specs++;
|
||||
this.log(spec.suite.description + ' : ' + spec.description + ' ... ');
|
||||
}
|
||||
},
|
||||
|
||||
reportSuiteResults: function(suite) {
|
||||
if (!this.hasGroupedConsole()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function suiteResults(suite) {
|
||||
var results = suite.results();
|
||||
startGroup(results, suite.description);
|
||||
var specs = suite.specs();
|
||||
for (var i in specs) {
|
||||
if (specs.hasOwnProperty(i)) {
|
||||
specResults(specs[i]);
|
||||
}
|
||||
}
|
||||
var suites = suite.suites();
|
||||
for (var j in suites) {
|
||||
if (suites.hasOwnProperty(j)) {
|
||||
suiteResults(suites[j]);
|
||||
}
|
||||
}
|
||||
console.groupEnd();
|
||||
}
|
||||
|
||||
function specResults(spec) {
|
||||
var results = spec.results();
|
||||
startGroup(results, spec.description);
|
||||
var items = results.getItems();
|
||||
for (var k in items) {
|
||||
if (items.hasOwnProperty(k)) {
|
||||
itemResults(items[k]);
|
||||
}
|
||||
}
|
||||
console.groupEnd();
|
||||
}
|
||||
|
||||
function itemResults(item) {
|
||||
if (item.passed && !item.passed()) {
|
||||
console.warn({actual:item.actual,expected: item.expected});
|
||||
item.trace.message = item.matcherName;
|
||||
console.error(item.trace);
|
||||
} else {
|
||||
console.info('Passed');
|
||||
}
|
||||
}
|
||||
|
||||
function startGroup(results, description) {
|
||||
var consoleFunc = (results.passed() && console.groupCollapsed) ? 'groupCollapsed' : 'group';
|
||||
console[consoleFunc](description + ' (' + results.passedCount + '/' + results.totalCount + ' passed, ' + results.failedCount + ' failures)');
|
||||
}
|
||||
|
||||
// export public
|
||||
jasmine.ConsoleReporter = ConsoleReporter;
|
||||
})();
|
||||
286
6/node_modules/jasmine-reporters/src/jasmine.junit_reporter.js
generated
vendored
Normal file
286
6/node_modules/jasmine-reporters/src/jasmine.junit_reporter.js
generated
vendored
Normal file
@@ -0,0 +1,286 @@
|
||||
(function() {
|
||||
|
||||
if (typeof jasmine == 'undefined') {
|
||||
throw new Error("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
|
||||
* @param {string} [filePrefix] is the string value that is prepended to the
|
||||
* xml output file; default: 'TEST-'
|
||||
* @param {boolean} [consolidateAll] whether to save test results from different
|
||||
* specs all in a single file; filePrefix is then the whole file
|
||||
* name without extension; default: false
|
||||
*/
|
||||
var JUnitXmlReporter = function(savePath, consolidate, useDotNotation, filePrefix, consolidateAll) {
|
||||
this.savePath = savePath || '';
|
||||
this.consolidate = consolidate === jasmine.undefined ? true : consolidate;
|
||||
this.consolidateAll = consolidateAll === jasmine.undefined ? false : consolidateAll;
|
||||
this.useDotNotation = useDotNotation === jasmine.undefined ? true : useDotNotation;
|
||||
this.filePrefix = filePrefix || (this.consolidateAll ? 'junitresults' : '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) {
|
||||
spec.startTime = new Date();
|
||||
|
||||
if (!spec.suite.startTime) {
|
||||
spec.suite.startTime = spec.startTime;
|
||||
}
|
||||
},
|
||||
|
||||
reportSpecResults: function(spec) {
|
||||
var results = spec.results();
|
||||
spec.didFail = !results.passed();
|
||||
spec.duration = elapsed(spec.startTime, new Date());
|
||||
spec.output = '<testcase classname="' + this.getFullName(spec.suite) +
|
||||
'" name="' + escapeInvalidXmlChars(spec.description) + '" time="' + spec.duration + '">';
|
||||
if(results.skipped) {
|
||||
spec.output = spec.output + "<skipped />";
|
||||
}
|
||||
|
||||
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 += '<failure type="' + result.type + '" message="' + trim(escapeInvalidXmlChars(result.message)) + '">';
|
||||
failure += escapeInvalidXmlChars(result.trace.stack || result.message);
|
||||
failure += "</failure>";
|
||||
}
|
||||
}
|
||||
if (failure) {
|
||||
spec.output += 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>";
|
||||
},
|
||||
|
||||
reportRunnerResults: function(runner) {
|
||||
var fileName;
|
||||
if (this.consolidateAll) {
|
||||
fileName = this.filePrefix + '.xml';
|
||||
var output = '<?xml version="1.0" encoding="UTF-8" ?>';
|
||||
output += "\n<testsuites>";
|
||||
}
|
||||
var suites = runner.suites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
fileName = this.consolidateAll ? fileName : this.filePrefix + this.getFullName(suite, true) + '.xml';
|
||||
if (!this.consolidateAll) {
|
||||
var output = '<?xml version="1.0" encoding="UTF-8" ?>';
|
||||
}
|
||||
// if we are consolidating, only write out top-level suites
|
||||
if ((this.consolidate || this.consolidateAll) && suite.parentSuite) {
|
||||
continue;
|
||||
}
|
||||
else if (this.consolidate || this.consolidateAll) {
|
||||
if (!this.consolidateAll) {
|
||||
output += "\n<testsuites>";
|
||||
}
|
||||
output += this.getNestedOutput(suite);
|
||||
if (!this.consolidateAll) {
|
||||
output += "\n</testsuites>";
|
||||
this.writeFile(this.savePath, fileName, output);
|
||||
}
|
||||
}
|
||||
else {
|
||||
output += suite.output;
|
||||
this.writeFile(this.savePath, fileName, output);
|
||||
}
|
||||
}
|
||||
if (this.consolidateAll) {
|
||||
output += "\n</testsuites>";
|
||||
this.writeFile(this.savePath, fileName, output);
|
||||
}
|
||||
// When all done, make it known on JUnitXmlReporter
|
||||
JUnitXmlReporter.finished_at = (new Date()).getTime();
|
||||
},
|
||||
|
||||
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(path, filename, text) {
|
||||
var errors = [];
|
||||
|
||||
function getQualifiedFilename(separator) {
|
||||
if (separator && path && path.substr(-1) !== separator && filename.substr(0) !== separator) {
|
||||
return path + separator + filename;
|
||||
}
|
||||
return path + filename;
|
||||
}
|
||||
|
||||
function rhinoWrite(path, filename, text) {
|
||||
if (path) {
|
||||
// turn filename into a qualified 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));
|
||||
out.write(text);
|
||||
out.close();
|
||||
}
|
||||
|
||||
function phantomWrite(path, filename, text) {
|
||||
// turn filename into a qualified path
|
||||
filename = getQualifiedFilename(window.fs_path_separator);
|
||||
// write via a method injected by phantomjs-testrunner.js
|
||||
__phantom_writeFile(filename, text);
|
||||
}
|
||||
|
||||
function nodeWrite(path, filename, text) {
|
||||
var fs = require("fs");
|
||||
var nodejs_path = require("path");
|
||||
require("mkdirp").sync(path); // make sure the path exists
|
||||
var filepath = nodejs_path.join(path, filename);
|
||||
var xmlfile = fs.openSync(filepath, "w");
|
||||
fs.writeSync(xmlfile, text, 0);
|
||||
fs.closeSync(xmlfile);
|
||||
}
|
||||
|
||||
|
||||
// Attempt writing with each possible environment.
|
||||
// Track errors in case no write succeeds
|
||||
try {
|
||||
rhinoWrite(path, filename, text);
|
||||
return;
|
||||
} catch (e) {
|
||||
errors.push(' Rhino attempt: ' + e.message);
|
||||
}
|
||||
|
||||
try {
|
||||
phantomWrite(path, filename, text);
|
||||
return;
|
||||
} catch (f) {
|
||||
errors.push(' PhantomJs attempt: ' + f.message);
|
||||
}
|
||||
|
||||
try {
|
||||
nodeWrite(path, filename, text);
|
||||
return;
|
||||
} catch (g) {
|
||||
errors.push(' NodeJS attempt: ' + g.message);
|
||||
}
|
||||
|
||||
// If made it here, no write succeeded. Let user know.
|
||||
this.log("Warning: writing junit report failed for '" + path + "', '" +
|
||||
filename + "'. Reasons:\n" +
|
||||
errors.join("\n"));
|
||||
},
|
||||
|
||||
|
||||
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;
|
||||
})();
|
||||
303
6/node_modules/jasmine-reporters/src/jasmine.nunit_reporter.js
generated
vendored
Normal file
303
6/node_modules/jasmine-reporters/src/jasmine.nunit_reporter.js
generated
vendored
Normal file
@@ -0,0 +1,303 @@
|
||||
/* globals jasmine */
|
||||
(function() {
|
||||
/**
|
||||
* Generates NUnit XML for the given spec run.
|
||||
* Allows the test results to be used in java based CI
|
||||
* systems like Jenkins.
|
||||
*
|
||||
* Originally from https://github.com/gmusick/jasmine-reporters. Adapted
|
||||
* to support file output via PhantomJS/Rhino/Node.js like JUnitXmlReporter.
|
||||
* Also fixed a couple minor bugs (ie month being reported incorrectly) and
|
||||
* added a few options to control how / where the file is generated.
|
||||
*
|
||||
* @param {object} [options]
|
||||
* @param {string} [options.savePath] directory to save the files (default: '')
|
||||
* @param {string} [options.filename] name of xml output file (default: 'nunit-results.xml')
|
||||
* @param {string} [options.reportName] name for parent test-results node (default: 'Jasmine Results')
|
||||
*/
|
||||
jasmine.NUnitXmlReporter = function(options) {
|
||||
options = options || {};
|
||||
this.savePath = options.savePath || '';
|
||||
this.filename = options.filename || 'nunit-results.xml';
|
||||
this.reportName = options.reportName || 'Jasmine Results';
|
||||
this.testSuites = {};
|
||||
this.testSpecs = {};
|
||||
this.testRun = {
|
||||
suites: []
|
||||
};
|
||||
};
|
||||
|
||||
jasmine.NUnitXmlReporter.prototype = {
|
||||
reportRunnerStarting: function(runner) {
|
||||
var suites = runner.suites();
|
||||
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var currentSuite = suites[i];
|
||||
|
||||
var suite = {
|
||||
elapsed: 0,
|
||||
executed: false,
|
||||
id: currentSuite.id,
|
||||
name: currentSuite.description,
|
||||
specs: [],
|
||||
success: false,
|
||||
suites: []
|
||||
};
|
||||
|
||||
this.testSuites[currentSuite.id] = suite;
|
||||
|
||||
var parent = this.testRun.suites;
|
||||
if (currentSuite.parentSuite) {
|
||||
parent = this.testSuites[currentSuite.parentSuite.id].suites;
|
||||
}
|
||||
|
||||
parent.push(suite);
|
||||
}
|
||||
},
|
||||
|
||||
reportSpecStarting: function(spec) {
|
||||
spec.startTime = new Date();
|
||||
},
|
||||
|
||||
reportRunnerResults: function(runner) {
|
||||
var output = printTestResults(runner, this);
|
||||
this.writeFile(output);
|
||||
},
|
||||
|
||||
reportSuiteResults: function(suite) {
|
||||
var id = suite.id;
|
||||
|
||||
var results = suite.results();
|
||||
|
||||
var testSuite = this.testSuites[id];
|
||||
testSuite.executed = true;
|
||||
testSuite.success = results.passed();
|
||||
},
|
||||
|
||||
reportSpecResults: function(spec) {
|
||||
var elapsed = spec.startTime ? (new Date() - spec.startTime) / 1000 : 0;
|
||||
var results = spec.results();
|
||||
var skipped = !!results.skipped;
|
||||
var id = spec.id;
|
||||
var suite = spec.suite;
|
||||
var testSuite = this.testSuites[suite.id];
|
||||
var testSpec = {
|
||||
elapsed: elapsed,
|
||||
executed: !skipped,
|
||||
failures: [],
|
||||
id: spec.id,
|
||||
name: spec.description,
|
||||
success: results.passed()
|
||||
};
|
||||
this.testSpecs[spec.id] = testSpec;
|
||||
testSuite.specs.push(testSpec);
|
||||
|
||||
if (!testSpec.success) {
|
||||
var items = results.getItems();
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var result = items[i];
|
||||
if (result.passed && !result.passed()) {
|
||||
var failure = {
|
||||
message: result.toString(),
|
||||
stack: result.trace.stack ? result.trace.stack : ""
|
||||
};
|
||||
testSpec.failures.push(failure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (suite) {
|
||||
testSuite = this.testSuites[suite.id];
|
||||
testSuite.elapsed = testSuite.elapsed ? (testSuite.elapsed + elapsed) : elapsed;
|
||||
suite = suite.parentSuite;
|
||||
}
|
||||
},
|
||||
|
||||
writeFile: function(text) {
|
||||
var errors = [];
|
||||
var path = this.savePath;
|
||||
var filename = this.filename;
|
||||
function getQualifiedFilename(separator) {
|
||||
if (path && path.substr(-1) !== separator && filename.substr(0) !== separator) {
|
||||
path += separator;
|
||||
}
|
||||
return path + filename;
|
||||
}
|
||||
|
||||
function rhinoWrite(path, filename, text) {
|
||||
if (path) {
|
||||
// turn filename into a qualified 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));
|
||||
out.write(text);
|
||||
out.close();
|
||||
}
|
||||
|
||||
function phantomWrite(path, filename, text) {
|
||||
// turn filename into a qualified path
|
||||
filename = getQualifiedFilename(window.fs_path_separator);
|
||||
// write via a method injected by phantomjs-testrunner.js
|
||||
__phantom_writeFile(filename, text);
|
||||
}
|
||||
|
||||
function nodeWrite(path, filename, text) {
|
||||
var fs = require("fs");
|
||||
var nodejs_path = require("path");
|
||||
require("mkdirp").sync(path); // make sure the path exists
|
||||
var filepath = nodejs_path.join(path, filename);
|
||||
var xmlfile = fs.openSync(filepath, "w");
|
||||
fs.writeSync(xmlfile, text, 0);
|
||||
fs.closeSync(xmlfile);
|
||||
}
|
||||
|
||||
// Attempt writing with each possible environment.
|
||||
// Track errors in case no write succeeds
|
||||
try {
|
||||
rhinoWrite(path, filename, text);
|
||||
return;
|
||||
} catch (e) {
|
||||
errors.push(' Rhino attempt: ' + e.message);
|
||||
}
|
||||
|
||||
try {
|
||||
phantomWrite(path, filename, text);
|
||||
return;
|
||||
} catch (f) {
|
||||
errors.push(' PhantomJs attempt: ' + f.message);
|
||||
}
|
||||
|
||||
try {
|
||||
nodeWrite(path, filename, text);
|
||||
return;
|
||||
} catch (g) {
|
||||
errors.push(' NodeJS attempt: ' + g.message);
|
||||
}
|
||||
|
||||
// If made it here, no write succeeded. Let user know.
|
||||
console.log("Warning: writing junit report failed for '" + path + "', '" +
|
||||
filename + "'. Reasons:\n" +
|
||||
errors.join("\n")
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
function dateString(date) {
|
||||
var year = date.getFullYear();
|
||||
var month = date.getMonth()+1; // 0-based
|
||||
var day = date.getDate();
|
||||
return year + "-" + formatAsTwoDigits(month) + "-" + formatAsTwoDigits(day);
|
||||
}
|
||||
|
||||
function timeString(date) {
|
||||
var hours = date.getHours();
|
||||
var minutes = date.getMinutes();
|
||||
var seconds = date.getSeconds();
|
||||
return hours + ":" + formatAsTwoDigits(minutes) + ":" + formatAsTwoDigits(seconds);
|
||||
}
|
||||
|
||||
function formatAsTwoDigits(digit) {
|
||||
return (digit < 10) ? "0" + digit : "" + digit;
|
||||
}
|
||||
|
||||
function escapeInvalidXmlChars(str) {
|
||||
return str.replace(/</g, "<")
|
||||
.replace(/\>/g, ">")
|
||||
.replace(/\"/g, """)
|
||||
.replace(/\'/g, "'")
|
||||
.replace(/\&/g, "&");
|
||||
}
|
||||
|
||||
function getSkippedCount(specs) {
|
||||
if (!specs.length) { return 0; }
|
||||
for (var i = 0, count = 0; i < specs.length; i++) {
|
||||
if (specs[i].results().skipped) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
function printTestResults(runner, reporter) {
|
||||
var testRun = reporter.testRun;
|
||||
var output = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
|
||||
|
||||
var date = new Date();
|
||||
var results = runner.results();
|
||||
var specs = runner.specs();
|
||||
var specCount = specs.length;
|
||||
var skippedCount = getSkippedCount(specs);
|
||||
|
||||
output += "<test-results name=\"" + escapeInvalidXmlChars(reporter.reportName) + "\" ";
|
||||
output += "total=\"" + specCount + "\" ";
|
||||
output += "failures=\"" + results.failedCount + "\" ";
|
||||
output += "not-run=\"" + skippedCount + "\" ";
|
||||
output += "date=\"" + dateString(date) + "\" ";
|
||||
output += "time=\"" + timeString(date) + "\">";
|
||||
|
||||
output += printSuites(testRun.suites);
|
||||
|
||||
output += "</test-results>";
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
function printSuites(suites) {
|
||||
var output = "";
|
||||
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
output += "<test-suite ";
|
||||
output += "name=\"" + escapeInvalidXmlChars(suites[i].name) + "\" ";
|
||||
output += "executed=\"" + suites[i].executed + "\" ";
|
||||
output += "success=\"" + suites[i].success + "\" ";
|
||||
output += "time=\"" + suites[i].elapsed + "\">";
|
||||
output += "<results>";
|
||||
|
||||
output += printSuites(suites[i].suites);
|
||||
|
||||
if (suites[i].specs.length > 0) {
|
||||
output += printSpecs(suites[i].specs);
|
||||
}
|
||||
|
||||
output += "</results>";
|
||||
output += "</test-suite>";
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
function printSpecs(specs) {
|
||||
var output = "";
|
||||
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
var spec = specs[i];
|
||||
|
||||
output += "<test-case ";
|
||||
output += "name=\"" + escapeInvalidXmlChars(spec.name) + "\" ";
|
||||
output += "executed=\"" + spec.executed + "\" ";
|
||||
output += "success=\"" + spec.success + "\" ";
|
||||
output += "time=\"" + spec.elapsed + "\">";
|
||||
|
||||
for (var j = 0; j < spec.failures.length; j++) {
|
||||
var failure = spec.failures[j];
|
||||
|
||||
output += "<failure>";
|
||||
output += "<message><![CDATA[" + failure.message + "]]></message>";
|
||||
output += "<stack-trace><![CDATA[" + failure.stack + "]]></stack-trace>";
|
||||
output += "</failure>";
|
||||
}
|
||||
|
||||
output += "</test-case>";
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
})();
|
||||
96
6/node_modules/jasmine-reporters/src/jasmine.tap_reporter.js
generated
vendored
Normal file
96
6/node_modules/jasmine-reporters/src/jasmine.tap_reporter.js
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
(function() {
|
||||
if (! jasmine) {
|
||||
throw new Exception("jasmine library does not exist in global namespace!");
|
||||
}
|
||||
|
||||
/**
|
||||
* TAP (http://en.wikipedia.org/wiki/Test_Anything_Protocol) reporter.
|
||||
* outputs spec results to the console.
|
||||
*
|
||||
* Heavily inspired by ConsoleReporter found at:
|
||||
* https://github.com/larrymyers/jasmine-reporters/
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* jasmine.getEnv().addReporter(new jasmine.TapReporter());
|
||||
* jasmine.getEnv().execute();
|
||||
*/
|
||||
var TapReporter = function() {
|
||||
this.started = false;
|
||||
this.finished = false;
|
||||
};
|
||||
|
||||
TapReporter.prototype = {
|
||||
|
||||
reportRunnerStarting: function(runner) {
|
||||
this.started = true;
|
||||
this.start_time = (new Date()).getTime();
|
||||
this.executed_specs = 0;
|
||||
this.passed_specs = 0;
|
||||
this.executed_asserts = 0;
|
||||
this.passed_asserts = 0;
|
||||
// should have at least 1 spec, otherwise it's considered a failure
|
||||
this.log('1..'+ Math.max(runner.specs().length, 1));
|
||||
},
|
||||
|
||||
reportSpecStarting: function(spec) {
|
||||
this.executed_specs++;
|
||||
},
|
||||
|
||||
reportSpecResults: function(spec) {
|
||||
var resultText = "not ok";
|
||||
var errorMessage = '';
|
||||
|
||||
var results = spec.results();
|
||||
if (results.skipped) {
|
||||
return;
|
||||
}
|
||||
var passed = results.passed();
|
||||
|
||||
this.passed_asserts += results.passedCount;
|
||||
this.executed_asserts += results.totalCount;
|
||||
|
||||
if (passed) {
|
||||
this.passed_specs++;
|
||||
resultText = "ok";
|
||||
} else {
|
||||
var items = results.getItems();
|
||||
var i = 0;
|
||||
var expectationResult, stackMessage;
|
||||
while (expectationResult = items[i++]) {
|
||||
if (expectationResult.trace) {
|
||||
stackMessage = expectationResult.trace.stack? expectationResult.trace.stack : expectationResult.message;
|
||||
errorMessage += '\n '+ stackMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.log(resultText +" "+ (spec.id + 1) +" - "+ spec.suite.description +" : "+ spec.description + errorMessage);
|
||||
},
|
||||
|
||||
reportRunnerResults: function(runner) {
|
||||
var dur = (new Date()).getTime() - this.start_time;
|
||||
var failed = this.executed_specs - this.passed_specs;
|
||||
var spec_str = this.executed_specs + (this.executed_specs === 1 ? " spec, " : " specs, ");
|
||||
var fail_str = failed + (failed === 1 ? " failure in " : " failures in ");
|
||||
var assert_str = this.executed_asserts + (this.executed_asserts === 1 ? " assertion, " : " assertions, ");
|
||||
|
||||
if (this.executed_asserts) {
|
||||
this.log("# "+ spec_str + assert_str + fail_str + (dur/1000) + "s.");
|
||||
} else {
|
||||
this.log('not ok 1 - no asserts run.');
|
||||
}
|
||||
this.finished = true;
|
||||
},
|
||||
|
||||
log: function(str) {
|
||||
var console = jasmine.getGlobal().console;
|
||||
if (console && console.log) {
|
||||
console.log(str);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// export public
|
||||
jasmine.TapReporter = TapReporter;
|
||||
})();
|
||||
143
6/node_modules/jasmine-reporters/src/jasmine.teamcity_reporter.js
generated
vendored
Normal file
143
6/node_modules/jasmine-reporters/src/jasmine.teamcity_reporter.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
(function() {
|
||||
if (! jasmine) {
|
||||
throw new Exception("jasmine library does not exist in global namespace!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic reporter that outputs spec results to for the Teamcity build system
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* jasmine.getEnv().addReporter(new jasmine.TeamcityReporter());
|
||||
* jasmine.getEnv().execute();
|
||||
*/
|
||||
var TeamcityReporter = function() {
|
||||
this.started = false;
|
||||
this.finished = false;
|
||||
};
|
||||
|
||||
TeamcityReporter.prototype = {
|
||||
reportRunnerResults: function(runner) {
|
||||
this.log("##teamcity[progressFinish 'Running Jasmine Tests']");
|
||||
},
|
||||
|
||||
reportRunnerStarting: function(runner) {
|
||||
this.log("##teamcity[progressStart 'Running Jasmine Tests']");
|
||||
},
|
||||
|
||||
reportSpecResults: function(spec) { },
|
||||
|
||||
reportSpecStarting: function(spec) { },
|
||||
|
||||
reportSuiteResults: function(suite) {
|
||||
var results = suite.results();
|
||||
var path = [];
|
||||
while(suite) {
|
||||
path.unshift(suite.description);
|
||||
suite = suite.parentSuite;
|
||||
}
|
||||
var description = path.join(' ');
|
||||
|
||||
this.log("##teamcity[testSuiteStarted name='" + this.escapeTeamcityString(description) + "']");
|
||||
|
||||
var outerThis = this;
|
||||
var eachSpecFn = function(spec){
|
||||
if (spec.description) {
|
||||
outerThis.log("##teamcity[testStarted name='" + outerThis.escapeTeamcityString(spec.description) + "' captureStandardOutput='true']");
|
||||
var specResultFn = function(result){
|
||||
if (!result.passed_) {
|
||||
outerThis.log("##teamcity[testFailed name='" + outerThis.escapeTeamcityString(spec.description) + "' message='|[FAILED|]' details='" + outerThis.escapeTeamcityString(result.trace.stack) + "']");
|
||||
}
|
||||
};
|
||||
|
||||
for (var j = 0, jlen = spec.items_.length; j < jlen; j++) {
|
||||
specResultFn(spec.items_[j]);
|
||||
}
|
||||
outerThis.log("##teamcity[testFinished name='" + outerThis.escapeTeamcityString(spec.description) + "']");
|
||||
}
|
||||
};
|
||||
for (var i = 0, ilen = results.items_.length; i < ilen; i++) {
|
||||
eachSpecFn(results.items_[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.log("##teamcity[testSuiteFinished name='" + outerThis.escapeTeamcityString(description) + "']");
|
||||
},
|
||||
|
||||
log: function(str) {
|
||||
var console = jasmine.getGlobal().console;
|
||||
if (console && console.log) {
|
||||
console.log(str);
|
||||
}
|
||||
},
|
||||
|
||||
hasGroupedConsole: function() {
|
||||
var console = jasmine.getGlobal().console;
|
||||
return console && console.info && console.warn && console.group && console.groupEnd && console.groupCollapsed;
|
||||
},
|
||||
|
||||
escapeTeamcityString: function(message) {
|
||||
if(!message) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return message.replace(/\|/g, "||")
|
||||
.replace(/\'/g, "|'")
|
||||
.replace(/\n/g, "|n")
|
||||
.replace(/\r/g, "|r")
|
||||
.replace(/\u0085/g, "|x")
|
||||
.replace(/\u2028/g, "|l")
|
||||
.replace(/\u2029/g, "|p")
|
||||
.replace(/\[/g, "|[")
|
||||
.replace(/]/g, "|]");
|
||||
}
|
||||
};
|
||||
|
||||
function suiteResults(suite) {
|
||||
console.group(suite.description);
|
||||
var specs = suite.specs();
|
||||
for (var i in specs) {
|
||||
if (specs.hasOwnProperty(i)) {
|
||||
specResults(specs[i]);
|
||||
}
|
||||
}
|
||||
var suites = suite.suites();
|
||||
for (var j in suites) {
|
||||
if (suites.hasOwnProperty(j)) {
|
||||
suiteResults(suites[j]);
|
||||
}
|
||||
}
|
||||
console.groupEnd();
|
||||
}
|
||||
|
||||
function specResults(spec) {
|
||||
var results = spec.results();
|
||||
if (results.passed() && console.groupCollapsed) {
|
||||
console.groupCollapsed(spec.description);
|
||||
} else {
|
||||
console.group(spec.description);
|
||||
}
|
||||
var items = results.getItems();
|
||||
for (var k in items) {
|
||||
if (items.hasOwnProperty(k)) {
|
||||
itemResults(items[k]);
|
||||
}
|
||||
}
|
||||
console.groupEnd();
|
||||
}
|
||||
|
||||
function itemResults(item) {
|
||||
if (item.passed && !item.passed()) {
|
||||
console.warn({actual:item.actual,expected: item.expected});
|
||||
item.trace.message = item.matcherName;
|
||||
console.error(item.trace);
|
||||
} else {
|
||||
console.info('Passed');
|
||||
}
|
||||
}
|
||||
|
||||
// export public
|
||||
jasmine.TeamcityReporter = TeamcityReporter;
|
||||
})();
|
||||
|
||||
193
6/node_modules/jasmine-reporters/src/jasmine.terminal_reporter.js
generated
vendored
Normal file
193
6/node_modules/jasmine-reporters/src/jasmine.terminal_reporter.js
generated
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
(function() {
|
||||
if (! jasmine) {
|
||||
throw new Exception("jasmine library does not exist in global namespace!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic reporter that outputs spec results to the terminal.
|
||||
* Use this reporter in your build pipeline.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* jasmine.getEnv().addReporter(new jasmine.TerminalReporter({
|
||||
verbosity: 2,
|
||||
color: true
|
||||
}));
|
||||
* jasmine.getEnv().execute();
|
||||
*/
|
||||
var DEFAULT_VERBOSITY = 2,
|
||||
ATTRIBUTES_TO_ANSI = {
|
||||
"off": 0,
|
||||
"bold": 1,
|
||||
"red": 31,
|
||||
"green": 32
|
||||
};
|
||||
|
||||
var TerminalReporter = function(params) {
|
||||
var parameters = params || {};
|
||||
|
||||
if (parameters.verbosity === 0) {
|
||||
this.verbosity = 0;
|
||||
} else {
|
||||
this.verbosity = parameters.verbosity || DEFAULT_VERBOSITY;
|
||||
}
|
||||
this.color = parameters.color;
|
||||
|
||||
this.started = false;
|
||||
this.finished = false;
|
||||
this.current_suite_hierarchy = [];
|
||||
this.indent_string = ' ';
|
||||
};
|
||||
|
||||
TerminalReporter.prototype = {
|
||||
reportRunnerResults: function(runner) {
|
||||
var dur = (new Date()).getTime() - this.start_time,
|
||||
failed = this.executed_specs - this.passed_specs,
|
||||
spec_str = this.executed_specs + (this.executed_specs === 1 ? " spec, " : " specs, "),
|
||||
fail_str = failed + (failed === 1 ? " failure in " : " failures in "),
|
||||
summary_str = spec_str + fail_str + (dur/1000) + "s.",
|
||||
result_str = (failed && "FAILURE: " || "SUCCESS: ") + summary_str,
|
||||
result_color = failed && "red+bold" || "green+bold";
|
||||
|
||||
if (this.verbosity === 2) {
|
||||
this.log("");
|
||||
}
|
||||
|
||||
if (this.verbosity > 0) {
|
||||
this.log(this.inColor(result_str, result_color));
|
||||
}
|
||||
|
||||
this.finished = true;
|
||||
},
|
||||
|
||||
reportRunnerStarting: function(runner) {
|
||||
this.started = true;
|
||||
this.start_time = (new Date()).getTime();
|
||||
this.executed_specs = 0;
|
||||
this.passed_specs = 0;
|
||||
},
|
||||
|
||||
reportSpecResults: function(spec) {
|
||||
var color = "red";
|
||||
|
||||
if (spec.results().skipped) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (spec.results().passed()) {
|
||||
this.passed_specs++;
|
||||
color = "green";
|
||||
}
|
||||
|
||||
if (this.verbosity === 2) {
|
||||
var resultText = 'F';
|
||||
|
||||
if (spec.results().passed()) {
|
||||
resultText = '.';
|
||||
}
|
||||
this.log(this.inColor(resultText, color));
|
||||
} else if (this.verbosity > 2) {
|
||||
resultText = "Failed";
|
||||
|
||||
if (spec.results().passed()) {
|
||||
resultText = 'Passed';
|
||||
}
|
||||
this.log(' ' + this.inColor(resultText, color));
|
||||
}
|
||||
if (!spec.results().passed()) {
|
||||
if (this.verbosity === 2) {
|
||||
this.log(" ");
|
||||
this.log(this.indentWithCurrentLevel(this.indent_string + spec.getFullName()));
|
||||
} else if (this.verbosity === 1) {
|
||||
this.log(spec.getFullName());
|
||||
}
|
||||
var items = spec.results().getItems()
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var item = items[i];
|
||||
if (item instanceof jasmine.ExpectationResult && !item.passed()) {
|
||||
this.log(this.inColor(this.indentWithCurrentLevel(this.indent_string + this.indent_string + item.toString()), color));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
reportSpecStarting: function(spec) {
|
||||
this.executed_specs++;
|
||||
if (this.verbosity > 2) {
|
||||
this.logCurrentSuite(spec.suite);
|
||||
|
||||
this.log(this.indentWithCurrentLevel(this.indent_string + spec.description + ' ...'));
|
||||
}
|
||||
},
|
||||
|
||||
reportSuiteResults: function(suite) {
|
||||
var results = suite.results(),
|
||||
failed = results.totalCount - results.passedCount,
|
||||
color = failed ? "red+bold" : "green+bold";
|
||||
|
||||
if (this.verbosity > 2) {
|
||||
this.logCurrentSuite(suite);
|
||||
this.log(this.indentWithCurrentLevel(this.inColor(results.passedCount + " of "
|
||||
+ results.totalCount + " passed.", color)));
|
||||
}
|
||||
},
|
||||
|
||||
indentWithCurrentLevel: function(string) {
|
||||
return new Array(this.current_suite_hierarchy.length).join(this.indent_string) + string;
|
||||
},
|
||||
|
||||
recursivelyUpdateHierarchyUpToRootAndLogNewBranches: function(suite) {
|
||||
var suite_path = [],
|
||||
current_level;
|
||||
|
||||
if (suite.parentSuite != null) {
|
||||
suite_path = this.recursivelyUpdateHierarchyUpToRootAndLogNewBranches(suite.parentSuite);
|
||||
}
|
||||
|
||||
suite_path.push(suite);
|
||||
current_level = suite_path.length - 1;
|
||||
|
||||
if (this.current_suite_hierarchy.length <= current_level
|
||||
|| this.current_suite_hierarchy[current_level] !== suite) {
|
||||
|
||||
this.current_suite_hierarchy = suite_path.slice(0);
|
||||
this.log(this.indentWithCurrentLevel(this.inColor(suite.description, "bold")));
|
||||
}
|
||||
return suite_path;
|
||||
},
|
||||
|
||||
logCurrentSuite: function(suite) {
|
||||
var suite_path = this.recursivelyUpdateHierarchyUpToRootAndLogNewBranches(suite);
|
||||
// If we just popped down from a higher path, we need to update here
|
||||
this.current_suite_hierarchy = suite_path;
|
||||
},
|
||||
|
||||
inColor: function (string, color) {
|
||||
var color_attributes = color && color.split("+"),
|
||||
ansi_string = "",
|
||||
i, attr;
|
||||
|
||||
if (! this.color || ! color_attributes) {
|
||||
return string;
|
||||
}
|
||||
|
||||
for(i = 0; i < color_attributes.length; i++) {
|
||||
ansi_string += "\033[" + ATTRIBUTES_TO_ANSI[color_attributes[i]] + "m";
|
||||
}
|
||||
ansi_string += string + "\033[" + ATTRIBUTES_TO_ANSI["off"] + "m";
|
||||
|
||||
return ansi_string;
|
||||
},
|
||||
|
||||
log: function(str) {
|
||||
var console = jasmine.getGlobal().console;
|
||||
if (console && console.log) {
|
||||
console.log(str);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// export public
|
||||
jasmine.TerminalReporter = TerminalReporter;
|
||||
})();
|
||||
5
6/node_modules/jasmine-reporters/src/load_reporters.js
generated
vendored
Normal file
5
6/node_modules/jasmine-reporters/src/load_reporters.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
require("./jasmine.console_reporter.js")
|
||||
require("./jasmine.junit_reporter.js")
|
||||
require("./jasmine.nunit_reporter.js")
|
||||
require("./jasmine.teamcity_reporter.js")
|
||||
require("./jasmine.tap_reporter.js")
|
||||
266
6/node_modules/jasmine-reporters/test/JUnitXmlReporterSpec.js
generated
vendored
Normal file
266
6/node_modules/jasmine-reporters/test/JUnitXmlReporterSpec.js
generated
vendored
Normal file
@@ -0,0 +1,266 @@
|
||||
(function(){
|
||||
var env, spec, suite, reporter, runner;
|
||||
function fakeSpec(suite, name) {
|
||||
var s = new jasmine.Spec(env, suite, name);
|
||||
suite.add(s);
|
||||
return s;
|
||||
}
|
||||
function fakeSuite(name, parentSuite) {
|
||||
var s = new jasmine.Suite(env, name, null, parentSuite || null);
|
||||
if (parentSuite) {
|
||||
parentSuite.add(s);
|
||||
}
|
||||
runner.add(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
// make sure reporter is set before calling this
|
||||
function triggerSuiteEvents(suites) {
|
||||
for (var i=0; i<suites.length; i++) {
|
||||
var s = suites[i];
|
||||
for (var j=0; j<s.specs().length; j++) {
|
||||
reporter.reportSpecStarting(s.specs()[j]);
|
||||
reporter.reportSpecResults(s.specs()[j]);
|
||||
}
|
||||
reporter.reportSuiteResults(s);
|
||||
}
|
||||
}
|
||||
|
||||
describe("JUnitXmlReporter", function(){
|
||||
|
||||
beforeEach(function(){
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
runner = new jasmine.Runner(env);
|
||||
|
||||
suite = fakeSuite("ParentSuite");
|
||||
spec = fakeSpec(suite, "should be a dummy with invalid characters: & < > \" '");
|
||||
reporter = new jasmine.JUnitXmlReporter();
|
||||
});
|
||||
|
||||
describe("constructor", function(){
|
||||
it("should default path to an empty string", function(){
|
||||
expect(reporter.savePath).toEqual("");
|
||||
});
|
||||
it("should default consolidate to true", function(){
|
||||
expect(reporter.consolidate).toBe(true);
|
||||
});
|
||||
it("should default useDotNotation to true", function(){
|
||||
expect(reporter.useDotNotation).toBe(true);
|
||||
});
|
||||
|
||||
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));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("reportSpecStarting", function(){
|
||||
it("should add start time", function(){
|
||||
reporter.reportSpecStarting(spec);
|
||||
expect(spec.startTime).not.toBeUndefined();
|
||||
});
|
||||
it("should add start time to the suite", function(){
|
||||
expect(suite.startTime).toBeUndefined();
|
||||
reporter.reportSpecStarting(spec);
|
||||
expect(suite.startTime).not.toBeUndefined();
|
||||
});
|
||||
it("should not add start time to the suite if it already exists", function(){
|
||||
var a = new Date();
|
||||
suite.startTime = a;
|
||||
reporter.reportSpecStarting(spec);
|
||||
expect(suite.startTime).toBe(a);
|
||||
});
|
||||
});
|
||||
|
||||
describe("reportSpecResults", function(){
|
||||
beforeEach(function(){
|
||||
reporter.reportSpecStarting(spec);
|
||||
//spec.results_ = fakeResults();
|
||||
reporter.reportSpecResults(spec);
|
||||
});
|
||||
|
||||
it("should compute duration", function(){
|
||||
expect(spec.duration).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it("should generate <testcase> output", function(){
|
||||
expect(spec.output).not.toBeUndefined();
|
||||
expect(spec.output).toContain("<testcase");
|
||||
});
|
||||
|
||||
it("should escape bad xml characters in spec description", function() {
|
||||
expect(spec.output).toContain("& &lt; &gt; &quot; &apos;");
|
||||
});
|
||||
|
||||
it("should generate valid xml <failure> output if test failed", function(){
|
||||
spec = fakeSpec(suite, "should be a dummy");
|
||||
reporter.reportSpecStarting(spec);
|
||||
|
||||
var expectationResult = new jasmine.ExpectationResult({
|
||||
matcherName: "toEqual", passed: false,
|
||||
message: "Expected 'a' to equal '&'.",
|
||||
trace: { stack: "in test1.js:12\nin test2.js:123" }
|
||||
});
|
||||
|
||||
var results = {
|
||||
passed: function() { return false; },
|
||||
getItems: function() { return [expectationResult]; }
|
||||
};
|
||||
|
||||
spyOn(spec, "results").andReturn(results);
|
||||
|
||||
reporter.reportSpecResults(spec);
|
||||
|
||||
expect(spec.output).toContain("<failure");
|
||||
expect(spec.output).toContain("type=\"" + expectationResult.type + "\"");
|
||||
expect(spec.output).toContain("message=\"Expected &apos;a&apos; to equal &apos;&&apos;.\"");
|
||||
expect(spec.output).toContain(">in test1.js:12\nin test2.js:123</failure>");
|
||||
});
|
||||
});
|
||||
|
||||
describe("reportSuiteResults", function(){
|
||||
beforeEach(function(){
|
||||
triggerSuiteEvents([suite]);
|
||||
});
|
||||
it("should compute duration", function(){
|
||||
expect(suite.duration).not.toBeUndefined();
|
||||
});
|
||||
it("should generate startTime if no specs were executed", function(){
|
||||
suite = fakeSuite("just a fake suite");
|
||||
triggerSuiteEvents([suite]);
|
||||
expect(suite.startTime).not.toBeUndefined();
|
||||
});
|
||||
it("should generate <testsuite> output", function(){
|
||||
expect(suite.output).not.toBeUndefined();
|
||||
expect(suite.output).toContain("<testsuite");
|
||||
});
|
||||
it("should contain <testcase> output from specs", function(){
|
||||
expect(suite.output).toContain("<testcase");
|
||||
});
|
||||
});
|
||||
|
||||
describe("reportRunnerResults", function(){
|
||||
var subSuite, subSubSuite, siblingSuite;
|
||||
|
||||
beforeEach(function(){
|
||||
subSuite = fakeSuite("SubSuite", suite);
|
||||
subSubSuite = fakeSuite("SubSubSuite", subSuite);
|
||||
siblingSuite = fakeSuite("SiblingSuite With Invalid Chars & < > \" ' | : \\ /");
|
||||
var subSpec = fakeSpec(subSuite, "should be one level down");
|
||||
var subSubSpec = fakeSpec(subSubSuite, "should be two levels down");
|
||||
var siblingSpec = fakeSpec(siblingSuite, "should be a sibling of Parent");
|
||||
|
||||
spyOn(reporter, "writeFile");
|
||||
spyOn(reporter, "getNestedOutput").andCallThrough();
|
||||
triggerSuiteEvents([suite, subSuite, subSubSuite, siblingSuite]);
|
||||
});
|
||||
|
||||
describe("general functionality", function() {
|
||||
beforeEach(function() {
|
||||
reporter.reportRunnerResults(runner);
|
||||
});
|
||||
it("should remove invalid filename chars from the filename", function() {
|
||||
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 & &lt; &gt; &quot; &apos; | : \\ /");
|
||||
});
|
||||
});
|
||||
|
||||
describe("consolidated is true and consolidatedAll is false", function(){
|
||||
beforeEach(function(){
|
||||
reporter.reportRunnerResults(runner);
|
||||
});
|
||||
it("should write one file per parent suite", function(){
|
||||
expect(reporter.writeFile.callCount).toEqual(2);
|
||||
});
|
||||
it("should consolidate suite output", function(){
|
||||
expect(reporter.getNestedOutput.callCount).toEqual(4);
|
||||
});
|
||||
it("should wrap output in <testsuites>", function(){
|
||||
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][2]).toContain("<?xml");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("consolidated is false and consolidatedAll is false", function(){
|
||||
beforeEach(function(){
|
||||
reporter.consolidate = false;
|
||||
reporter.reportRunnerResults(runner);
|
||||
});
|
||||
it("should write one file per suite", function(){
|
||||
expect(reporter.writeFile.callCount).toEqual(4);
|
||||
});
|
||||
it("should not wrap results in <testsuites>", function(){
|
||||
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][2]).toContain("<?xml");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("consolidatedAll is true", function(){
|
||||
beforeEach(function(){
|
||||
reporter.consolidateAll = true;
|
||||
reporter.reportRunnerResults(runner);
|
||||
});
|
||||
it("should write one file for all test suites", function(){
|
||||
expect(reporter.writeFile.callCount).toEqual(1);
|
||||
});
|
||||
it("should consolidate suites output", function(){
|
||||
expect(reporter.getNestedOutput.callCount).toEqual(4);
|
||||
});
|
||||
it("should wrap output in <testsuites>", function(){
|
||||
expect(reporter.writeFile.mostRecentCall.args[2]).toContain("<testsuites>");
|
||||
});
|
||||
it("should include xml header in the file", function(){
|
||||
expect(reporter.writeFile.argsForCall[0][2]).toContain("<?xml");
|
||||
});
|
||||
});
|
||||
describe("dot notation is true", function(){
|
||||
beforeEach(function(){
|
||||
reporter.reportRunnerResults(runner);
|
||||
});
|
||||
it("should separate descriptions with dot notation", function(){
|
||||
expect(subSubSuite.output).toContain('classname="ParentSuite.SubSuite.SubSubSuite"');
|
||||
});
|
||||
});
|
||||
|
||||
describe("dot notation is false", function(){
|
||||
beforeEach(function(){
|
||||
reporter.useDotNotation = false;
|
||||
triggerSuiteEvents([suite, subSuite, subSubSuite, siblingSuite]);
|
||||
reporter.reportRunnerResults(runner);
|
||||
});
|
||||
it("should separate descriptions with whitespace", function(){
|
||||
expect(subSubSuite.output).toContain('classname="ParentSuite SubSuite SubSubSuite"');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
||||
164
6/node_modules/jasmine-reporters/test/NUnitXmlReporterSpec.js
generated
vendored
Normal file
164
6/node_modules/jasmine-reporters/test/NUnitXmlReporterSpec.js
generated
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
/* globals jasmine, describe, beforeEach, afterEach, it, expect, spyOn */
|
||||
(function(){
|
||||
var env, suite, subSuite, subSubSuite, siblingSuite, reporter, runner;
|
||||
function fakeSpec(suite, name) {
|
||||
var s = new jasmine.Spec(env, suite, name);
|
||||
suite.add(s);
|
||||
return s;
|
||||
}
|
||||
function fakeSuite(name, parentSuite) {
|
||||
var s = new jasmine.Suite(env, name, null, parentSuite || null);
|
||||
if (parentSuite) {
|
||||
parentSuite.add(s);
|
||||
}
|
||||
runner.add(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
// make sure reporter is set before calling this
|
||||
function triggerSuiteEvents(suites) {
|
||||
for (var i=0; i<suites.length; i++) {
|
||||
var s = suites[i];
|
||||
for (var j=0; j<s.specs().length; j++) {
|
||||
reporter.reportSpecStarting(s.specs()[j]);
|
||||
reporter.reportSpecResults(s.specs()[j]);
|
||||
}
|
||||
reporter.reportSuiteResults(s);
|
||||
}
|
||||
}
|
||||
|
||||
describe("NUnitXmlReporter", function(){
|
||||
|
||||
beforeEach(function(){
|
||||
env = new jasmine.Env();
|
||||
env.updateInterval = 0;
|
||||
runner = new jasmine.Runner(env);
|
||||
|
||||
suite = fakeSuite("ParentSuite");
|
||||
subSuite = fakeSuite("SubSuite", suite);
|
||||
subSubSuite = fakeSuite("SubSubSuite", subSuite);
|
||||
siblingSuite = fakeSuite("SiblingSuite With Invalid Chars & < > \" ' | : \\ /");
|
||||
var spec = fakeSpec(suite, "should be a dummy with invalid characters: & < >");
|
||||
var failedSpec = fakeSpec(suite, "should be failed");
|
||||
failedSpec.fail(Error("I failed"));
|
||||
var subSpec = fakeSpec(subSuite, "should be one level down");
|
||||
var subSubSpec1 = fakeSpec(subSubSuite, "(1) should be two levels down");
|
||||
var subSubSpec2 = fakeSpec(subSubSuite, "(2) should be two levels down");
|
||||
var subSubSpec3 = fakeSpec(subSubSuite, "(3) should be two levels down");
|
||||
var siblingSpec = fakeSpec(siblingSuite, "should be a sibling of Parent");
|
||||
reporter = new jasmine.NUnitXmlReporter({reportName: "<Bad Character Report>"});
|
||||
});
|
||||
|
||||
describe("constructor", function(){
|
||||
it("should default path to an empty string", function(){
|
||||
reporter = new jasmine.NUnitXmlReporter();
|
||||
expect(reporter.savePath).toBe("");
|
||||
});
|
||||
it("should allow a custom path to be provided", function() {
|
||||
reporter = new jasmine.NUnitXmlReporter({savePath:"/tmp"});
|
||||
expect(reporter.savePath).toBe("/tmp");
|
||||
});
|
||||
it("should default filename to 'nunit-results.xml'", function(){
|
||||
reporter = new jasmine.NUnitXmlReporter();
|
||||
expect(reporter.filename).toBe("nunit-results.xml");
|
||||
});
|
||||
it("should allow a custom filename to be provided", function() {
|
||||
reporter = new jasmine.NUnitXmlReporter({filename:"results.xml"});
|
||||
expect(reporter.filename).toBe("results.xml");
|
||||
});
|
||||
it("should default reportName to 'Jasmine Results'", function(){
|
||||
reporter = new jasmine.NUnitXmlReporter();
|
||||
expect(reporter.reportName).toBe("Jasmine Results");
|
||||
});
|
||||
it("should allow a custom reportName to be provided", function() {
|
||||
reporter = new jasmine.NUnitXmlReporter({reportName:"Test Results"});
|
||||
expect(reporter.reportName).toBe("Test Results");
|
||||
});
|
||||
});
|
||||
|
||||
describe("reportRunnerResults", function(){
|
||||
var output, xmldoc;
|
||||
|
||||
beforeEach(function(){
|
||||
spyOn(reporter, "writeFile");
|
||||
reporter.reportRunnerStarting(runner);
|
||||
triggerSuiteEvents([suite, siblingSuite, subSuite, subSubSuite]);
|
||||
reporter.reportRunnerResults(runner);
|
||||
output = reporter.writeFile.mostRecentCall.args[0];
|
||||
xmldoc = (new DOMParser()).parseFromString(output, "text/xml");
|
||||
});
|
||||
it("should escape invalid xml chars from report name", function() {
|
||||
expect(output).toContain('name="&lt;Bad Character Report&gt;"');
|
||||
});
|
||||
it("should escape invalid xml chars from suite names", function() {
|
||||
expect(output).toContain('name="SiblingSuite With Invalid Chars & &lt; &gt; &quot; &apos; | : \\ /"');
|
||||
});
|
||||
it("should escape invalid xml chars from spec names", function() {
|
||||
expect(output).toContain('name="should be a dummy with invalid characters: & &lt; &gt;');
|
||||
});
|
||||
describe("xml structure", function() {
|
||||
var rootNode, suites, specs;
|
||||
beforeEach(function() {
|
||||
rootNode = xmldoc.getElementsByTagName("test-results")[0];
|
||||
suites = rootNode.getElementsByTagName("test-suite");
|
||||
specs = rootNode.getElementsByTagName("test-case");
|
||||
});
|
||||
it("should report the date / time that the tests were run", function() {
|
||||
function twoDigits(number) { return number >= 10 ? number : ("0" + number); }
|
||||
var now = new Date();
|
||||
var date = now.getFullYear() + "-" + twoDigits(now.getMonth()+1) + "-" + twoDigits(now.getDate());
|
||||
var time = now.getHours() + ":" + twoDigits(now.getMinutes()) + ":" + twoDigits(now.getSeconds());
|
||||
expect(rootNode.getAttribute("date")).toBe(date);
|
||||
expect(rootNode.getAttribute("time")).toBe(time); // this could fail extremely rarely
|
||||
});
|
||||
it("should report the appropriate number of suites", function() {
|
||||
expect(suites.length).toBe(4);
|
||||
});
|
||||
it("should order suites appropriately", function() {
|
||||
expect(suites[0].getAttribute("name")).toContain("ParentSuite");
|
||||
expect(suites[1].getAttribute("name")).toContain("SubSuite");
|
||||
expect(suites[2].getAttribute("name")).toContain("SubSubSuite");
|
||||
expect(suites[3].getAttribute("name")).toContain("SiblingSuite");
|
||||
});
|
||||
it("should nest suites appropriately", function() {
|
||||
expect(suites[0].parentNode).toBe(rootNode);
|
||||
expect(suites[1].parentNode).toBe(suites[0].getElementsByTagName("results")[0]);
|
||||
expect(suites[2].parentNode).toBe(suites[1].getElementsByTagName("results")[0]);
|
||||
expect(suites[3].parentNode).toBe(rootNode);
|
||||
});
|
||||
it("should report the execution time for test specs", function() {
|
||||
var time;
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
time = specs[i].getAttribute("time");
|
||||
expect(time.length).toBeGreaterThan(0);
|
||||
expect(time).not.toContain(":"); // as partial seconds, not a timestamp
|
||||
}
|
||||
});
|
||||
it("should include a test-case for each spec and report the total number of specs on the root node", function() {
|
||||
expect(rootNode.getAttribute("total")).toBe(specs.length.toString());
|
||||
});
|
||||
describe("passed specs", function() {
|
||||
it("should indicate that the test case was successful", function() {
|
||||
expect(specs[0].getAttribute("success")).toBe("true");
|
||||
});
|
||||
});
|
||||
describe("failed specs", function() {
|
||||
var failedSpec;
|
||||
beforeEach(function() {
|
||||
failedSpec = rootNode.getElementsByTagName("message")[0].parentNode.parentNode;
|
||||
});
|
||||
it("should report the number of failed specs on the root node", function() {
|
||||
expect(rootNode.getAttribute("failures")).toBe("1");
|
||||
});
|
||||
it("should indicate that the test case was not successful", function() {
|
||||
expect(failedSpec.getAttribute("success")).toBe("false");
|
||||
});
|
||||
it("should include the error for failed specs", function() {
|
||||
expect(failedSpec.getElementsByTagName("message")[0].textContent).toContain("I failed");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
||||
36
6/node_modules/jasmine-reporters/test/console_reporter.html
generated
vendored
Normal file
36
6/node_modules/jasmine-reporters/test/console_reporter.html
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Console Reporter Spec</title>
|
||||
|
||||
<link rel="stylesheet" href="../ext/jasmine.css" type="text/css" />
|
||||
|
||||
<script type="text/javascript" src="../ext/jasmine.js"></script>
|
||||
<script type="text/javascript" src="../ext/jasmine-html.js"></script>
|
||||
<script type="text/javascript" src="../src/jasmine.console_reporter.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
describe("Basic Suite", function() {
|
||||
it("Should pass a basic truthiness test.", function() {
|
||||
expect(true).toEqual(true);
|
||||
});
|
||||
|
||||
it("Should fail when it hits an inequal statement.", function() {
|
||||
expect(1+1).toEqual(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Another Suite", function() {
|
||||
it("Should pass this test as well.", function() {
|
||||
expect(0).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
jasmine.getEnv().addReporter(new jasmine.ConsoleReporter());
|
||||
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
||||
jasmine.getEnv().execute();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
14
6/node_modules/jasmine-reporters/test/envjs.bootstrap.js
generated
vendored
Normal file
14
6/node_modules/jasmine-reporters/test/envjs.bootstrap.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
load('../ext/env.rhino.1.2.js');
|
||||
|
||||
Envjs.scriptTypes['text/javascript'] = true;
|
||||
|
||||
var specFile;
|
||||
|
||||
for (i = 0; i < arguments.length; i++) {
|
||||
specFile = arguments[i];
|
||||
|
||||
console.log("Loading: " + specFile);
|
||||
|
||||
window.location = specFile
|
||||
}
|
||||
|
||||
7
6/node_modules/jasmine-reporters/test/envjs.runner.sh
generated
vendored
Normal file
7
6/node_modules/jasmine-reporters/test/envjs.runner.sh
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# cleanup previous test runs
|
||||
rm -f *.xml
|
||||
|
||||
# fire up the envjs environment
|
||||
java -cp ../ext/js.jar:../ext/jline.jar org.mozilla.javascript.tools.shell.Main -opt -1 envjs.bootstrap.js $@
|
||||
23
6/node_modules/jasmine-reporters/test/junit_xml_reporter.html
generated
vendored
Normal file
23
6/node_modules/jasmine-reporters/test/junit_xml_reporter.html
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>JUnit XML Reporter Spec</title>
|
||||
|
||||
<link rel="stylesheet" href="../ext/jasmine.css" type="text/css" />
|
||||
|
||||
<script type="text/javascript" src="../ext/jasmine.js"></script>
|
||||
<script type="text/javascript" src="../ext/jasmine-html.js"></script>
|
||||
<script type="text/javascript" src="../src/jasmine.junit_reporter.js"></script>
|
||||
|
||||
<!-- Include spec file -->
|
||||
<script type="text/javascript" src="JUnitXmlReporterSpec.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
||||
jasmine.getEnv().addReporter(new jasmine.JUnitXmlReporter());
|
||||
jasmine.getEnv().execute();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
24
6/node_modules/jasmine-reporters/test/nunit_xml_reporter.html
generated
vendored
Normal file
24
6/node_modules/jasmine-reporters/test/nunit_xml_reporter.html
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>JUnit XML Reporter Spec</title>
|
||||
|
||||
<link rel="stylesheet" href="../ext/jasmine.css" type="text/css" />
|
||||
|
||||
<script type="text/javascript" src="../ext/jasmine.js"></script>
|
||||
<script type="text/javascript" src="../ext/jasmine-html.js"></script>
|
||||
<script type="text/javascript" src="../src/jasmine.nunit_reporter.js"></script>
|
||||
<script type="text/javascript" src="../src/jasmine.terminal_reporter.js"></script>
|
||||
|
||||
<!-- Include spec file -->
|
||||
<script type="text/javascript" src="NUnitXmlReporterSpec.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
||||
jasmine.getEnv().addReporter(new jasmine.NUnitXmlReporter());
|
||||
jasmine.getEnv().execute();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
223
6/node_modules/jasmine-reporters/test/phantomjs-testrunner.js
generated
vendored
Normal file
223
6/node_modules/jasmine-reporters/test/phantomjs-testrunner.js
generated
vendored
Normal file
@@ -0,0 +1,223 @@
|
||||
/* globals jasmine, phantom */
|
||||
// Verify arguments
|
||||
var system = require('system');
|
||||
var args;
|
||||
|
||||
if(phantom.args) {
|
||||
args = phantom.args;
|
||||
} else {
|
||||
args = system.args.slice(1);//use system args for phantom 2.0+
|
||||
}
|
||||
|
||||
if (args.length === 0) {
|
||||
console.log("Simple JasmineBDD test runner for phantom.js");
|
||||
console.log("Usage: phantomjs-testrunner.js url_to_runner.html");
|
||||
console.log("Accepts http:// and file:// urls");
|
||||
console.log("");
|
||||
console.log("NOTE: This script depends on jasmine.TrivialReporter being used\non the page, for the DOM elements it creates.\n");
|
||||
phantom.exit(2);
|
||||
}
|
||||
else {
|
||||
var fs = require("fs"),
|
||||
pages = [],
|
||||
page, address, resultsKey, i, l;
|
||||
|
||||
|
||||
var setupPageFn = function(p, k) {
|
||||
return function() {
|
||||
overloadPageEvaluate(p);
|
||||
setupWriteFileFunction(p, k, fs.separator);
|
||||
};
|
||||
};
|
||||
|
||||
for (i = 0, l = args.length; i < l; i++) {
|
||||
address = args[i];
|
||||
console.log("Loading " + address);
|
||||
|
||||
// if provided a url without a protocol, try to use file://
|
||||
address = address.indexOf("://") === -1 ? "file://" + address : address;
|
||||
|
||||
// create a WebPage object to work with
|
||||
page = require("webpage").create();
|
||||
page.url = address;
|
||||
|
||||
// When initialized, inject the reporting functions before the page is loaded
|
||||
// (and thus before it will try to utilize the functions)
|
||||
resultsKey = "__jr" + Math.ceil(Math.random() * 1000000);
|
||||
page.onInitialized = setupPageFn(page, resultsKey);
|
||||
page.open(address, processPage(null, page, resultsKey));
|
||||
pages.push(page);
|
||||
|
||||
page.onConsoleMessage = logAndWorkAroundDefaultLineBreaking;
|
||||
}
|
||||
|
||||
// bail when all pages have been processed
|
||||
setInterval(function(){
|
||||
var exit_code = 0;
|
||||
for (i = 0, l = pages.length; i < l; i++) {
|
||||
page = pages[i];
|
||||
if (page.__exit_code === null) {
|
||||
// wait until later
|
||||
return;
|
||||
}
|
||||
exit_code |= page.__exit_code;
|
||||
}
|
||||
phantom.exit(exit_code);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
// Thanks to hoisting, these helpers are still available when needed above
|
||||
/**
|
||||
* 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 {
|
||||
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.
|
||||
*
|
||||
* @param {function} fn The function to replace occurrences within.
|
||||
* @param {object} replacements Key => Value object of string replacements.
|
||||
*/
|
||||
function replaceFunctionPlaceholders(fn, replacements) {
|
||||
if (replacements && typeof replacements === "object") {
|
||||
fn = fn.toString();
|
||||
for (var p in replacements) {
|
||||
if (replacements.hasOwnProperty(p)) {
|
||||
var match = new RegExp("%" + p + "%", "g");
|
||||
do {
|
||||
fn = fn.replace(match, replacements[p]);
|
||||
} while(fn.indexOf(match) !== -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return fn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the "evaluate" method with one we can easily do substitution with.
|
||||
*
|
||||
* @param {phantomjs.WebPage} page The WebPage object to overload
|
||||
*/
|
||||
function overloadPageEvaluate(page) {
|
||||
page._evaluate = page.evaluate;
|
||||
page.evaluate = function(fn, replacements) { return page._evaluate(replaceFunctionPlaceholders(fn, replacements)); };
|
||||
return page;
|
||||
}
|
||||
|
||||
/** Stubs a fake writeFile function into the test runner.
|
||||
*
|
||||
* @param {phantomjs.WebPage} page The WebPage object to inject functions into.
|
||||
* @param {string} key The name of the global object in which file data should
|
||||
* be stored for later retrieval.
|
||||
*/
|
||||
// TODO: not bothering with error checking for now (closed environment)
|
||||
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, fs_path_separator: path_separator.replace("\\", "\\\\")});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the loaded page's filename => output object.
|
||||
*
|
||||
* @param {phantomjs.WebPage} page The WebPage object to retrieve data from.
|
||||
* @param {string} key The name of the global object to be returned. Should
|
||||
* be the same key provided to setupWriteFileFunction.
|
||||
*/
|
||||
function getXmlResults(page, key) {
|
||||
return page.evaluate(function(){
|
||||
return window["%resultsObj%"] || {};
|
||||
}, {resultsObj: key});
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a page.
|
||||
*
|
||||
* @param {string} status The status from opening the page via WebPage#open.
|
||||
* @param {phantomjs.WebPage} page The WebPage to be processed.
|
||||
*/
|
||||
function processPage(status, page, resultsKey) {
|
||||
if (status === null && page) {
|
||||
page.__exit_code = null;
|
||||
return function(stat){
|
||||
processPage(stat, page, resultsKey);
|
||||
};
|
||||
}
|
||||
if (status !== "success") {
|
||||
console.error("Unable to load resource: " + address);
|
||||
page.__exit_code = 2;
|
||||
}
|
||||
else {
|
||||
var isFinished = function() {
|
||||
return page.evaluate(function(){
|
||||
// if there's a JUnitXmlReporter, return a boolean indicating if it is finished
|
||||
if (jasmine && jasmine.JUnitXmlReporter && jasmine.JUnitXmlReporter.started_at !== null) {
|
||||
return jasmine.JUnitXmlReporter.finished_at !== null;
|
||||
}
|
||||
// otherwise, see if there is anything in a "finished-at" element
|
||||
return document.getElementsByClassName("finished-at").length &&
|
||||
document.getElementsByClassName("finished-at")[0].innerHTML.length > 0;
|
||||
});
|
||||
};
|
||||
var getResults = function() {
|
||||
return page.evaluate(function(){
|
||||
return document.getElementsByClassName("description").length &&
|
||||
document.getElementsByClassName("description")[0].innerHTML.match(/(\d+) spec.* (\d+) failure.*/) ||
|
||||
["Unable to determine success or failure."];
|
||||
});
|
||||
};
|
||||
var timeout = 60000;
|
||||
var loopInterval = 100;
|
||||
var ival = setInterval(function(){
|
||||
if (isFinished()) {
|
||||
// get the results that need to be written to disk
|
||||
var fs = require("fs"),
|
||||
xml_results = getXmlResults(page, resultsKey),
|
||||
output;
|
||||
for (var filename in xml_results) {
|
||||
if (xml_results.hasOwnProperty(filename) && (output = xml_results[filename]) && typeof(output) === "string") {
|
||||
fs.write(filename, output, "w");
|
||||
}
|
||||
}
|
||||
|
||||
// print out a success / failure message of the results
|
||||
var results = getResults();
|
||||
var failures = Number(results[2]);
|
||||
if (failures > 0) {
|
||||
page.__exit_code = 1;
|
||||
clearInterval(ival);
|
||||
}
|
||||
else {
|
||||
page.__exit_code = 0;
|
||||
clearInterval(ival);
|
||||
}
|
||||
}
|
||||
else {
|
||||
timeout -= loopInterval;
|
||||
if (timeout <= 0) {
|
||||
console.log('Page has timed out; aborting.');
|
||||
page.__exit_code = 2;
|
||||
clearInterval(ival);
|
||||
}
|
||||
}
|
||||
}, loopInterval);
|
||||
}
|
||||
}
|
||||
40
6/node_modules/jasmine-reporters/test/phantomjs.runner.sh
generated
vendored
Normal file
40
6/node_modules/jasmine-reporters/test/phantomjs.runner.sh
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/bin/bash
|
||||
|
||||
# sanity check to make sure phantomjs exists in the PATH
|
||||
hash /usr/bin/env phantomjs &> /dev/null
|
||||
if [ $? -eq 1 ]; then
|
||||
echo "ERROR: phantomjs is not installed"
|
||||
echo "Please visit http://www.phantomjs.org/"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# sanity check number of args
|
||||
if [ $# -lt 1 ]
|
||||
then
|
||||
echo "Usage: `basename $0` path_to_runner.html"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SCRIPTDIR=$(dirname `perl -e 'use Cwd "abs_path";print abs_path(shift)' $0`)
|
||||
TESTFILE=""
|
||||
while (( "$#" )); do
|
||||
if [ ${1:0:7} == "http://" -o ${1:0:8} == "https://" ]; then
|
||||
TESTFILE="$TESTFILE $1"
|
||||
else
|
||||
TESTFILE="$TESTFILE `perl -e 'use Cwd "abs_path";print abs_path(shift)' $1`"
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
# cleanup previous test runs
|
||||
cd $SCRIPTDIR
|
||||
rm -f *.xml
|
||||
|
||||
# make sure phantomjs submodule is initialized
|
||||
cd ..
|
||||
git submodule update --init
|
||||
|
||||
# fire up the phantomjs environment and run the test
|
||||
cd $SCRIPTDIR
|
||||
/usr/bin/env phantomjs $SCRIPTDIR/phantomjs-testrunner.js $TESTFILE
|
||||
37
6/node_modules/jasmine-reporters/test/tap_reporter.html
generated
vendored
Normal file
37
6/node_modules/jasmine-reporters/test/tap_reporter.html
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Console Reporter Spec</title>
|
||||
|
||||
<link rel="stylesheet" href="../ext/jasmine.css" type="text/css" />
|
||||
|
||||
<script type="text/javascript" src="../ext/jasmine.js"></script>
|
||||
<script type="text/javascript" src="../ext/jasmine-html.js"></script>
|
||||
<script type="text/javascript" src="../src/jasmine.tap_reporter.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
describe("Basic Suite", function() {
|
||||
it("Should pass a basic truthiness test.", function() {
|
||||
expect(true).toEqual(true);
|
||||
expect(false).toEqual(false);
|
||||
});
|
||||
|
||||
it("Should fail when it hits an inequal statement.", function() {
|
||||
expect(1+1).toEqual(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Another Suite", function() {
|
||||
it("Should pass this test as well.", function() {
|
||||
expect(0).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
jasmine.getEnv().addReporter(new jasmine.TapReporter());
|
||||
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
||||
jasmine.getEnv().execute();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
36
6/node_modules/jasmine-reporters/test/teamcity_reporter.html
generated
vendored
Normal file
36
6/node_modules/jasmine-reporters/test/teamcity_reporter.html
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Console Reporter Spec</title>
|
||||
|
||||
<link rel="stylesheet" href="../ext/jasmine.css" type="text/css" />
|
||||
|
||||
<script type="text/javascript" src="../ext/jasmine.js"></script>
|
||||
<script type="text/javascript" src="../ext/jasmine-html.js"></script>
|
||||
<script type="text/javascript" src="../src/jasmine.teamcity_reporter.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
describe("Basic Suite", function() {
|
||||
it("Should pass a basic truthiness test.", function() {
|
||||
expect(true).toEqual(true);
|
||||
});
|
||||
|
||||
it("Should fail when it hits an inequal statement.", function() {
|
||||
expect(1+1).toEqual(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Another Suite", function() {
|
||||
it("Should pass this test as well.", function() {
|
||||
expect(0).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
jasmine.getEnv().addReporter(new jasmine.TeamcityReporter());
|
||||
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
||||
jasmine.getEnv().execute();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
39
6/node_modules/jasmine-reporters/test/terminal_reporter.html
generated
vendored
Normal file
39
6/node_modules/jasmine-reporters/test/terminal_reporter.html
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Terminal Reporter Spec</title>
|
||||
|
||||
<link rel="stylesheet" href="../ext/jasmine.css" type="text/css" />
|
||||
|
||||
<script type="text/javascript" src="../ext/jasmine.js"></script>
|
||||
<script type="text/javascript" src="../ext/jasmine-html.js"></script>
|
||||
<script type="text/javascript" src="../src/jasmine.terminal_reporter.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
describe("Basic Suite", function() {
|
||||
it("Should pass a basic truthiness test.", function() {
|
||||
expect(true).toEqual(true);
|
||||
});
|
||||
|
||||
it("Should fail when it hits an inequal statement.", function() {
|
||||
expect(1+1).toEqual(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Another Suite", function() {
|
||||
it("Should pass this test as well.", function() {
|
||||
expect(0).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
jasmine.getEnv().addReporter(new jasmine.TerminalReporter({
|
||||
verbosity: 3,
|
||||
color: true
|
||||
}));
|
||||
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
|
||||
jasmine.getEnv().execute();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user