Skip to content

armgit / mocha

Public Imported from GitHub
0

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

Fix 1875: Markdown reporter exceeds maximum call stack size

Daniel St. Jules9e456090c1f0
diff --git a/lib/reporters/markdown.js b/lib/reporters/markdown.js
index ac054506..88b1f4db 100644
--- a/lib/reporters/markdown.js
+++ b/lib/reporters/markdown.js
@@ -38,7 +38,7 @@ function Markdown(runner) {
var key = SUITE_PREFIX + suite.title;
obj = obj[key] = obj[key] || { suite: suite };
- suite.suites.forEach(function() {
+ suite.suites.forEach(function(suite) {
mapTOC(suite, obj);
});
diff --git a/test/integration/fixtures/passing.js b/test/integration/fixtures/passing.js
new file mode 100644
index 00000000..df91b3e5
--- /dev/null
+++ b/test/integration/fixtures/passing.js
@@ -0,0 +1,11 @@
+var assert = require('assert');
+
+describe('suite', function() {
+ it('test1', function() {
+ assert(true);
+ });
+
+ it('test2', function() {
+ assert(true);
+ });
+});
diff --git a/test/integration/reporters.js b/test/integration/reporters.js
new file mode 100644
index 00000000..477e42f3
--- /dev/null
+++ b/test/integration/reporters.js
@@ -0,0 +1,31 @@
+var assert = require('assert');
+var run = require('./helpers').runMocha;
+
+describe('reporters', function() {
+ this.timeout(1000);
+
+ describe('markdown', function() {
+ var res;
+
+ before(function(done) {
+ run('passing.js', ['--reporter', 'markdown'], function(err, result) {
+ res = result;
+ done(err);
+ });
+ });
+
+ it('does not exceed maximum callstack (issue: 1875)', function() {
+ assert(res.output.indexOf('RangeError') === -1, 'Threw RangeError');
+ });
+
+ it('contains spec src', function() {
+ var src = [
+ '```js',
+ 'assert(true);',
+ '```'
+ ].join('\n');
+
+ assert(res.output.indexOf(src) !== -1, 'No assert found');
+ });
+ });
+});