diff --git a/index.js b/index.js index b599404..524a2a6 100644 --- a/index.js +++ b/index.js @@ -69,6 +69,8 @@ function AssertionError (message, _props, ssf) { ssf = ssf || arguments.callee; if (ssf && Error.captureStackTrace) { Error.captureStackTrace(this, ssf); + } else { + this.stack = new Error().stack; } } diff --git a/test/test.js b/test/test.js index edbe6a7..c696e0f 100644 --- a/test/test.js +++ b/test/test.js @@ -13,6 +13,10 @@ suite(function (test, assert) { assert(empty.message === 'Unspecified AssertionError', 'w/o err.message'); }); + test('stack', function() { + assert(typeof new AssertionError().stack === 'string'); + }); + test('custom properties', function () { var err = new AssertionError('good message', { name: 'ShouldNotExist'