From f871be6463b886b7d84ac102ea260383de2ea241 Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Mon, 26 Aug 2019 10:13:50 +0200 Subject: [PATCH] fix(karma): error messages truncated due to custom formatter Currently error messages printed out by Karma will be truncated sometimes. This can happen for example if a jasmine test assertion contains parenthesis characters. For example: ```ts expect(element.style.transform).toBe('translate3d(...)') ``` If such an assertion fails, the error message from the browser looks like that: ``` Error: Expected 'translate3d(50px, 100px, 0px)' to be 'translate3d(500px, 100px, 0px)'. at at UserContext.eval (../../src/cdk/drag-drop/directives/drag.spec.ts:79:44 <- bin/src/cdk/drag-drop/directives/drag.spec.js:104:57) ``` Currently the format error function that is supposed to clean up paths in the error message, accidentally matches the first path starting with `(50px, 100px, 0px` and ending with `drag.spec.ts:79:44`). Resulting in a broken error message like: ``` Error: Expected 'translate3d(../src/cdk/drag-drop/directives/drag.spec.ts:79:44 <- bin/src/cdk/drag-drop/directives/drag.spec.js:104:57) at UserContext.eval (external/npm/node_modules/zone.js/dist/zone-testing-bundle.js:4954:30) at ZoneDelegate.invoke (external/npm/node_modules/zone.js/dist/zone-testing-bundle.js:391:26) ``` --- packages/karma/src/karma.conf.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/karma/src/karma.conf.js b/packages/karma/src/karma.conf.js index 9a859c4c1b..f0ebabc998 100644 --- a/packages/karma/src/karma.conf.js +++ b/packages/karma/src/karma.conf.js @@ -418,7 +418,7 @@ try { // This is a bazel specific formatError that removes the workspace // name from stack traces. // Look for filenames of the format "(::" - const FILENAME_REGEX = /\(([^:]+)(:\d+:\d+)/gm; + const FILENAME_REGEX = /\(([^:\n\r]+)(:\d+:\d+)/gm; msg = msg.replace(FILENAME_REGEX, (_, p1, p2) => { if (p1.startsWith('../')) { // Remove all leading "../"