RE: programmatically replicate the state of an env...
# announcements
s
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
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
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
awesome! glad it's all figured out.