From 59cd573412da32a20960080b1d090620838139ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Krzewski?= Date: Wed, 30 May 2018 17:40:11 +0200 Subject: [PATCH] Report both failing and passing expecations to Jasmine (#87) --- integrations/jasmine-check/jasmine-check.js | 33 +++++++-------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/integrations/jasmine-check/jasmine-check.js b/integrations/jasmine-check/jasmine-check.js index b493d20..958cd62 100644 --- a/integrations/jasmine-check/jasmine-check.js +++ b/integrations/jasmine-check/jasmine-check.js @@ -65,29 +65,20 @@ function checkIt(it) { // Intercept match results var matchFailed = false; var matchResults = []; - var failingMatchResults; - - var addResult = spec.addMatcherResult ? - spec.addMatcherResult.bind(spec) : - spec.addExpectationResult.bind(spec, false); + var expectationResults = []; var existingSpecFail = spec.fail; var existingAddExpectationResult = spec.addExpectationResult; var existingAddMatcherResult = spec.addMatcherResult; - var checkAddExpectationResult = function(passed, data) { - if (passed) { - return; - } - matchFailed = true; - matchResults.push(data); + var checkAddExpectationResult = function(passed, data, isException) { + matchFailed = matchFailed || !passed; + expectationResults.push([passed, data, isException]); }; var checkAddMatcherResult = function(result) { + matchFailed = matchFailed || !result.passed(); matchResults.push(result); - if (!result.passed()) { - matchFailed = true; - } }; // Build property @@ -96,16 +87,11 @@ function checkIt(it) { spec.fail = logException; spec.addExpectationResult = checkAddExpectationResult; spec.addMatcherResult = checkAddMatcherResult; - matchFailed = false; - matchResults = []; try { propertyFn.apply(thisArg, arguments); } catch (error) { spec.fail(error); } - if (matchFailed) { - failingMatchResults = matchResults; - } spec.fail = existingSpecFail; spec.addExpectationResult = existingAddExpectationResult; spec.addMatcherResult = existingAddMatcherResult; @@ -129,8 +115,11 @@ function checkIt(it) { } // Report results - (failingMatchResults || matchResults).forEach(function (matchResult) { - addResult(matchResult); + matchResults.forEach(function (matchResult) { + spec.addMatcherResult(matchResult); + }); + expectationResults.forEach(function(data) { + spec.addExpectationResult(data[0], data[1], data[2]); }); } } @@ -150,7 +139,7 @@ function logException(e) { expected: "", actual: "", error: e - }); + }, true); } }