Better StackTraces with filtering and mapping lines
See original GitHub issueLet us say we have the following stack trace:
Expected 'bar' to be 'bar1'
assert@/Users/foo/Workspace/ws/examples/browser-js/test-dist/index.js:11066:27 <- ~/expect/lib/assert.js:29:0
toBe@/Users/foo/Workspace/ws/examples/browser-js/test-dist/index.js:8037:28 <- ~/expect/lib/Expectation.js:86:0
/Users/foo/Workspace/ws/examples/browser-js/test-dist/index.js:7909:75 <- test/unit.ts:31:48
First I’d like to filter stack traces from ~/except
. Second I want to only see the original source (the part after <-
).
I could actually hack the lib/reporter.js
at line 92 like this to achieve this result:
// filter lines
msg = msg.split('\n').filter(line => !line.match(/~\/expect\/lib/)).join('\n');
// map lines
msg = msg.split('\n').map(line => line.match(/\/(.*)<-/) ? line.replace(/\/(.*)<-/, '') : line).join('\n');
The result will be:
Expected 'bar' to be 'bar1'
test/unit.ts:31:48
Can I achieve the same behaviour with existing APIs? Or can I add this behaviour with a pull request? I could imagine to add two new fields to the karma config (e.g. mapStackTraceLine
/filterStackTraceLine
) so everyone can set custom filter/map rules if needed.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:15 (9 by maintainers)
Top Results From Across the Web
Filter irrelevant stack trace lines in logs - Java Code Geeks
For instance in web application the stack trace shows you the complete request processing path, from HTTP socket, through filters, servlets, ...
Read more >How to filter stacktrace frames in Logback - Stack Overflow
So I configured logback with the following not to print any stack trace line from org.something packages (e.g. org.apache , org.springframework ...
Read more >StackTrace.JS - Framework-agnostic, micro-library for getting ...
Generate, parse, and enhance JavaScript stack traces in all web browsers ... stacktrace.js v2.0 is out, featuring ES6 support, better stack frames, and...
Read more >Stack Trace Filter - Logstash/Gelf Loggers
logstash-gelf provides a built-in stack trace filter to filter out the noise out of stack traces. Original stack trace. javax.servlet.
Read more >Configuring Mule Stack Traces | MuleSoft Documentation
When Mule does show stack traces, it filters out some internal class references from to produce a more readable output. You can control...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks!
So I used your example:
It did clean it up quite a bit, But I’m still getting some weird mode_modules stuff.
So I modified it a little and it works!
Thanks a ton @levithomason!
See my response to your question here, https://github.com/rstacruz/mocha-clean/issues/5#issuecomment-331010426.
The usage changed slightly due to how the stack is passed. Each line is passed one at a time, rather than the whole stack at once.