Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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 @@ -14,8 +14,16 @@ export const configSteps: Steps = (state: State) => {
}

return ({ given, when, then }: StepsDefinitionCallbackOptions) => {
const originalEnv = process.env;
beforeEach(() => {
state.options = {};
state.config = undefined;
state.events = [];
process.env = { ...originalEnv };
});

afterEach(() => {
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/e2e/tests/config.spec.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test should not be part of the e2e suite, although it uses gherkin steps, it is fast and can be run during normal unit test execution

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { configSteps } from '../step-definitions/configSteps';
import type { State } from '../step-definitions/state';
import { autoBindSteps, loadFeatures } from 'jest-cucumber';
import { CONFIG_FEATURE } from '../constants';

jest.setTimeout(50000);
describe('config', () => {
const state: State = {
resolverType: 'in-process',
options: {},
config: undefined,
events: [],
};
autoBindSteps(
loadFeatures(CONFIG_FEATURE, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The config.feature gherkin file is part of the in-process and rpc tests. In-Process and RPC cover all *.feature files. I don't think there is need for a specific config.spec.ts file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct :) However the motivation for having a separate config.spec.ts file was to enable the test to run without requiring a container to be started

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