tests found bug. fixed
MODIFY
packages/error-stack-shim/src/getStack.js
packages/error-stack-shim/src/getStack.js
@@ -29,7 +29,7 @@ function FakeError(...args) {
return apply(UnsafeError, this, args);
}
FakeError.prototype = UnsafeError.prototype;
-FakeError.prototype.constructore = FakeError;
+FakeError.prototype.constructor = FakeError;
// eslint-disable-next-line no-global-assign
Error = FakeError;

MODIFY
packages/error-stack-shim/test/test.js
packages/error-stack-shim/test/test.js
@@ -3,18 +3,28 @@ import { test } from 'tape-promise/tape';
import { getStack, getStackString } from '../src/getStack';
test('getStack well formed', t => {
+ // Note: define err1 and err2 on consecutive lines
const err1 = new Error('foo');
- const stack = getStack(err1);
+ const err2 = new TypeError('bar');
+ const stack1 = getStack(err1);
+ const stack2 = getStack(err2);
- t.true(Array.isArray(stack.frames));
- t.true(typeof stack.string === 'string');
- t.equal(stack.string, getStackString(err1));
- t.equal(stack.string, err1.stack);
+ t.true(Array.isArray(stack1.frames));
+ t.true(typeof stack1.string === 'string');
+ t.equal(stack1.string, getStackString(err1));
+ t.equal(stack1.string, err1.stack);
+ t.equal(Error, Error.prototype.constructor);
- console.log('error: ', err1);
- console.log('error.stack: ', err1.stack);
- console.log('trace: ', stack.string);
- console.log('json: ', JSON.stringify(stack.frames[0], undefined, ' '));
+ const frame1 = stack1.frames[0];
+ const frame2 = stack2.frames[0];
+
+ console.log('trace: ', stack1.string);
+ console.log(frame1);
+
+ t.equal(frame1.name, frame2.name);
+ t.equal(frame1.span[0][0] + 1, frame2.span[0][0]);
+ t.equal(frame1.source, frame2.source);
+ t.true(frame1.source.endsWith('error-stack-shim/test/test.js'));
t.end();
});

tests found bug. fixed