Skip to content

Commit

Permalink
Merge pull request #2655 from near/feature-flag-test
Browse files Browse the repository at this point in the history
test(flags): verify that every feature flag specifies every environment
  • Loading branch information
andy-haynes authored May 12, 2022
2 parents 76d1545 + 733a6be commit 85421cc
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/frontend/test/feature_flags.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Environments from '../../../features/environments.json';
import Flags from '../../../features/flags.json';

const nonEnvironmentKeys = [
'createdAt',
'createdBy',
];

function formatEnvironments(environments) {
return environments.sort().join(',');
}

test('all feature flags specify all environments', () => {
const allEnvironments = Object.values(Environments);
Object.entries(Flags).forEach(([flag, flagEnvironments]) => {
const specifiedEnvironments = Object.keys(flagEnvironments)
.filter((env) => !nonEnvironmentKeys.includes(env));

const actual = `${flag}:${formatEnvironments(specifiedEnvironments)}`;
const expected = `${flag}:${formatEnvironments(allEnvironments)}`;

expect(actual).toBe(expected);
});
});

0 comments on commit 85421cc

Please sign in to comment.