Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

add window scrolling to HTML reporter

TJ Holowaychukf3f7aafc21d2
diff --git a/lib/reporters/html.js b/lib/reporters/html.js
index 7a0e64cc..113a356a 100644
--- a/lib/reporters/html.js
+++ b/lib/reporters/html.js
@@ -95,6 +95,8 @@ function HTML(runner) {
});
runner.on('test end', function(test){
+ window.scrollTo(0, document.body.scrollHeight);
+
// TODO: add to stats
var percent = stats.tests / total * 100 | 0;
if (progress) progress.update(percent).draw(ctx);
diff --git a/mocha.js b/mocha.js
index fe8dc5d0..34873377 100644
--- a/mocha.js
+++ b/mocha.js
@@ -1695,6 +1695,8 @@ function HTML(runner) {
});
runner.on('test end', function(test){
+ window.scrollTo(0, document.body.scrollHeight);
+
// TODO: add to stats
var percent = stats.tests / total * 100 | 0;
if (progress) progress.update(percent).draw(ctx);
@@ -1815,13 +1817,14 @@ exports.HTML = require('./html');
exports.List = require('./list');
exports.Min = require('./min');
exports.Spec = require('./spec');
+exports.Nyan = require('./nyan');
+exports.XUnit = require('./xunit');
exports.Progress = require('./progress');
exports.Landing = require('./landing');
exports.JSONCov = require('./json-cov');
exports.HTMLCov = require('./html-cov');
exports.JSONStream = require('./json-stream');
-exports.XUnit = require('./xunit')
-exports.Teamcity = require('./teamcity')
+exports.Teamcity = require('./teamcity');
}); // module: reporters/index.js
@@ -2383,6 +2386,7 @@ function Markdown(runner) {
}); // module: reporters/markdown.js
require.register("reporters/min.js", function(module, exports, require){
+
/**
* Module dependencies.
*/
diff --git a/test/browser/large.js b/test/browser/large.js
index 2f5e4024..4f90e8ce 100644
--- a/test/browser/large.js
+++ b/test/browser/large.js
@@ -1,7 +1,7 @@
var n = 30;
while (n--) {
- describe('Array', function(){
+ describe('Array ' + n, function(){
var arr;
beforeEach(function(){
@@ -13,9 +13,10 @@ while (n--) {
assert(-1 == arr.indexOf(5));
})
- it('should return the correct index when the value is present', function(){
+ it('should return the correct index when the value is present', function(done){
assert(0 == arr.indexOf(1));
assert(1 == arr.indexOf(2));
+ setTimeout(done, Math.random() * 200 | 0)
})
})
})