https://www.growthbook.io/ logo
#announcements
Title
# announcements
s

silly-crayon-99948

07/31/2023, 9:02 PM
RE: programmatically replicate the state of an environment I would like to fetch a json that contains the name of the flag and the on/off state from a specific GrowthBook environment I have defined (e.g. “development”). I am using node.js and need this information to set up our feature testing (cucumber.js) Happy to read and follow instructions if you can link me to the right spot or help me find it.
b

better-magician-65629

07/31/2023, 9:27 PM
when you create an SDK connection you'll get a client key and API host you can use to configure the SDK. if you make a request to the endpoint, you can see what this JSON looks like. if you want to add this to your tests without making network calls (and impacting your usage of the growthbook API's) you can save the file as JSON, import/require it into your tests, and call
setFeatures(theJson)
on the SDK or pass it to your Context. here's an example where we set mock features in our react tests. let us know if you need anymore info.
s

silly-crayon-99948

08/01/2023, 2:09 PM
Tisha Murvihill [7:59 AM] Thank you Tina, I love it that you can mock flags for the unit tests in react. Thank you for the tip! We do want to run the tests with the current actual state of the flags, rather than a mocked state. I was able to get what I needed just from the returned JSON. I got confused thinking I needed to specify the environment, but it was already specified in the config that was set up by another dev. Now I understand how it works! Thank you for the response.
🙌 1
b

better-magician-65629

08/01/2023, 4:49 PM
awesome! glad it's all figured out.
11 Views