cypress-failed-log icon indicating copy to clipboard operation
cypress-failed-log copied to clipboard

Add support for retries specified in each individual test (as opposed to global config)

Open svegalopez opened this issue 2 years ago • 1 comments

Hi @bahmutov,

I was wondering if this is something that could be useful ? If so I can open a PR. I noticed the plugin reads the retries configuration when it is first imported (in this line)

Let's say that I have the retries set to 2 in the global cypress.config.js but I want to change that for a specific test. So I do this :

it('dummy', { retries: 3 }, () => {
  // ... some commands ...
})

I think the retries setting of 3 will not be honoured given the place where the plugin reads it, am I correct ? If so, I was wondering if this could help instead :

// inside of onFailed function

if (this.currentTest.final) {
    const filepath = writeFailedTestInfo(info)
    debug('saving the log file %s', filepath)
    info.filepath = filepath
  }

If the final property is not available in older versions of cypress (not sure), then maybe the plugin could fallback to reading the Cypress.config('retries') ad-hoc, inside the onFailed function as opposed to once at the beginning ?

Let me know if this is something you would be open to ?

svegalopez avatar Jan 12 '23 14:01 svegalopez

Sure, could be useful Sent from my iPhoneOn Jan 12, 2023, at 09:48, Sebastian Vega @.***> wrote: Hi @bahmutov, I was wondering if this is something that could be useful ? If so I can open a PR. I noticed the plugin reads the retries configuration when it is first imported (in this line) Let's say that I have the retries set to 2 in the global cypress.config.js but I want to change that for a specific test. So I do this : it('dummy', { retries: 3 }, () => { // ... some commands ... }) I think the retries setting of 3 will not be honoured given the place where the plugin reads it, am I correct ? If so, I was wondering if this could help instead : if (this.currentTest.final) { const filepath = writeFailedTestInfo(info) debug('saving the log file %s', filepath) info.filepath = filepath } If the final property is not available in older versions of cypress (not sure), then maybe we could read the Cypress.config('retries') ad-hoc, inside the onFailed function as opposed to at the beginning ? Let me know if this is something you would be open to ?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

bahmutov avatar Jan 12 '23 15:01 bahmutov