Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/providers/flagd/src/e2e/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export const UNSTABLE_CLIENT_NAME = 'unstable';
export const UNAVAILABLE_CLIENT_NAME = 'unavailable';

export const GHERKIN_FLAGD = getGherkinTestPath('*.feature');
export const CONFIG_FEATURE = getGherkinTestPath('config.feature');
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@ export const configSteps: Steps = (state: State) => {
}
}

const originalEnv = { ...process.env };

return ({ given, when, then }: StepsDefinitionCallbackOptions) => {
beforeEach(() => {
state.options = {};
state.config = undefined;
state.events = [];
Object.keys(process.env)
.filter((key) => !Object.prototype.hasOwnProperty.call(originalEnv, key))
.forEach((key) => delete process.env[key]);
Object.assign(process.env, originalEnv);
});

given(/^an option "(.*)" of type "(.*)" with value "(.*)"$/, (name: string, type: string, value: string) => {
state.options[mapName(name)] = mapValueToType(value, type);
});
Expand Down
23 changes: 23 additions & 0 deletions libs/providers/flagd/src/lib/configuration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import type { Config, FlagdProviderOptions } from './configuration';
import { getConfig } from './configuration';
import { DEFAULT_MAX_CACHE_SIZE } from './constants';
import type { EvaluationContext } from '@openfeature/server-sdk';
import { configSteps } from '../e2e/step-definitions/configSteps';
import type { State } from '../e2e/step-definitions/state';
import { autoBindSteps, loadFeatures } from 'jest-cucumber';
import { CONFIG_FEATURE } from '../e2e';

describe('Configuration', () => {
const OLD_ENV = process.env;
Expand Down Expand Up @@ -163,4 +167,23 @@ describe('Configuration', () => {
});
});
});

describe('config.feature', () => {
const state: State = {
resolverType: 'in-process',
options: {},
config: undefined,
events: [],
};

autoBindSteps(
loadFeatures(CONFIG_FEATURE, {
scenarioNameTemplate: (vars) => {
const tags = [...new Set([...vars.scenarioTags, ...vars.featureTags])];
return `${vars.scenarioTitle}${tags.length > 0 ? ` (${tags.join(', ')})` : ''}`;
},
}),
[configSteps(state)],
);
});
});