Skip to content

Commit f871be6

Browse files
devversionalexeagle
authored andcommitted
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 <Jasmine> 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) ```
1 parent 5551ab9 commit f871be6

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

packages/karma/src/karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ try {
418418
// This is a bazel specific formatError that removes the workspace
419419
// name from stack traces.
420420
// Look for filenames of the format "(<filename>:<row>:<column>"
421-
const FILENAME_REGEX = /\(([^:]+)(:\d+:\d+)/gm;
421+
const FILENAME_REGEX = /\(([^:\n\r]+)(:\d+:\d+)/gm;
422422
msg = msg.replace(FILENAME_REGEX, (_, p1, p2) => {
423423
if (p1.startsWith('../')) {
424424
// Remove all leading "../"

0 commit comments

Comments
 (0)