Intercepts jasmine.Spec to stringify it as "[ Spec ]" instead of JSON.
This is required for using jasmine-given with the reporter, as that library sets expectations on jasmine.Specs themselves. When the Spec is stringified as JSON, it ends up stringifying the entire Jasmine environment, including previous ExpectationResults. Since those previous ExpectationResults have had their "expected" values stringified, they may include stringified Specs themselves. This leds to exponential growth in the size of stringified Specs. Special-casing jasmine.Spec prevents the exponential growth by short-circuting the value to a small, still-useful String.
This commit is contained in:
parent
f8aed8dbf1
commit
69288dc2b8
@ -114,6 +114,11 @@ phantom.sendMessage = function() {
|
|||||||
// If we're a node
|
// If we're a node
|
||||||
if (value instanceof Node) return '[ Node ]';
|
if (value instanceof Node) return '[ Node ]';
|
||||||
|
|
||||||
|
// jasmine-given has expectations on Specs. We intercept to return a
|
||||||
|
// String to avoid stringifying the entire Jasmine environment, which
|
||||||
|
// results in exponential string growth
|
||||||
|
if (value instanceof jasmine.Spec) return '[ Spec: ' + value.description + ' ]';
|
||||||
|
|
||||||
// If we're a window (logic stolen from jQuery)
|
// If we're a window (logic stolen from jQuery)
|
||||||
if (value.window && value.window === value.window.window) return '[ Window ]';
|
if (value.window && value.window === value.window.window) return '[ Window ]';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user