Skip to content

Commit

Permalink
Bluebird long stack traces integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
mliou8 authored and novemberborn committed Sep 24, 2017
1 parent 3c8b1be commit 61101d9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/cli.js
Expand Up @@ -75,6 +75,14 @@ test('disallow invalid babel config shortcuts', t => {
});
});

test('enabling long stack traces will provide detailed debug information', t => {
execCli('fixture/long-stack-trace', (err, stdout, stderr) => {
t.ok(err);
t.match(stderr, /From previous event/);
t.end();
});
});

test('timeout', t => {
execCli(['fixture/long-running.js', '-T', '1s'], (err, stdout, stderr) => {
t.ok(err);
Expand Down
6 changes: 6 additions & 0 deletions test/fixture/long-stack-trace/enable-trace.js
@@ -0,0 +1,6 @@
'use strict';

const Promise = require('bluebird');
Promise.longStackTraces();

module.exports = Promise;
5 changes: 5 additions & 0 deletions test/fixture/long-stack-trace/package.json
@@ -0,0 +1,5 @@
{
"ava": {
"require": "./enable-trace.js"
}
}
17 changes: 17 additions & 0 deletions test/fixture/long-stack-trace/test.js
@@ -0,0 +1,17 @@
import test from '../../../';
import Promise from './enable-trace';


// This promise throwing pattern was used in bluebird documentation for long stack traces
// http://bluebirdjs.com/docs/api/promise.longstacktraces.html
test(async t => {
const resolve = await Promise.resolve().then(function outer() {
return Promise.resolve().then(function inner() {
return Promise.resolve().then(function evenMoreInner() {
a.b.c.d()
}).catch(function catcher(e) {
throw e.stack
});
});
});
});

0 comments on commit 61101d9

Please sign in to comment.