From 7cd9c3a14db87e31ed916c1b3796c76188b22f2d Mon Sep 17 00:00:00 2001 From: Bradley Momberger Date: Thu, 7 Jun 2018 16:24:21 -0400 Subject: [PATCH 1/2] fix before/after all hooks not finding tests that aren't direct children of parent --- src/adapters/mocha.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/adapters/mocha.js b/src/adapters/mocha.js index 3bbdcf9..ff1f6a8 100644 --- a/src/adapters/mocha.js +++ b/src/adapters/mocha.js @@ -53,12 +53,18 @@ function TesteeReporter(runner) { } else if(data.title === '"before all" hook') { // tests in this suite will never run if before() fails, // so create the first test in order to fail it. - data = data.parent.tests[0]; + var test; + data.parent.eachTest(function(t) { + test = test || t; + }) + data = test; diff = self.diff(data); self.api['test'](diff); } else { // after all hook. apply to last test, which has already ran - data = data.parent.tests[data.parent.tests.length - 1]; + data.parent.eachTest(function(t) { + data = t; + }) } } From 1be9026032c4222450d5b0cbb23b61afa52d4da0 Mon Sep 17 00:00:00 2001 From: Bradley Momberger Date: Thu, 7 Jun 2018 17:01:33 -0400 Subject: [PATCH 2/2] don't replace data with undefined if no test found --- src/adapters/mocha.js | 2 +- test/test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/adapters/mocha.js b/src/adapters/mocha.js index ff1f6a8..e8db674 100644 --- a/src/adapters/mocha.js +++ b/src/adapters/mocha.js @@ -57,7 +57,7 @@ function TesteeReporter(runner) { data.parent.eachTest(function(t) { test = test || t; }) - data = test; + data = test || data; diff = self.diff(data); self.api['test'](diff); } else { diff --git a/test/test.js b/test/test.js index 80c2448..46c4811 100644 --- a/test/test.js +++ b/test/test.js @@ -33,7 +33,7 @@ function compare (assert, reference, actual, name) { } else if(key === 'duration') { assert.ok(inRange(expected, current, 20), name + ' ' + key + ' === ' + expected + '(+/- 20)'); } else { - assert.equal(expected, current, name + ' ' + key + ' === ' + expected); + assert.equal(current, expected, name + ' ' + key + ' === ' + expected); } } }