Hey, Aagyajeet - what is your stack? We have some basic documentation on server-side testing
here.
For API tests, i've seen some organizations initialize GrowthBook and set attributes in middleware, and then attach the GrowthBook instance to the request object to be used in various controllers.