11cb0ef41Sopenharmony_ci# Writing tests
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciUndici is tuned for a production use case and its default will keep
41cb0ef41Sopenharmony_cia socket open for a few seconds after an HTTP request is completed to
51cb0ef41Sopenharmony_ciremove the overhead of opening up a new socket. These settings that makes
61cb0ef41Sopenharmony_ciUndici shine in production are not a good fit for using Undici in automated
71cb0ef41Sopenharmony_citests, as it will result in longer execution times.
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciThe following are good defaults that will keep the socket open for only 10ms:
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ci```js
121cb0ef41Sopenharmony_ciimport { request, setGlobalDispatcher, Agent } from 'undici'
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciconst agent = new Agent({
151cb0ef41Sopenharmony_ci  keepAliveTimeout: 10, // milliseconds
161cb0ef41Sopenharmony_ci  keepAliveMaxTimeout: 10 // milliseconds
171cb0ef41Sopenharmony_ci})
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_cisetGlobalDispatcher(agent)
201cb0ef41Sopenharmony_ci```
21