-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
155 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict'; | ||
|
||
const mocha = require('mocha'); | ||
const internal = [ | ||
'(timers.js:', | ||
'(node.js:', | ||
'(module.js:', | ||
'(domain.js:', | ||
'GeneratorFunctionPrototype.next (native)', | ||
'at Generator.next', | ||
// node 8.x | ||
'at Promise (<anonymous>)', | ||
'at next (native)', | ||
'__mocha_internal__', | ||
/node_modules\/.*empower-core\//, | ||
/node_modules\/.*mocha\//, | ||
/node_modules\/.*co\//, | ||
/node_modules\/.*co-mocha\//, | ||
]; | ||
|
||
// monkey-patch `Runner#fail` to modify stack | ||
const originFn = mocha.Runner.prototype.fail; | ||
mocha.Runner.prototype.fail = function(test, err) { | ||
/* istanbul ignore else */ | ||
if (err.stack) { | ||
const stack = err.stack.split('\n').filter(line => { | ||
line = line.replace(/\\\\?/g, '/'); | ||
// console.log('[%s] %s', !internal.some(rule => match(line, rule)) ? ' ' : '--', line); | ||
return !internal.some(rule => match(line, rule)); | ||
}); | ||
err.stack = stack.join('\n'); | ||
} | ||
return originFn.call(this, test, err); | ||
}; | ||
|
||
function match(line, rule) { | ||
if (rule instanceof RegExp) return rule.test(line); | ||
return line.includes(rule); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
test/fixtures/test-files-stack/node_modules/my-sleep/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "test-files-stack" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
|
||
describe('assert.test.js', () => { | ||
it('should fail with simplify stack', () => { | ||
[ 1 ].forEach(() => { | ||
assert(1 === 0); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
const co = require('co'); | ||
|
||
describe('promise.test.js', () => { | ||
it('should fail with simplify stack', function* () { | ||
yield co(function* () { | ||
return yield new Promise((resolve, reject) => { | ||
reject(new Error('this is an error')); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
const sleep = require('my-sleep'); | ||
|
||
describe('sleep.test.js', () => { | ||
it('should fail with simplify stack', done => { | ||
sleep(() => { | ||
done(new Error('this is an error')); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters