Skip to content

Commit 956cdc6

Browse files
committed
Simplify reported value
When the value of an uncaught exception is a function, AVA previously displayed the source of that function in the error report. During the review process for an unrelated change, this condition was found to be too rare to justify the maintenance overhead. Do not attempt to display the source of function values in these cases.
1 parent e6d6a96 commit 956cdc6

File tree

4 files changed

+1
-40
lines changed

4 files changed

+1
-40
lines changed

lib/serialize-error.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ module.exports = error => {
9292
if (typeof error.stack === 'string') {
9393
retval.summary = error.stack.split('\n')[0];
9494
} else {
95-
retval.summary = typeof error === 'function' ?
96-
error.toString() : JSON.stringify(error);
95+
retval.summary = JSON.stringify(error);
9796
}
9897

9998
return retval;

test/cli.js

-20
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,6 @@ test('timeout', t => {
9191
});
9292
});
9393

94-
test('throwing a named function will report the to the console', t => {
95-
execCli('fixture/throw-named-function.js', (err, stdout, stderr) => {
96-
t.ok(err);
97-
t.match(stderr, /function fooFn\(\) \{\}/);
98-
// TODO(jamestalmage)
99-
// t.ok(/1 uncaught exception[^s]/.test(stdout));
100-
t.end();
101-
});
102-
});
103-
10494
test('include anonymous functions in error reports', t => {
10595
execCli('fixture/error-in-anonymous-function.js', (err, stdout, stderr) => {
10696
t.ok(err);
@@ -210,16 +200,6 @@ test('babel require hook only does not apply to source files', t => {
210200
});
211201
});
212202

213-
test('throwing a anonymous function will report the function to the console', t => {
214-
execCli('fixture/throw-anonymous-function.js', (err, stdout, stderr) => {
215-
t.ok(err);
216-
t.match(stderr, /\(\) => \{\}/);
217-
// TODO(jamestalmage)
218-
// t.ok(/1 uncaught exception[^s]/.test(stdout));
219-
t.end();
220-
});
221-
});
222-
223203
test('pkg-conf: defaults', t => {
224204
execCli([], {dirname: 'fixture/pkg-conf/defaults'}, err => {
225205
t.ifError(err);

test/fixture/throw-anonymous-function.js

-8
This file was deleted.

test/fixture/throw-named-function.js

-10
This file was deleted.

0 commit comments

Comments
 (0)