From 175a3eb9292f13daa0e8711ed1e59e0dc7a6cbbf Mon Sep 17 00:00:00 2001 From: Robert DeLuca Date: Thu, 5 Mar 2020 12:56:47 -0600 Subject: [PATCH] fix: Call `toString` on error (#479) Issue #478 attempted to break the error apart to perserve the stacktrace, but it looks like it's failing to produce the error message at all (depedning on the test framework/logging setup). We're going to call `.toString` on the error to print the message. If the user wants the stack trace, they will need to open the browser and place a breakpoint on the error log. --- src/percy-agent-client/dom.ts | 3 +-- test/unit/percy-agent-client/dom.test.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/percy-agent-client/dom.ts b/src/percy-agent-client/dom.ts index ac74bdab..b5eb218e 100644 --- a/src/percy-agent-client/dom.ts +++ b/src/percy-agent-client/dom.ts @@ -42,8 +42,7 @@ class DOM { try { dom = this.options.domTransformation(dom) } catch (error) { - console.error('Could not transform the dom:') - console.error(error) + console.error('Could not transform the dom: ', error.toString()) } } diff --git a/test/unit/percy-agent-client/dom.test.ts b/test/unit/percy-agent-client/dom.test.ts index 4955286a..6fff135d 100644 --- a/test/unit/percy-agent-client/dom.test.ts +++ b/test/unit/percy-agent-client/dom.test.ts @@ -104,7 +104,7 @@ describe('DOM -', () => { expect(consoleStub.called).to.equal(false) // invoke the transform function again to try and remove a non-existent element expect(dom.snapshotString()).to.contain('Hello DOM testing') - expect(consoleStub.calledTwice).to.equal(true) + expect(consoleStub.calledOnce).to.equal(true) }) })