From 712305bd21ef3d2bb6ec3b8589179f570be4fb69 Mon Sep 17 00:00:00 2001 From: Adam Gruber Date: Fri, 4 Mar 2016 09:26:05 -0500 Subject: [PATCH] Fixes https://github.com/adamgruber/mochawesome/issues/33 --- changelog.md | 3 ++ gulpfile.js | 7 +++ lib/mochawesome.js | 6 --- package.json | 2 +- test/mem-test.js | 115 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+), 7 deletions(-) create mode 100644 test/mem-test.js diff --git a/changelog.md b/changelog.md index c135f82..c7f88b1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,8 @@ #Changelog +###1.3.2 +- Removed `allHooks` array since it was not being used and could lead to an issue where node runs out of memory while rendering the template. See [#33](https://github.com/adamgruber/mochawesome/issues/33) + ###1.3.1 - Update copyright in template diff --git a/gulpfile.js b/gulpfile.js index 9e5dbb0..78d638f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -30,6 +30,7 @@ var watchFiles = [ var testPaths = { basic: ['./test/test.js'], + mem: ['./test/mem-test.js'], fiveby: [ './test/fiveby/*.js', './test/fiveby/**/*.js' @@ -165,6 +166,12 @@ gulp.task('test', function () { .on('error', console.warn.bind(console)); }); +gulp.task('mem-test', function () { + return gulp.src(testPaths.mem) + .pipe(mocha(mochaOpts)) + .on('error', console.warn.bind(console)); +}); + gulp.task('testOpts', function () { mochaOpts.reporterOptions = 'reportDir=customDir,reportName=customName,reportTitle=customTitle,inlineAssets=true'; return gulp.src(testPaths.basic) diff --git a/lib/mochawesome.js b/lib/mochawesome.js index 8821d9d..0b07a24 100755 --- a/lib/mochawesome.js +++ b/lib/mochawesome.js @@ -46,7 +46,6 @@ function Mochawesome (runner, options) { var allSuites = {}, allTests = [], - allHooks = [], allPending = [], allFailures = [], allPasses = [], @@ -56,10 +55,6 @@ function Mochawesome (runner, options) { allTests.push(test); }); - runner.on('hook end', function (hook) { - allHooks.push(hook); - }); - runner.on('pending', function (test) { allPending.push(test); }); @@ -87,7 +82,6 @@ function Mochawesome (runner, options) { stats: self.stats, suites: allSuites, allTests: allTests.map(cleanTest), - allHooks: allHooks, allPending: allPending, allPasses: allPasses.map(cleanTest), allFailures: allFailures.map(cleanTest), diff --git a/package.json b/package.json index 80b79be..be55b4d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mochawesome", - "version": "1.3.1", + "version": "1.3.2", "description": "A Gorgeous HTML/CSS Reporter for Mocha.js", "scripts": { "test": "gulp build" diff --git a/test/mem-test.js b/test/mem-test.js new file mode 100644 index 0000000..9af2a75 --- /dev/null +++ b/test/mem-test.js @@ -0,0 +1,115 @@ +/* Test courtesy of @adaphi */ +'use strict' + +describe('mochawesome hook test', function() { + + // Change this to drastically alter the memory impact + var numTests = 1000; + + before('before hook 1', function(done) { + done(); + }); + + before('before hook 2', function(done) { + done(); + }); + + before('before hook 3', function(done) { + done(); + }); + + before('before hook 4', function(done) { + done(); + }); + + before('before hook 5', function(done) { + done(); + }); + + before('before hook 6', function(done) { + done(); + }); + + before('before hook 7', function(done) { + done(); + }); + + before('before hook 8', function(done) { + done(); + }); + + beforeEach('beforeEach hook 1', function(done) { + done(); + }); + + beforeEach('beforeEach hook 2', function(done) { + done(); + }); + + beforeEach('beforeEach hook 3', function(done) { + done(); + }); + + beforeEach('beforeEach hook 4', function(done) { + done(); + }); + + afterEach('afterEach hook 1', function(done) { + done(); + }); + + afterEach('afterEach hook 2', function(done) { + done(); + }); + + after('after hook 1', function(done) { + done(); + }); + + after('after hook 2', function(done) { + done(); + }); + + for (var i=1; i<=numTests; i++) { + it( 'test ' + i, genTestBody() ); + } + + function genTestBody() { + return function(done) { + // This just needs to contain a lot of stuff. + // AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + // AAAAAAAAAAAAAAAAAAAAAAAAAAAA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