Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/extract-stack.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const stackLineRegex = /^.+ \(.+:[0-9]+:[0-9]+\)$/;
const stackLineRegex = /^.+( \(.+:[0-9]+:[0-9]+\)|:[0-9]+:[0-9]+)$/;

module.exports = stack => {
return stack
Expand Down
8 changes: 8 additions & 0 deletions test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ test('throwing a named function will report the to the console', t => {
});
});

test('include anonymous functions in error reports', t => {
execCli('fixture/error-in-anonymous-function.js', (err, stdout, stderr) => {
t.ok(err);
t.match(stderr, /test\/fixture\/error-in-anonymous-function\.js:4:8/);
t.end();
});
});

test('improper use of t.throws will be reported to the console', t => {
execCli('fixture/improper-t-throws.js', (err, stdout, stderr) => {
t.ok(err);
Expand Down
10 changes: 10 additions & 0 deletions test/extract-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,13 @@ test('strip beginning whitespace from stack', t => {
t.is(extractStack(stack), 'Test.t (test.js:1:1)');
t.end();
});

test('includes anonymous function lines', t => {
const stack = [
'error message',
'path/to/test.js:1:1'
].join('\n');

t.is(extractStack(stack), 'path/to/test.js:1:1');
t.end();
});
9 changes: 9 additions & 0 deletions test/fixture/error-in-anonymous-function.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import test from '../../';

const getAnonymousFn = () => () => {
throw Error();
};

test(t => {
getAnonymousFn()();
});