-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Issues
While starting to work with CTRF and playwright-ctrf-json-reporter I noticed some ways to improve the errors. Resolving mentioned issues below would generally help to debug errors more easily.
1. Include snippet for errors
Currently the playwright-ctrf-json-reporter only takes the message and stack from the testResult.error object:
playwright-ctrf-json-reporter/src/generate-report.ts
Lines 370 to 387 in 31d6f32
| extractFailureDetails(testResult: TestResult): Partial<CtrfTest> { | |
| if ( | |
| (testResult.status === 'failed' || | |
| testResult.status === 'timedOut' || | |
| testResult.status === 'interrupted') && | |
| testResult.error !== undefined | |
| ) { | |
| const failureDetails: Partial<CtrfTest> = {} | |
| if (testResult.error.message !== undefined) { | |
| failureDetails.message = testResult.error.message | |
| } | |
| if (testResult.error.stack !== undefined) { | |
| failureDetails.trace = testResult.error.stack | |
| } | |
| return failureDetails | |
| } | |
| return {} | |
| } |
What would be helpful is to also include the testResult.error.snippet in the report, which contains the code snippet, that caused the error. It's a string value that looks like this when logged:
2. Include retry attempts for flaky tests
Currently the code only takes the latestResult into consideration:
| const latestResult = testCase.results[testCase.results.length - 1] |
This is enough to get a summary for the test, but the CTRF report won't contain any details about the failed retry attempts in case of a flaky test. I would like to at least include the errors of the failed attempts, but if attempts are added anyway, it might just make sense to include all details.
Resolution
First of all I want to hear your opinion about these changes. I find them very useful, but just started with CTRF so I don't know about the architectural plans here.
If you find the suggestions useful and you are in need of assistance, I would also gladly work on this issue.
There are just few things I would need to know as the changes themselves are quite straightforward:
- If we decide to add the
snippetfield, which field should I use:extraor just a fieldsnippetnext tostackandmessage - If we decide to add retry attempt details, which field should I use:
extraor a new fieldretryAttemptswhich would be anArray<CtrfTest>withoutretryAttempts.
(P.S. I want to build an internal dashboard for our team to monitor our tests (especially the flaky ones) from different sources like jest and playwright. CTRF is super helpful in this case. I really appreciate all the work done, thank you a lot!)