Skip to content

Improve flaky and errored tests in report #20

@ysfaran

Description

@ysfaran

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:

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:

Image

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 snippet field, which field should I use: extra or just a field snippet next to stack and message
  • If we decide to add retry attempt details, which field should I use: extra or a new field retryAttempts which would be an Array<CtrfTest> without retryAttempts.

(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!)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions