From 4395ae5f513b0eb22c28af332cb7c41cbe750b17 Mon Sep 17 00:00:00 2001 From: semenkozin Date: Thu, 24 Apr 2014 05:53:16 +0400 Subject: [PATCH] Fix TypeError when generating diff for an object with circular structure; fixes #1179 --- lib/reporters/base.js | 2 +- mocha.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/reporters/base.js b/lib/reporters/base.js index 0754fe1a37..44c0d7a5fa 100644 --- a/lib/reporters/base.js +++ b/lib/reporters/base.js @@ -466,7 +466,7 @@ function stringify(obj) { function canonicalize(obj, stack) { stack = stack || []; - if (utils.indexOf(stack, obj) !== -1) return obj; + if (utils.indexOf(stack, obj) !== -1) return '[Circular]'; var canonicalizedObj; diff --git a/mocha.js b/mocha.js index 19edc87d97..66943316f1 100644 --- a/mocha.js +++ b/mocha.js @@ -2317,7 +2317,7 @@ function stringify(obj) { function canonicalize(obj, stack) { stack = stack || []; - if (utils.indexOf(stack, obj) !== -1) return obj; + if (utils.indexOf(stack, obj) !== -1) return '[Circular]'; var canonicalizedObj;