-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat separate message from stack trace #12
Feat separate message from stack trace #12
Conversation
The CTRF Test objects has a message and a trace attribute. According to the documentation, the message should contain a description of the test result and the trace should contain the stack trace of a failed test. The reporter receives the assertion description and the stack trace intermingled and stores them both, redundantly, in the message and trace attributes. This change splits the assert description from the stack trace as shown stores them separately. Everything above the dashed line is stored in message while lines below are stored in trace. ``` Error: expect(received).toStrictEqual(expected) // deep equality - Expected - 1 + Received + 1 @@ -23,11 +23,11 @@ "isSelected": true, }, ], "damper_setup": "damper_1,damper_2", "driver": "driver1", - "id": 0, + "id": 1, "isCurrentlyUsedInProfile": true, "isIntermediateState": true, "isSelectedForAll": false, "lap": "LapName1", "lap_id": 1, ------------------------- at lap-channel-type-table-data-creation.service.spec.ts:185:26 at zone-testing-bundle.umd.js:409:30) at zone-testing-bundle.umd.js:3830:43) at zone.js/bundles/zone-testing-bundle.umd.js:408:56) ``` This simplifies processing of both values for later tools when eval- uating the test results.
src/generate-report.ts
Outdated
// slice message until stack trace part is found and remove ansi color codes | ||
failureDetails.message = joinedMessages.slice(0, match?.index).replace(colorCodesPattern, '') | ||
|
||
// slice from begin of stack trace, remove indentation of each line and return the trace as string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comment
src/generate-report.ts
Outdated
failureDetails.message = testResult.failureMessages.join('\r\n') | ||
const joinedMessages = testResult.failureMessages.join('\n') | ||
const match = joinedMessages.match(messageStackTracePattern) | ||
// slice message until stack trace part is found and remove ansi color codes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comment
@@ -148,16 +149,26 @@ class GenerateCtrfReport implements Reporter { | |||
} | |||
|
|||
extractFailureDetails(testResult: AssertionResult): Partial<CtrfTest> { | |||
const messageStackTracePattern = /^\s{4}at/mu | |||
const colorCodesPattern = /\x1b\[\d+m/gmu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disable eslint for this line by adding below comment to line above.
// eslint-disable-next-line no-control-regex
Dealing with ANSI escape codes for coloring text in terminal outputs is a valid use case.
Great work for your first contribution in typescript! Please run the following static analysis checks - |
The CTRF Test objects has a message and a trace attribute. According to
the documentation, the message should contain a description of the test
result and the trace should contain the stack trace of a failed test.
The reporter receives the assertion description and the stack trace
intermingled and stores them both, redundantly, in the message and trace
attributes.
This change splits the assert description from the stack trace as shown
stores them separately. Everything above the dashed line is stored in
message while lines below are stored in trace.
This simplifies processing of both values for later tools when eval-
uating the test results.
Note: I'm totally new to TypeScript, got a short introduction from my co-worker today to be able to start this. Hints on style are welcome, therefore.