diff --git a/jasmine.iws b/jasmine.iws index 1e3128d..f4c7c96 100644 --- a/jasmine.iws +++ b/jasmine.iws @@ -79,29 +79,29 @@ - - - - - - - - - - + - + + + + + + + + + + - + @@ -110,7 +110,7 @@ - + @@ -118,14 +118,14 @@ + + + - - - @@ -305,52 +305,6 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + localhost @@ -508,14 +508,14 @@ + + + - - - @@ -531,33 +531,33 @@ - + - + + + - - - - - - - - - - + - + + + + + + + + diff --git a/lib/json_reporter.js b/lib/json_reporter.js index 11e397c..a9c6f53 100644 --- a/lib/json_reporter.js +++ b/lib/json_reporter.js @@ -1,5 +1,6 @@ -JasmineReporters.JSON = function () { +JasmineReporters.JSON = function (elementId) { var that = { + elementId: elementId, results: {}, addResults: function (results) { @@ -7,7 +8,15 @@ JasmineReporters.JSON = function () { }, report: function () { - return Object.toJSON(that.results); + var output = Object.toJSON(that.results); + + if (that.elementId) { + var element = document.getElementById(that.elementId); + if (element) { + element.innerHTML = output; + } + } + return output; } } return that; diff --git a/test/bootstrap.html b/test/bootstrap.html index 4b20bfd..b216b31 100755 --- a/test/bootstrap.html +++ b/test/bootstrap.html @@ -26,6 +26,7 @@
+ diff --git a/test/bootstrap.js b/test/bootstrap.js index 636a6d8..b22e70f 100755 --- a/test/bootstrap.js +++ b/test/bootstrap.js @@ -658,7 +658,7 @@ var testJSONReporter = function () { }); }); - runner.reporter = JasmineReporters.JSON(); + runner.reporter = JasmineReporters.JSON('json_reporter_results'); reporter.test((runner.reporter !== undefined), "Runner's reporter is undefined"); @@ -670,7 +670,10 @@ var testJSONReporter = function () { expectedJSONString = '{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"totalCount": 1, "passedCount": 1, "failedCount": 0, "results": [{"passed": true, "message": "Passed."}], "description": "should be a test"}], "description": "one suite description"}], "description": "All Jasmine Suites"}'; setTimeout(function() { reporter.test((runner.reporter.report() === expectedJSONString), - 'Jasmine Reporter does not have the expected report, has: ' + runner.reporter.report()); + 'Jasmine Reporter does not have the expected report, has: ' + runner.reporter.report()); + reporter.test((document.getElementById('json_reporter_results').innerHTML === expectedJSONString), + 'Jasmine Reporter did not output the string to the DOM'); + }, 500); }