Please consider to enable html report integration into an existing div element #152

wants to merge 10 commits into


None yet

5 participants


Currently jasmine.TrivialReporter always creates the complete report div structure (including the root div element of the report) and appends it as child of the document body. Thus it is not possible to integrate the (really nice) report into a sub element of a page with an already given structure.

With the proposed trivial change 'jasmine.TrivialReporter' first will search for an already existing HTML element with ID 'jasmine_reporter' and - if existing - append the report as child to this existing element (which should be a div, of course). If no corresponding element can be found, a new div element will be created and appended as child to document.body - as before.

This makes it possible to integrate the test report into a sub element - like a TiddlyWiki tiddler. TiddlyWiki ( is an One-File-Wiki with an already given page structure - including everything in one file: data and source. I'm using jasmine in order to test the functionality of TiddlyWiki plugin extensions right in place.

Example: Jasmine test report in a TiddlyWiki tiddler

Thank you very much for providing jasmine! Love jasmine! :-)


Behavior seems fine to me; we'd want to see tests before it gets merged. Also, it might be useful for you to make these changes against the 1.2.rc1 branch of jasmine as the TrivialReporter will be going away.

gvictorv added some commits Nov 9, 2011
@gvictorv gvictorv Merge remote branch 'upstream/master' into report-in-subelement

Now searching for a sub-element with id 'TrivialReporter' instead of 'jasmine_reporter'.
If no sub-element can be found create a new div with id 'TrivialReporter'.
@gvictorv gvictorv If missing, assign 'jasmine_reporter' class to found sub-element with…
… id 'TrivialReporter'.
@gvictorv gvictorv spec/html/TrivialReporterSpec.js:
Added test cases for reporting into an existing sub-element with id 'TrivialReporter' or body if it can't be found.
Imitating required method 'getElementById' for fakeDocument.
@gvictorv gvictorv HtmlReporter.js: Enabled html report integration into an existing sub…
…-element with name 'HTMLReporter'.
@gvictorv gvictorv Fixed missing semicolon in 'ReporterView.js'. a2a115a
@gvictorv gvictorv Added missing newline at EOF in 'HtmlReporter.js'. 0e2fa09
@gvictorv gvictorv Modified CSS in order to enable reporting into a sub-element with dep…
…recated 'TrivialReporter'.

- #TrivialReporter position is now relative;
- #TrivialReporter overflow-y is now auto;
@gvictorv gvictorv spec/html/HtmlReporterSpec.js:
Added test cases for reporting into an existing sub-element with id 'HTMLReporter' or body if it can't be found.
Imitating required method 'getElementById' for fakeDocument.

Now that I found the time to implement the requested changes and additions, I'm glad to deliver:

  • The adopted implementation of the desired behavior for TrivialReporter according to the changes in master
    • Now using 'TrivialReporter' as id instead of 'jasmine_reporter'
    • Now assigning the class 'jasmine_reporter' in the already existing sub-element, if missing
    • Adjusted CSS for #TrivialReporter to (re-)enable reporting into a sub-element
    • Two test cases checking the desired behavior
  • A similar implementation of the desired behavior for the new HtmlReporter including test cases

Example: Jasmine test report in a TiddlyWiki tiddler now using HtmlReporter

Additionally I've committed two (very) small fixes:

  • Missing semicolon in ReporterView
  • Missing newline at EOF in HtmlReporter

I would be very happy if you take these changes into consideration. :-) Thank you a lot for taking a look into it!

After having adopted the desired behavior of reporting into a sub-element for both, TrivialReporter and the new HtmlReporter, in master, is there still any need to make the same changes in the 1.2.rc1 branch?

@gvictorv gvictorv Fixed imitated fakeDocument.getElementById(id) method in HtmlReporter…
…Spec and TrivialReporterSpec:

now using passed id argument instead of hard coded id names.

Ooops. Missed to avoid hard coded id names in required method 'fakeDocument.getElementById(id)' within the test implementations. Fixed in last commit.


Do I need to push a merge with the newest commits on master (b4439f7)? There are no conflicts so far.

ikr commented Jan 24, 2012

Looking forward to this feature merged. Makes it possible to conveniently test the code in its exact run-time context. Up-vote!

infews commented Feb 24, 2012

This is exactly what I am looking for right now. As far as I can tell there is no other way to hack this in right now.

ghost commented May 26, 2013

Closing. This is now possible in 2.0. Look at boot.js on master - when you instantiate the HtmlReporter you pass in a function to get the top-level node.

@ghost ghost closed this May 26, 2013
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment