cypress-commands icon indicating copy to clipboard operation
cypress-commands copied to clipboard

Make a command not count towards the reliability limit

Open Lakitna opened this issue 5 years ago • 2 comments

Type of feature

  • [ ] Add a new command
  • [ ] Extend a default Cypress command
  • [ ] Change a Cypress-commands command
  • [x] Other

What do you want to accomplish?

When an assertion fails the previous command will be retried until the assertion passes. Only one command will be retried. I want to find a way to make Cypress retry 2 or more commands instead.

Why?

This can be very useful for improving tests stability when building custom commands or when added to certain commands like for example text().

Describe possible implementations

The only existing thing in Cypress that resembles this behaviour is the should(fn). Creating an alias for should is a last resort to get this behaviour. It would be a lot better if we can hook into the underlying logic of should instead to bypass the default chaining logic.

Additional context

The first step would be to find out if this is even possible. Next step would be to find out if this behaviour can be added to existing commands with an option.

Lakitna avatar Apr 07 '19 19:04 Lakitna

So I worked on this a bit while making the .attribute() command.

When creating a command with the option type: 'assertion' you can make Cypress retry both the command itself and the preceding command. This results basically in a command that behaves like .should(fn) with the difference that it actually yields the returned value.

Now hold your horses it's not all good. Cypress retries everything in the command, including things like setup and logging. This results in a log entry for every time the command is retried, a bit overkill.

Also note that verifyUpcomingAssertions does not work when using type: 'assertion. In this context, this means that default implicit assertions do not work and will have to be reimplemented for every command.

Lakitna avatar May 16 '19 13:05 Lakitna

There are currently no plans for doing any work on this. I simply don't have any leads to make this work, so I feel it's not worth spending time on this.

I'll leave it open, as a place to make suggestions for how to do this.

Lakitna avatar Sep 15 '21 10:09 Lakitna