Skip to content

Tutorial - How to test feature flags #5476

Closed

Description

@ivanagas

Strapline

Explain the idea in a sentence or two

A tutorial on how to test feature flags. Build an app, add feature flags, show how to mock PostHog in this, and write code that covers the flags.

Why should we do it?

How it will it be useful or interesting for readers/viewers

Multiple users asking about it, it’s non-obvious and probably needed by lots of people.

https://posthogusers.slack.com/archives/C01GLBKHKQT/p1678344199227279

https://posthog.slack.com/archives/C03JJKLEC8L/p1677608938579749

Headlines options

think of two of three possible headlines we could use

How to test with feature flags

Writing unit tests for feature flags

How to write tests for feature flagged code

Outline

Bullet point outline of structure / questions / topics to be covered

  • Build a python or javascript app
  • Write a test
  • Adding a feature flag
  • Setting up test with feature flag
  • Mock PostHog
    • Pass mocked PostHog to provider?
    • Create mocked PostHog client?
    • At PostHog, we mock the /decide endpoint or mock the methods directly
    • Test for when posthog.isFeatureEnabled = false
    • Test for when posthog.isFeatureEnabled = true
  • Check for a winner in the experiment and remember to reimplement tests. They kind of provide that reminder themselves.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions