FlagFix
Guides

How to test flag evaluation

Pass fetchImpl. Do not point tests at production.

لا توجد ترجمة عربية منشورة لهذه الصفحة بعد. النص الإنجليزي هو المرجع.

Last updated on

const client = createFlagFix({
  serverKey: "test-server-key",
  apiHost: "https://api.flagfix.io",
  fetchImpl: async () =>
    new Response(
      JSON.stringify({
        flags: [{ key: "new_checkout", enabled: true, value: null, configurationVersion: 1 }],
        matchedSegments: [],
        configurationVersion: 1,
      }),
      { status: 200, headers: { "content-type": "application/json" } },
    ),
});

Pass fetchImpl so the test never calls the real API. Keep the JSON aligned with the evaluate-all response: flags, matchedSegments, and configurationVersion. The fuller example is Unit testing.

React tests should set lifecycle: false.

هل كانت هذه الصفحة مفيدة؟