Created
July 24, 2012 18:53
-
-
Save mikelovesrobots/3171830 to your computer and use it in GitHub Desktop.
Jasmine pretty print monkeypatch for sane test failure messages (dump in spec/javascripts/helpers)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jasmine.PrettyPrinter.prototype.iterateObject = (obj, fn) -> | |
for own property, _ of obj | |
if property == '__Jasmine_been_here_before__' | |
continue | |
fn(property, if obj.__lookupGetter__ then (obj.__lookupGetter__(property) != jasmine.undefined && obj.__lookupGetter__(property) != null) else false) | |
jasmine.StringPrettyPrinter::originalEmitObject = jasmine.StringPrettyPrinter::emitObject | |
jasmine.StringPrettyPrinter::emitObject = (obj) -> | |
if obj instanceof jQuery | |
@emitJQuery obj | |
else | |
@append obj.className + '(' if obj.className != 'Object' | |
@originalEmitObject(obj) | |
@append ')' if obj.className != 'Object' | |
jasmine.StringPrettyPrinter::emitJQuery = (obj) -> | |
@append("$(") | |
elements = [] | |
for i in [0...obj.length] | |
elements.push obj[i].outerHTML.replace(/>[\s\S]*</, '>...<') | |
@append elements.join(', ') | |
@append(")") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment