Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run TestCafe tests with throttling connection?

I need to check functionality if a file is uploading longer then 1 minute.

To check it with manual testing I use Chrome Dev Tools to set Throttling "Slow 3G". But I can't figure out how to do it with TestCafe.

like image 968
QWAma Avatar asked Sep 18 '25 01:09

QWAma


1 Answers

TestCafe does not have an API to set the throttling. However, TestCafe uses Chrome DevTools Protocol internally so you can get access to internal CDP methods. Please refer to the following links to get started:

Chrome DevTools Protocol

chrome-remote-interface package

chrome-remote-interface repo

Please also take a look at the following example which shows how to enable file downloading in chrome headless.

I think you need to combine this example with the CDP Network.emulateNetworkConditions method.

Please refer to this article https://chromedevtools.github.io/devtools-protocol/tot/Network#method-emulateNetworkConditions

like image 137
Alex Kamaev Avatar answered Sep 19 '25 22:09

Alex Kamaev