Skip to content

Commit 61101d9

Browse files
mliou8novemberborn
authored andcommitted
Bluebird long stack traces integration test
1 parent 3c8b1be commit 61101d9

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

test/cli.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ test('disallow invalid babel config shortcuts', t => {
7575
});
7676
});
7777

78+
test('enabling long stack traces will provide detailed debug information', t => {
79+
execCli('fixture/long-stack-trace', (err, stdout, stderr) => {
80+
t.ok(err);
81+
t.match(stderr, /From previous event/);
82+
t.end();
83+
});
84+
});
85+
7886
test('timeout', t => {
7987
execCli(['fixture/long-running.js', '-T', '1s'], (err, stdout, stderr) => {
8088
t.ok(err);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use strict';
2+
3+
const Promise = require('bluebird');
4+
Promise.longStackTraces();
5+
6+
module.exports = Promise;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"ava": {
3+
"require": "./enable-trace.js"
4+
}
5+
}

test/fixture/long-stack-trace/test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import test from '../../../';
2+
import Promise from './enable-trace';
3+
4+
5+
// This promise throwing pattern was used in bluebird documentation for long stack traces
6+
// http://bluebirdjs.com/docs/api/promise.longstacktraces.html
7+
test(async t => {
8+
const resolve = await Promise.resolve().then(function outer() {
9+
return Promise.resolve().then(function inner() {
10+
return Promise.resolve().then(function evenMoreInner() {
11+
a.b.c.d()
12+
}).catch(function catcher(e) {
13+
throw e.stack
14+
});
15+
});
16+
});
17+
});

0 commit comments

Comments
 (0)