Feature flags and Stage are both powerful tools for testing in production-like environments. But they solve fundamentally different problems. Here's how to think about when to use each.
What Feature Flags Do
Feature flags let you toggle code paths without deploying new code. They're great for:
- Gradual rollouts: Release to 1% of users, then 10%, then 100%
- Kill switches: Instantly disable a feature if something goes wrong
- A/B testing: Show different variations to different users
- User targeting: Enable features for specific users or segments
What Stage Does
Stage lets you mutate API responses without changing upstream systems. It's great for:
- Testing edge cases: Simulate any response from your dependencies
- Error scenario testing: Test how your app handles failures
- Preview environments: Show stakeholders how features will work with different data
- Debugging production issues: Reproduce exact API responses that caused problems
The Key Difference
Feature flags change your code's behavior. Stage changes what your code receives.
Consider this example:
Feature flag approach:
if (featureFlags.isEnabled('new-pricing')) {
showNewPricing();
} else {
showOldPricing();
}
Stage approach:
// Stage mutates the pricing API response
{
"match": { "path": "/api/pricing" },
"action": {
"type": "override",
"body": { "price": 99.99, "currency": "USD" }
}
}
With feature flags, your code must explicitly handle both cases. With Stage, your code receives different data and responds accordingly.
When to Use Feature Flags
Use feature flags when:
- You're rolling out new code: Feature flags are perfect for gradual releases
- You need a kill switch: For quickly disabling features in production
- You're running A/B tests: Comparing user behavior across variations
- You need user-level control: Different experiences for different users
When to Use Stage
Use Stage when:
- Testing dependency behavior: How does your app handle different API responses?
- You can't control upstream data: The data comes from third parties
- Testing error scenarios: Timeouts, rate limits, invalid responses
- Preview environments: Showing how features work with specific data
Using Both Together
The real power comes from using both tools together.
Example: Testing a new checkout flow
- Feature flag: Roll out the new checkout UI to 10% of users
- Stage: Test how the new UI handles different payment responses
This combination lets you: - Control who sees the new code (feature flag) - Test all the scenarios the new code might encounter (Stage)
Decision Framework
Ask yourself:
- Are you changing code behavior? → Feature flag
- Are you testing API response handling? → Stage
- Do you need to roll back instantly? → Feature flag
- Are you testing third-party integrations? → Stage
- Do you need user-level targeting? → Feature flag
- Do you need data-level testing? → Stage
Conclusion
Feature flags and Stage are complementary tools. Feature flags give you control over code paths. Stage gives you control over data paths. The best testing strategies use both.
Ready to add Stage to your testing toolkit? Get started free.