mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Revert "Revert "tests: updating mocha and refactoring the custom html reporter using events""
This reverts commit 2ce798339d
.
This commit is contained in:
parent
c5584fb5b4
commit
d1efa509e6
3 changed files with 16077 additions and 2852 deletions
|
@ -14,7 +14,7 @@
|
||||||
<script src="lib/underscore.js"></script>
|
<script src="lib/underscore.js"></script>
|
||||||
|
|
||||||
<script src="lib/mocha.js"></script>
|
<script src="lib/mocha.js"></script>
|
||||||
<script> mocha.setup('bdd') </script>
|
<script> mocha.setup({ui: 'bdd', ignoreLeaks: true}) </script>
|
||||||
<script src="lib/expect.js"></script>
|
<script src="lib/expect.js"></script>
|
||||||
|
|
||||||
<script src="lib/sendkeys.js"></script>
|
<script src="lib/sendkeys.js"></script>
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,26 @@
|
||||||
$(function(){
|
$(function(){
|
||||||
function Base(runner) {
|
|
||||||
|
function stringifyException(exception){
|
||||||
|
var err = exception.stack || exception.toString();
|
||||||
|
|
||||||
|
// FF / Opera do not add the message
|
||||||
|
if (!~err.indexOf(exception.message)) {
|
||||||
|
err = exception.message + '\n' + err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <=IE7 stringifies to [Object Error]. Since it can be overloaded, we
|
||||||
|
// check for the result of the stringifying.
|
||||||
|
if ('[object Error]' == err) err = exception.message;
|
||||||
|
|
||||||
|
// Safari doesn't give you a stack. Let's at least provide a source line.
|
||||||
|
if (!exception.stack && exception.sourceURL && exception.line !== undefined) {
|
||||||
|
err += "\n(" + exception.sourceURL + ":" + exception.line + ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
function CustomRunner(runner) {
|
||||||
var self = this
|
var self = this
|
||||||
, stats = this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, failures: 0 }
|
, stats = this.stats = { suites: 0, tests: 0, passes: 0, pending: 0, failures: 0 }
|
||||||
, failures = this.failures = [];
|
, failures = this.failures = [];
|
||||||
|
@ -14,11 +35,42 @@ $(function(){
|
||||||
runner.on('suite', function(suite){
|
runner.on('suite', function(suite){
|
||||||
stats.suites = stats.suites || 0;
|
stats.suites = stats.suites || 0;
|
||||||
suite.root || stats.suites++;
|
suite.root || stats.suites++;
|
||||||
|
if (suite.root) return;
|
||||||
|
append(suite.title);
|
||||||
|
level++;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
runner.on('suite end', function(suite){
|
||||||
|
if (suite.root) return;
|
||||||
|
level--;
|
||||||
|
|
||||||
|
if(level == 0) {
|
||||||
|
append("");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Scroll down test display after each test
|
||||||
|
mocha = $('#mocha')[0];
|
||||||
|
runner.on('test', function(){
|
||||||
|
mocha.scrollTop = mocha.scrollHeight;
|
||||||
|
});
|
||||||
|
|
||||||
|
var killTimeout;
|
||||||
runner.on('test end', function(test){
|
runner.on('test end', function(test){
|
||||||
stats.tests = stats.tests || 0;
|
stats.tests = stats.tests || 0;
|
||||||
stats.tests++;
|
stats.tests++;
|
||||||
|
if ('passed' == test.state) {
|
||||||
|
append("->","[green]PASSED[clear] :", test.title);
|
||||||
|
} else if (test.pending) {
|
||||||
|
append("->","[yellow]PENDING[clear]:", test.title);
|
||||||
|
} else {
|
||||||
|
append("->","[red]FAILED[clear] :", test.title, stringifyException(test.err));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(killTimeout) clearTimeout(killTimeout);
|
||||||
|
killTimeout = setTimeout(function(){
|
||||||
|
append("FINISHED - [red]no test started since 3 minutes, tests stopped[clear]");
|
||||||
|
}, 60000 * 3);
|
||||||
});
|
});
|
||||||
|
|
||||||
runner.on('pass', function(test){
|
runner.on('pass', function(test){
|
||||||
|
@ -49,26 +101,8 @@ $(function(){
|
||||||
runner.on('pending', function(){
|
runner.on('pending', function(){
|
||||||
stats.pending++;
|
stats.pending++;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
var $console = $("#console");
|
||||||
This reporter wraps the original html reporter plus reports plain text into a hidden div.
|
|
||||||
This allows the webdriver client to pick up the test results
|
|
||||||
*/
|
|
||||||
var WebdriverAndHtmlReporter = function(html_reporter){
|
|
||||||
return function(runner){
|
|
||||||
Base.call(this, runner);
|
|
||||||
|
|
||||||
// Scroll down test display after each test
|
|
||||||
mocha = $('#mocha')[0];
|
|
||||||
runner.on('test', function(){
|
|
||||||
mocha.scrollTop = mocha.scrollHeight;
|
|
||||||
});
|
|
||||||
|
|
||||||
//initalize the html reporter first
|
|
||||||
html_reporter(runner);
|
|
||||||
|
|
||||||
var $console = $("#console");
|
|
||||||
var level = 0;
|
var level = 0;
|
||||||
var append = function(){
|
var append = function(){
|
||||||
var text = Array.prototype.join.apply(arguments, [" "]);
|
var text = Array.prototype.join.apply(arguments, [" "]);
|
||||||
|
@ -97,58 +131,6 @@ $(function(){
|
||||||
$console.text(oldText + newText + "\\n");
|
$console.text(oldText + newText + "\\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
runner.on('suite', function(suite){
|
|
||||||
if (suite.root) return;
|
|
||||||
|
|
||||||
append(suite.title);
|
|
||||||
level++;
|
|
||||||
});
|
|
||||||
|
|
||||||
runner.on('suite end', function(suite){
|
|
||||||
if (suite.root) return;
|
|
||||||
level--;
|
|
||||||
|
|
||||||
if(level == 0) {
|
|
||||||
append("");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var stringifyException = function(exception){
|
|
||||||
var err = exception.stack || exception.toString();
|
|
||||||
|
|
||||||
// FF / Opera do not add the message
|
|
||||||
if (!~err.indexOf(exception.message)) {
|
|
||||||
err = exception.message + '\n' + err;
|
|
||||||
}
|
|
||||||
|
|
||||||
// <=IE7 stringifies to [Object Error]. Since it can be overloaded, we
|
|
||||||
// check for the result of the stringifying.
|
|
||||||
if ('[object Error]' == err) err = exception.message;
|
|
||||||
|
|
||||||
// Safari doesn't give you a stack. Let's at least provide a source line.
|
|
||||||
if (!exception.stack && exception.sourceURL && exception.line !== undefined) {
|
|
||||||
err += "\n(" + exception.sourceURL + ":" + exception.line + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
var killTimeout;
|
|
||||||
runner.on('test end', function(test){
|
|
||||||
if ('passed' == test.state) {
|
|
||||||
append("->","[green]PASSED[clear] :", test.title);
|
|
||||||
} else if (test.pending) {
|
|
||||||
append("->","[yellow]PENDING[clear]:", test.title);
|
|
||||||
} else {
|
|
||||||
append("->","[red]FAILED[clear] :", test.title, stringifyException(test.err));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(killTimeout) clearTimeout(killTimeout);
|
|
||||||
killTimeout = setTimeout(function(){
|
|
||||||
append("FINISHED - [red]no test started since 3 minutes, tests stopped[clear]");
|
|
||||||
}, 60000 * 3);
|
|
||||||
});
|
|
||||||
|
|
||||||
var total = runner.total;
|
var total = runner.total;
|
||||||
runner.on('end', function(){
|
runner.on('end', function(){
|
||||||
if(stats.tests >= total){
|
if(stats.tests >= total){
|
||||||
|
@ -158,7 +140,6 @@ $(function(){
|
||||||
append("FINISHED -", stats.passes, "tests passed,", stats.failures, "tests failed, duration: " + minutes + ":" + seconds);
|
append("FINISHED -", stats.passes, "tests passed,", stats.failures, "tests failed, duration: " + minutes + ":" + seconds);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//http://stackoverflow.com/questions/1403888/get-url-parameter-with-jquery
|
//http://stackoverflow.com/questions/1403888/get-url-parameter-with-jquery
|
||||||
|
@ -189,10 +170,7 @@ $(function(){
|
||||||
mocha.grep(grep);
|
mocha.grep(grep);
|
||||||
}
|
}
|
||||||
|
|
||||||
mocha.ignoreLeaks();
|
var runner = mocha.run();
|
||||||
|
CustomRunner(runner)
|
||||||
mocha.reporter(WebdriverAndHtmlReporter(mocha._reporter));
|
|
||||||
|
|
||||||
mocha.run();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue