Feature Flag

CI/CD

// Definition

A runtime toggle that turns code paths on or off without redeploying. Enables progressive rollouts, A/B tests, and instant kill switches. Decouples deploy from release — code ships dark and is enabled later.

// Code Example

CypressTest both branches of a feature flag
TypeScript
function withFlag(name: string, on: boolean) {
  cy.intercept('GET', '/api/flags', { body: { [name]: on } });
}

it('shows new checkout when flag is on', () => {
  withFlag('newCheckout', true);
  cy.visit('/cart');
  cy.get('[data-testid=new-checkout]').should('be.visible');
});

it('falls back to legacy when flag is off', () => {
  withFlag('newCheckout', false);
  cy.visit('/cart');
  cy.get('[data-testid=legacy-checkout]').should('be.visible');
});

// Related terms