@configdirector/openfeature-server-provider 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,6 +25,29 @@ const newCheckout = await client.getBooleanValue("new-checkout", false);
25
25
 
26
26
  Full details are in the [official documentation](https://docs.configdirector.com/sdks/server/openfeature-node).
27
27
 
28
+ ## Test your code
29
+
30
+ Tests of code that reads flags through OpenFeature swap the provider for the in-memory one the OpenFeature Node.js SDK ships, `TypedInMemoryProvider` (`@openfeature/server-sdk` 1.21 and newer), so the test controls the values and nothing from ConfigDirector is involved:
31
+
32
+ ```ts
33
+ import { OpenFeature, TypedInMemoryProvider } from "@openfeature/server-sdk";
34
+
35
+ const provider = new TypedInMemoryProvider({
36
+ "new-checkout": { variants: { on: true, off: false }, defaultVariant: "on" },
37
+ });
38
+ await OpenFeature.setProviderAndWait(provider);
39
+ const client = OpenFeature.getClient();
40
+
41
+ expect(await client.getBooleanValue("new-checkout", false)).toBe(true);
42
+
43
+ provider.putConfiguration({
44
+ "new-checkout": { variants: { on: true, off: false }, defaultVariant: "off" },
45
+ });
46
+ expect(await client.getBooleanValue("new-checkout", true)).toBe(false);
47
+ ```
48
+
49
+ Full details are in the [testing section of the official documentation](https://docs.configdirector.com/sdks/openfeature/node-js#test-your-code).
50
+
28
51
  ## Documentation
29
52
 
30
53
  Refer to the [official documentation for the OpenFeature Node.js provider](https://docs.configdirector.com/sdks/server/openfeature-node).