Skip to content

Commit c9e41b7

Browse files
committed
Move env snapshot to function scope in configSteps
Signed-off-by: Marko Mlakar <[email protected]>
1 parent dafd6ba commit c9e41b7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

libs/providers/flagd/src/e2e/step-definitions/configSteps.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import type { State, Steps } from './state';
33
import { CacheOption, getConfig, ResolverType } from '../../lib/configuration';
44
import { mapValueToType } from './utils';
55

6-
const originalEnv = { ...process.env };
7-
86
export const configSteps: Steps = (state: State) => {
97
function mapName(name: string): string {
108
switch (name) {
@@ -16,12 +14,17 @@ export const configSteps: Steps = (state: State) => {
1614
}
1715

1816
return ({ given, when, then }: StepsDefinitionCallbackOptions) => {
17+
const originalEnv = process.env;
1918
beforeEach(() => {
2019
state.options = {};
2120
state.config = undefined;
2221
state.events = [];
2322
process.env = { ...originalEnv };
2423
});
24+
25+
afterEach(() => {
26+
process.env = originalEnv;
27+
});
2528
given(/^an option "(.*)" of type "(.*)" with value "(.*)"$/, (name: string, type: string, value: string) => {
2629
state.options[mapName(name)] = mapValueToType(value, type);
2730
});

0 commit comments

Comments
 (0)