'Feature flags in Next js application
I am using Cypress to test my Next.js application. Also I have set feature flags to hide a specific item. In _app.js I wrapped my components like this:
<FlagsContainer><Component {...props} /></FlagsContainer>
Inside FlagsContainer I fetch my feature flags from an external service and if the page for example corresponds to login I hide that page. The feature is working well.
Also I test my app using Cypress and Cucumber. Taking into account that for local environment the feature flag is not set, my tests are working because the page is displayed, but on prod env. the feature flag is set and the page will be hidden, and deploying the app to prod will run again the CI making the test to fail because the page won't be there. Inside my Cucumber file I have a test like this:
Scenario: Get login page
Given i am on welcome page
And i click on login page
Then i should see login page
Also I implemented this test and all works.
How to avoid failing the Cypress test on production? How to run the tests/scenarios taking into account that when the flag is set to true the scenario above should work and if is false another scenario should be applied? How to configure Cypress?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
