Skip to content
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

willBeRetried: false for all scenarios regardless of retries count #849

Closed
3 tasks done
WTK opened this issue Oct 2, 2022 · 4 comments
Closed
3 tasks done

willBeRetried: false for all scenarios regardless of retries count #849

WTK opened this issue Oct 2, 2022 · 4 comments

Comments

@WTK
Copy link

WTK commented Oct 2, 2022

Current behavior

cucumber messages always have willBeRetried: false for test cases despite them being retried.

I think as a side effect (or direct effect?) the html report generated has no screenshots attached. They're attached when retries == 0, but have no screenshots otherwise.

Desired behavior

Messages have willBeRetried: true if test case will be retried and false otherwise.

Test code to reproduce

No real code - just have a test that is failing and set retries number in cypress to be greater than zero. Observe resulting messages - they all have aforementioned property set to false.

Versions

  • Cypress version: 10.8.0
  • Preprocessor version: 13.0.2
  • Node version: 14.14

Checklist

@WTK
Copy link
Author

WTK commented Oct 3, 2022

It's easy to fix by running this within it handler, setting state in properties (retrieved via retrieveInternalSpecProperties) and then read state in the afterEach right when testCaseFinished message is pushed to the stack.

it(scenarioName, suiteOptions, function() {
    let attempt = cy.state('runnable')._currentRetry
    let retries = cy.state('runnable')._retries
    let isLastAttempt = attempt === retries
    const properties = retrieveInternalSpecProperties();
    properties._retriesState = {
        attempt,
        retries,
        isLastAttempt,
    };
})

afterEach(function() {
    messages.push({
        testCaseFinished: {
            testCaseStartedId,
            timestamp: endTimestamp,
            willBeRetried: !properties._retriesState.isLastAttempt,
        },
    });
})

With that said it doesn't help currently with html output (it still has no screenshots when retries > 0).

@badeball
Copy link
Owner

badeball commented Oct 4, 2022

Feel free to open up a PR on this. I think you can avoid mutating the internal properties though and rather just calculate isLastAttempt in the afterEach(..) block. Also, a change in the messages output should be accompanied by at least one test (in this case it's fine to add a scenario in features/issues/849.feature).

@WTK
Copy link
Author

WTK commented Oct 4, 2022

In my testing those internal properties of cypress were unavailable in the afterEach hook. I'm guessing they clear this information sometime before that.

badeball added a commit that referenced this issue Mar 19, 2023
badeball added a commit that referenced this issue Mar 19, 2023
@badeball
Copy link
Owner

This has been fixed with v16.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants