40 / 48 · 16 CI/CD Pipelines · Deployment Strategies← prev⊞ allnext →☰ Read as one page
6.6Feature Flags as a Testing Strategy
Feature flags decouple deployment from release. You deploy the code but keep new features hidden behind flags, then enable them gradually.
// Feature flag check in application code
if (featureFlags.isEnabled('new-checkout-flow', { userId })) {
return newCheckoutFlow();
} else {
return legacyCheckoutFlow();
}
QA implications of feature flags:
- Test both states of every flag (enabled and disabled)
- Test flag combinations if features interact
- Verify that disabling a flag cleanly reverts to the old behavior
- Clean up old flags -- stale flags create technical debt and increase test complexity
// Test both flag states
test('checkout flow with new feature enabled', async () => {
await setFeatureFlag('new-checkout-flow', true);
// ... test new behavior
});
test('checkout flow with new feature disabled', async () => {
await setFeatureFlag('new-checkout-flow', false);
// ... test legacy behavior
});