0

I am using testcafe to test an app served through SpringBoot.

I am successfully using appCommand to start the app before launching the tests. However, the app takes a bit to start (10-30 seconds, depending on the environment and load) so I need to use appInitDelay=40000.

It is a problem, because if the app takes only 10s to start... 20s are wasted... and precisely it takes short in the dev environment, where having the developer waiting for nothing for 20 extra seconds is a pain for the productivity (lost of focus).

Is there any better approach?

I have tried pageRequestTimeout but it does not work, because the tomcat is not ready and the test fails even before waiting for the page (the pageRequestTimeout is not even triggered). I have also tried retryTestPages but neither it works, because tomcat is ready around 1s before the actual SpringBootApp is ready... so the connection happens and tomcat return an error... again causing the test to fail.

Any other idea?

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
Javier Sedano
  • 923
  • 3
  • 11
  • 28
  • 1
    Since it's a Spring Boot application, you could implement an health endpoint to you check every x seconds in order to see whether the application is up or not (for instance, by checking if the response code is 200 or so). As soon as the check is valid, you could continue with running the testcafe command. All of this could be implemented within a batch script that the developers locally run on their machines. – Martin H. Jun 26 '21 at 11:52

1 Answers1

0

for the future, what I have finally done is:

-For the CI, launch the TestCafe with appCommand="..." and appInitDelay="40000". It will waste average around 30s on every CI... but well, at least there is not (usually) a human waiting for it.

-For dev, do not launch the app, just expect the app to be running (the developer will launch it by other means).

Javier Sedano
  • 923
  • 3
  • 11
  • 28