diff --git a/index.js b/index.js index 8b0442a..371e98e 100644 --- a/index.js +++ b/index.js @@ -50,7 +50,7 @@ const pretty = createPretty(DEFAULT_PRETTY) const getPretty = opts => (isNil(opts) ? pretty : createPretty(opts)) const cleanError = error => { - error.stack = !isNil(error.stack) ? cleanStack(error.stack) : null + if (error.stack) error.stack = cleanStack(error.stack) return error } diff --git a/test/index.js b/test/index.js index 655d499..2d008ec 100644 --- a/test/index.js +++ b/test/index.js @@ -4,6 +4,5 @@ const test = require('ava') const beautyError = require('..') test('pretty an error', t => { - const error = new Error("Hello darkness my old' friend") - t.snapshot(beautyError({ ...error, stack: '' })) + t.snapshot(beautyError(new Error("Hello darkness my old' friend"))) }) diff --git a/test/snapshots/index.js.md b/test/snapshots/index.js.md index d239d03..241ed12 100644 --- a/test/snapshots/index.js.md +++ b/test/snapshots/index.js.md @@ -8,5 +8,23 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - ` Error ␊ + ` Error Hello darkness my old' friend␊ +  ␊ +  - index.js:7 ␊ +   /Users/josefranciscoverdugambin/Projects/beauty-error/test/index.js:7:26␊ +  ␊ +  - test.js:316 Test.callFn␊ +   [beauty-error]/[ava]/lib/test.js:316:21␊ +  ␊ +  - test.js:329 Test.run␊ +   [beauty-error]/[ava]/lib/test.js:329:23␊ +  ␊ +  - runner.js:259 Runner.runSingle␊ +   [beauty-error]/[ava]/lib/runner.js:259:19␊ +  ␊ +  - runner.js:322 ␊ +   [beauty-error]/[ava]/lib/runner.js:322:16␊ +  ␊ +  - async Promise.all␊ +  ␊ ` diff --git a/test/snapshots/index.js.snap b/test/snapshots/index.js.snap index 13e24a9..5b6dfc2 100644 Binary files a/test/snapshots/index.js.snap and b/test/snapshots/index.js.snap differ