5

I have test suite where in one of the spec the 5th test-case is dependent on 3rd test-case. While the case is run locally via cypress runner - I do not see any issue in order of running.

But while case is running in CI - I'm seeing 5th is failing randomly [verified that no script errors] & upon analysis I notice that certain data records which are created in 3rd case are not returned for 5th case & hence its failing.

Is there a way to order tests within a spec in Cypress?

Ailia
  • 51
  • 3
  • Not that I'm aware of, restructure your checks, make them independent, move shared logic to before hooks. – pavelsaman Dec 09 '21 at 10:11
  • Another limitation of Cypress uncovered! ThankYou @pavelsaman! – Ailia Dec 09 '21 at 11:23
  • You can also read this https://stackoverflow.com/questions/58936891/cypress-how-can-i-run-test-files-in-order Perhaps something from that will solve your problem. But it still feels hacky and there's no explicit support for running tests in a particular order. – pavelsaman Dec 09 '21 at 11:29
  • Oh Nope! I want the ability to run the tests within a single spec in a particular order & not the test files of the entire suite. – Ailia Dec 09 '21 at 15:03
  • You can refer to the below answer link https://stackoverflow.com/a/59690611 – magan Feb 21 '22 at 11:05
  • 1
    NO, this talks abt multiple test files in a specific order.. my question is tests within a spec file in specific order – Ailia Mar 01 '22 at 05:34

1 Answers1

1

Unfortunately it is not possible to run tests within the same spec file in specific order in Cypress currently.

Cypress is basically just scheduling events to happen, with no additional control beyond that, so there is no way to guarantee tests will run in a specific order.

jacklynch
  • 11
  • 1