Skip to main content

Retry only Failures

A substantial percentage of your CI retries are spent running tests that already passed on the previous run. Not only is it a waste of time & resources, it's also an opportunity for flakes to cause troubles.

With Retry only Failures, when you retry one (or all the) nodes, Knapsack Pro executes only the tests that failed last time on that node.

Configuration

To enable Retry only Failures, npm install @knapsack-pro/cypress to v10 or later.

Knapsack Pro uses KNAPSACK_PRO_TEST_QUEUE_ID to uniquely identify a queue on the first run and all its retries.

Additional configuration for CircleCI

On CircleCI, you need to expose the pipeline number as follows:

# ...
environment:
CIRCLE_PIPELINE_NUMBER: << pipeline.number >>

Example

Let's say your test suite contains 3 tests:

  • a.cy.js
  • b.cy.js
  • c.cy.js

If you run your tests on 2 nodes, you could expect the following split:

  • Node 0: executes a.cy.js and b.cy.js where one test in a.cy.js:10 fails and one test in b.cy.js:20 is skipped
  • Node 1: executes c.cy.js successfully

If you retry Node 0, Retry only Failures will execute only a.cy.js. If you retry Node 1, Retry only Failures will execute no tests.