1

What is the best elegant approach for debugging a large E2E test?

I am using TestCafe automation framework and currently. I'm facing multiple tests that are flaky and require a fix.

The problem is that every time I modify something within the test code I need to run the entire test from the start in order to see if that new update succeeds or not.

I would like to hear ideas about strategies regard to how to debug an E2E test without losing your mind.

Current debug methods:

  • Using the builtin TestCafe mechanism for debugging in the problematic area in the code and try to comment out everything before that line. But that really doesn't feel like the best approach.
  • When there are prerequisite data such as user credentials,url,etc.. I manually Declare those again just before the debug().

PS: I know that tests should be focused as much as possible and relatively small but this is what we have now.

Thanks in advance

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
teslaTanch
  • 93
  • 9

2 Answers2

2

You can try using the flag

--debug-on-fail

This pauses the test when it fails and allows you to view the tested page and determine the cause of the fail. Also use test.only to to specify that only a particular test or fixture should run while all others should be skipped https://devexpress.github.io/testcafe/documentation/using-testcafe/command-line-interface.html#--debug-on-fail

VysakhMohan
  • 567
  • 3
  • 9
  • Thanks, @VysakhMohan, I am aware and use the mentioned debug CLI keyword. --debug-on-fail But I actually looking for a different approach for debugging large tests (~300 lines of code per test). Currently, I am commenting most of the beginning of the test to skip all of it and reach exactly to the problematic line – teslaTanch Apr 22 '20 at 07:09
  • @teslaTanch, could you please clarify why you need to comment most part of the test? It will break test execution. Are you trying to execute multiple test cases in one test? If so, it is better to split the test into smaller ones via beforeEach hooks and perform setup actions. – Shurygin.Sergey Apr 22 '20 at 08:57
1

You can use the takeScreenshot action to capture the existing state of the application during the test. Test Café stores the screenshots inside the screenshots sub-directory and names the file with a timestamp. Alternatively, you can add the takeOnFails command line flag to automatically capture the screen whenever a test fails, so at the point of failure. Another option is to slow down the test so it’s easier to observe when it is running. You can adjust the speed using the - speed command line flag. 1 is the fastest speed and 0.01 the slowest. Then you can record the test run using the - video command line flag, but you need to set up FFmpeg for this.