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

Closed
wants to merge 10 commits into
from

Projects

None yet

5 participants

@gvictorv

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 (www.tiddlywiki.com) 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! :-)

@ragaskar
Contributor

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
Conflicts:
	lib/jasmine-core/jasmine-html.js
	src/html/TrivialReporter.js

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'.
cd84c25
@gvictorv gvictorv If missing, assign 'jasmine_reporter' class to found sub-element with…
… id 'TrivialReporter'.
fc9a84d
@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.
a72d200
@gvictorv gvictorv HtmlReporter.js: Enabled html report integration into an existing sub…
…-element with name 'HTMLReporter'.
00ec81b
@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;
6da06ad
@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.
7b7137b
@gvictorv

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!

Question:
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.
dd858cd
@gvictorv

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

@gvictorv

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

@ikr
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
Contributor
infews commented Feb 24, 2012
@abierbaum

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
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