{"action":"created","issue":{"url":"https://api.github.com/repos/karma-runner/karma/issues/2119","repository_url":"https://api.github.com/repos/karma-runner/karma","labels_url":"https://api.github.com/repos/karma-runner/karma/issues/2119/labels{/name}","comments_url":"https://api.github.com/repos/karma-runner/karma/issues/2119/comments","events_url":"https://api.github.com/repos/karma-runner/karma/issues/2119/events","html_url":"https://github.com/karma-runner/karma/issues/2119","id":153521048,"number":2119,"title":"Better StackTraces with filtering and mapping lines","user":{"login":"donaldpipowitch","id":1152805,"avatar_url":"https://avatars.githubusercontent.com/u/1152805?v=3","gravatar_id":"","url":"https://api.github.com/users/donaldpipowitch","html_url":"https://github.com/donaldpipowitch","followers_url":"https://api.github.com/users/donaldpipowitch/followers","following_url":"https://api.github.com/users/donaldpipowitch/following{/other_user}","gists_url":"https://api.github.com/users/donaldpipowitch/gists{/gist_id}","starred_url":"https://api.github.com/users/donaldpipowitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/donaldpipowitch/subscriptions","organizations_url":"https://api.github.com/users/donaldpipowitch/orgs","repos_url":"https://api.github.com/users/donaldpipowitch/repos","events_url":"https://api.github.com/users/donaldpipowitch/events{/privacy}","received_events_url":"https://api.github.com/users/donaldpipowitch/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/karma-runner/karma/labels/help%20wanted","name":"help wanted","color":"207de5"},{"url":"https://api.github.com/repos/karma-runner/karma/labels/type:%20feature","name":"type: feature","color":"02e10c"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-05-06T19:24:08Z","updated_at":"2016-09-20T19:21:30Z","closed_at":"2016-09-07T15:53:09Z","body":"Let us say we have the following stack trace:\r\n\r\n```\r\n\tExpected 'bar' to be 'bar1'\r\n\tassert@/Users/foo/Workspace/ws/examples/browser-js/test-dist/index.js:11066:27 <- ~/expect/lib/assert.js:29:0\r\n\ttoBe@/Users/foo/Workspace/ws/examples/browser-js/test-dist/index.js:8037:28 <- ~/expect/lib/Expectation.js:86:0\r\n\t/Users/foo/Workspace/ws/examples/browser-js/test-dist/index.js:7909:75 <- test/unit.ts:31:48\r\n```\r\n\r\nFirst I'd like to filter stack traces from `~/except`. Second I want to only see the original source (the part after `<-`). \r\n\r\nI could actually hack the `lib/reporter.js` at line 92 like this to achieve this result:\r\n\r\n```\r\n    // filter lines\r\n    msg = msg.split('\\n').filter(line => !line.match(/~\\/expect\\/lib/)).join('\\n');\r\n    // map lines\r\n    msg = msg.split('\\n').map(line => line.match(/\\/(.*)<-/) ? line.replace(/\\/(.*)<-/, '') : line).join('\\n');\r\n```\r\n\r\nThe result will be:\r\n\r\n```\r\n\tExpected 'bar' to be 'bar1'\r\n\t test/unit.ts:31:48\r\n```\r\n\r\nCan 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."},"comment":{"url":"https://api.github.com/repos/karma-runner/karma/issues/comments/248404728","html_url":"https://github.com/karma-runner/karma/issues/2119#issuecomment-248404728","issue_url":"https://api.github.com/repos/karma-runner/karma/issues/2119","id":248404728,"user":{"login":"donaldpipowitch","id":1152805,"avatar_url":"https://avatars.githubusercontent.com/u/1152805?v=3","gravatar_id":"","url":"https://api.github.com/users/donaldpipowitch","html_url":"https://github.com/donaldpipowitch","followers_url":"https://api.github.com/users/donaldpipowitch/followers","following_url":"https://api.github.com/users/donaldpipowitch/following{/other_user}","gists_url":"https://api.github.com/users/donaldpipowitch/gists{/gist_id}","starred_url":"https://api.github.com/users/donaldpipowitch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/donaldpipowitch/subscriptions","organizations_url":"https://api.github.com/users/donaldpipowitch/orgs","repos_url":"https://api.github.com/users/donaldpipowitch/repos","events_url":"https://api.github.com/users/donaldpipowitch/events{/privacy}","received_events_url":"https://api.github.com/users/donaldpipowitch/received_events","type":"User","site_admin":false},"created_at":"2016-09-20T19:21:30Z","updated_at":"2016-09-20T19:21:30Z","body":"Very strange. I wonder why my setup behaves differently. Because I get every single line for `formatError` and not the whole output I generate several empty new lines on my terminal when I try to filter out node modules :/\r\n\r\nI use mocha and except. Maybe someone else has the same problem...\r\n\r\nMy output:\r\n\r\n```\r\n    ✖ dummy test 2\r\n      PhantomJS 2.1.1 (Mac OS X 0.0.0)\r\n    Expected 1 to equal 2\r\n\r\n      + expected - actual\r\n\r\n      -1\r\n      +2\r\n\r\n//empty line, was: assert@webpack:///~/expect/lib/assert.js:29:0 <- dist-tests/index.js:4741:27\r\n//empty line, was: toEqual@webpack:///~/expect/lib/Expectation.js:81:0 <- dist-tests/index.js:7172:30\r\n    ./tests/unit.tsx:27:2 // was: webpack:///tests/unit.tsx:22:31 <- dist-tests/index.js:15070:75\r\n```\r\n\r\nThe two empty lines shouldn't be there...\r\n\r\nAlso very strange: my pattern is `\"source <- compiled\"` not `\"compiled <- source\"`?"}}
{"actor":{"display_login":"donaldpipowitch"}}