Repository: open-feature/js-sdk
Pull request #567 (2023-09-13 14:09:42)

chore(deps): update actions/checkout action to v4
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [actions/checkout](https://togithub.com/actions/checkout) | action | major | `v3` -> `v4` |

---

### Release Notes

<details>
<summary>actions/checkout (actions/checkout)</summary>

### [`v4`](https://togithub.com/actions/checkout/blob/HEAD/CHANGELOG.md#v400)

[Compare Source](https://togithub.com/actions/checkout/compare/v3...v4)

-   [Support fetching without the --progress option](https://togithub.com/actions/checkout/pull/1067)
-   [Update to node20](https://togithub.com/actions/checkout/pull/1436)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/open-feature/js-sdk).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi44My4wIiwidXBkYXRlZEluVmVyIjoiMzYuODMuMCIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->



Patch:
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index 3b802aab..9e75dbfa 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -12,7 +12,7 @@ jobs:
     runs-on: ubuntu-latest
 
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: actions/setup-node@v3
         with:
           registry-url: 'https://registry.npmjs.org'
diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml
index 88e23302..4c4be1fa 100644
--- a/.github/workflows/pr-checks.yaml
+++ b/.github/workflows/pr-checks.yaml
@@ -20,7 +20,7 @@ jobs:
           - 20.x
 
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - name: Use Node.js ${{ matrix.node-version }}
         uses: actions/setup-node@v3
         with:
@@ -43,7 +43,7 @@ jobs:
     runs-on: ubuntu-latest
 
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: actions/setup-node@v3
         with:
           node-version: 16
@@ -68,7 +68,7 @@ jobs:
           - 8013:8013
 
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: actions/setup-node@v3
         with:
           # we need 'fetch' for this test, which is only in 18
diff --git a/.github/workflows/publish-experimental.yml b/.github/workflows/publish-experimental.yml
index 5950082b..57604caf 100644
--- a/.github/workflows/publish-experimental.yml
+++ b/.github/workflows/publish-experimental.yml
@@ -13,7 +13,7 @@ jobs:
     runs-on: ubuntu-latest
 
     steps:
-      - uses: actions/checkout@v3
+      - uses: actions/checkout@v4
       - uses: actions/setup-node@v3
         with:
           registry-url: 'https://registry.npmjs.org'
diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml
index 78a8b221..e9ad5044 100644
--- a/.github/workflows/release-please.yml
+++ b/.github/workflows/release-please.yml
@@ -25,7 +25,7 @@ jobs:
     steps:
       # The logic below handles the npm publication:
       - name: Checkout Repository
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
       - name: Setup Node
         uses: actions/setup-node@v3
         with:
diff --git a/packages/client/src/open-feature.ts b/packages/client/src/open-feature.ts
index 90909e81..d9ebd726 100644
--- a/packages/client/src/open-feature.ts
+++ b/packages/client/src/open-feature.ts
@@ -75,6 +75,14 @@ export class OpenFeatureAPI extends OpenFeatureCommonAPI<Provider> implements Ma
       { name, version }
     );
   }
+
+  /**
+   * Clears all registered providers and resets the default provider.
+   * @returns {Promise<void>}
+   */
+  clearProviders(): Promise<void> {
+    return super.clearProvidersAndSetDefault(NOOP_PROVIDER);
+  }
 }
 
 /**
diff --git a/packages/server/src/open-feature.ts b/packages/server/src/open-feature.ts
index 5df264a7..fb6d88aa 100644
--- a/packages/server/src/open-feature.ts
+++ b/packages/server/src/open-feature.ts
@@ -19,7 +19,6 @@ const _globalThis = globalThis as OpenFeatureGlobal;
 export class OpenFeatureAPI extends OpenFeatureCommonAPI<Provider> implements ManageContext<OpenFeatureAPI> {
   protected _defaultProvider: Provider = NOOP_PROVIDER;
 
-  // eslint-disable-next-line @typescript-eslint/no-empty-function
   private constructor() {
     super('server');
   }
@@ -104,6 +103,14 @@ export class OpenFeatureAPI extends OpenFeatureCommonAPI<Provider> implements Ma
       context
     );
   }
+
+  /**
+   * Clears all registered providers and resets the default provider.
+   * @returns {Promise<void>}
+   */
+  clearProviders(): Promise<void> {
+    return super.clearProvidersAndSetDefault(NOOP_PROVIDER);
+  }
 }
 
 /**
diff --git a/packages/shared/src/open-feature.ts b/packages/shared/src/open-feature.ts
index 573ce40e..ca337321 100644
--- a/packages/shared/src/open-feature.ts
+++ b/packages/shared/src/open-feature.ts
@@ -329,12 +329,23 @@ export abstract class OpenFeatureCommonAPI<P extends CommonProvider = CommonProv
         try {
           await provider.onClose?.();
         } catch (err) {
-          this.handleShutdownError(this._defaultProvider, err);
+          this.handleShutdownError(provider, err);
         }
       })
     );
   }
 
+  protected async clearProvidersAndSetDefault(defaultProvider: P): Promise<void> {
+    try {
+      await this.close();
+    } catch (err) {
+      this._logger.error('Unable to cleanly close providers. Resetting to the default configuration.');
+    } finally {
+      this._clientProviders.clear();
+      this._defaultProvider = defaultProvider;
+    }
+  }
+
   private handleShutdownError(provider: P, err: unknown) {
     this._logger.error(`Error during shutdown of provider ${provider.metadata.name}: ${err}`);
     this._logger.error((err as Error)?.stack);


Test patch:
diff --git a/packages/client/test/client.spec.ts b/packages/client/test/client.spec.ts
index 109885c2..58088d03 100644
--- a/packages/client/test/client.spec.ts
+++ b/packages/client/test/client.spec.ts
@@ -96,7 +96,8 @@ describe('OpenFeatureClient', () => {
     OpenFeature.setProvider(MOCK_PROVIDER);
   });
 
-  afterEach(() => {
+  afterEach(async () => {
+    await OpenFeature.clearProviders();
     jest.clearAllMocks();
   });
 
@@ -367,164 +368,165 @@ describe('OpenFeatureClient', () => {
       });
     });
   });
-});
-
-describe('Requirement 1.4.3.1', () => {
-  describe('generic support', () => {
-    it('should support generics', () => {
-      // No generic information exists at runtime, but this test has some value in ensuring the generic args still exist in the typings.
-      const client = OpenFeature.getClient();
-      const details: ResolutionDetails<JsonValue> = client.getObjectDetails('flag', { key: 'value' });
-
-      expect(details).toBeDefined();
-    });
-  });
-});
-
-describe('Evaluation details structure', () => {
-  const flagKey = 'number-details';
-  const defaultValue = 1970;
-  let details: EvaluationDetails<number>;
-
-  describe('Normal execution', () => {
-    beforeAll(() => {
-      const client = OpenFeature.getClient();
-      details = client.getNumberDetails(flagKey, defaultValue);
-
-      expect(details).toBeDefined();
-    });
-
-    describe('Requirement 1.4.2, 1.4.3', () => {
-      it('should contain flag value', () => {
-        expect(details.value).toEqual(NUMBER_VALUE);
-      });
-    });
-
-    describe('Requirement 1.4.4', () => {
-      it('should contain flag key', () => {
-        expect(details.flagKey).toEqual(flagKey);
-      });
-    });
-
-    describe('Requirement 1.4.5', () => {
-      it('should contain flag variant', () => {
-        expect(details.variant).toEqual(NUMBER_VARIANT);
-      });
-    });
 
-    describe('Requirement 1.4.6', () => {
-      it('should contain reason', () => {
-        expect(details.reason).toEqual(REASON);
+  describe('Requirement 1.4.3.1', () => {
+    describe('generic support', () => {
+      it('should support generics', () => {
+        // No generic information exists at runtime, but this test has some value in ensuring the generic args still exist in the typings.
+        const client = OpenFeature.getClient();
+        const details: ResolutionDetails<JsonValue> = client.getObjectDetails('flag', { key: 'value' });
+  
+        expect(details).toBeDefined();
       });
     });
   });
-
-  describe('Abnormal execution', () => {
-    const NON_OPEN_FEATURE_ERROR_MESSAGE = 'A null dereference or something, I dunno.';
-    const OPEN_FEATURE_ERROR_MESSAGE = "This ain't the flag you're looking for.";
-    let nonOpenFeatureErrorDetails: EvaluationDetails<number>;
-    let openFeatureErrorDetails: EvaluationDetails<string>;
-    let client: Client;
-    const errorProvider = {
-      metadata: {
-        name: 'error-mock',
-      },
-      resolveNumberEvaluation: jest.fn((): Promise<ResolutionDetails<number>> => {
-        throw new Error(NON_OPEN_FEATURE_ERROR_MESSAGE); // throw a non-open-feature error
-      }),
-      resolveStringEvaluation: jest.fn((): Promise<ResolutionDetails<string>> => {
-        throw new FlagNotFoundError(OPEN_FEATURE_ERROR_MESSAGE); // throw an open-feature error
-      }),
-    } as unknown as Provider;
-    const defaultNumberValue = 123;
-    const defaultStringValue = 'hey!';
-
-    beforeAll(() => {
-      OpenFeature.setProvider(errorProvider);
-      client = OpenFeature.getClient();
-      nonOpenFeatureErrorDetails = client.getNumberDetails('some-flag', defaultNumberValue);
-      openFeatureErrorDetails = client.getStringDetails('some-flag', defaultStringValue);
-    });
-
-    describe('Requirement 1.4.7', () => {
-      describe('OpenFeatureError', () => {
-        it('should contain error code', () => {
-          expect(openFeatureErrorDetails.errorCode).toBeTruthy();
-          expect(openFeatureErrorDetails.errorCode).toEqual(ErrorCode.FLAG_NOT_FOUND); // should get code from thrown OpenFeatureError
-        });
+  
+  describe('Evaluation details structure', () => {
+    const flagKey = 'number-details';
+    const defaultValue = 1970;
+    let details: EvaluationDetails<number>;
+  
+    describe('Normal execution', () => {
+      beforeEach(() => {
+        const client = OpenFeature.getClient();
+        details = client.getNumberDetails(flagKey, defaultValue);
+  
+        expect(details).toBeDefined();
       });
-
-      describe('Non-OpenFeatureError', () => {
-        it('should contain error code', () => {
-          expect(nonOpenFeatureErrorDetails.errorCode).toBeTruthy();
-          expect(nonOpenFeatureErrorDetails.errorCode).toEqual(ErrorCode.GENERAL); // should fall back to GENERAL
+  
+      describe('Requirement 1.4.2, 1.4.3', () => {
+        it('should contain flag value', () => {
+          expect(details.value).toEqual(NUMBER_VALUE);
         });
       });
-    });
-
-    describe('Requirement 1.4.8', () => {
-      it('should contain error reason', () => {
-        expect(nonOpenFeatureErrorDetails.reason).toEqual(StandardResolutionReasons.ERROR);
-        expect(openFeatureErrorDetails.reason).toEqual(StandardResolutionReasons.ERROR);
-      });
-    });
-
-    describe('Requirement 1.4.9', () => {
-      it('must not throw, must return default', () => {
-        nonOpenFeatureErrorDetails = client.getNumberDetails('some-flag', defaultNumberValue);
-
-        expect(nonOpenFeatureErrorDetails).toBeTruthy();
-        expect(nonOpenFeatureErrorDetails.value).toEqual(defaultNumberValue);
+  
+      describe('Requirement 1.4.4', () => {
+        it('should contain flag key', () => {
+          expect(details.flagKey).toEqual(flagKey);
+        });
       });
-    });
-
-    describe('Requirement 1.4.12', () => {
-      describe('OpenFeatureError', () => {
-        it('should contain "error" message', () => {
-          expect(openFeatureErrorDetails.errorMessage).toEqual(OPEN_FEATURE_ERROR_MESSAGE);
+  
+      describe('Requirement 1.4.5', () => {
+        it('should contain flag variant', () => {
+          expect(details.variant).toEqual(NUMBER_VARIANT);
         });
       });
-
-      describe('Non-OpenFeatureError', () => {
-        it('should contain "error" message', () => {
-          expect(nonOpenFeatureErrorDetails.errorMessage).toEqual(NON_OPEN_FEATURE_ERROR_MESSAGE);
+  
+      describe('Requirement 1.4.6', () => {
+        it('should contain reason', () => {
+          expect(details.reason).toEqual(REASON);
         });
       });
     });
-  });
-
-  describe('Requirement 1.4.13, Requirement 1.4.14', () => {
-    it('should return immutable `flag metadata` as defined by the provider', () => {
-      const flagMetadata = {
-        url: 'https://test.dev',
-        version: '1',
-      };
-
-      const flagMetadataProvider = {
+  
+    describe('Abnormal execution', () => {
+      const NON_OPEN_FEATURE_ERROR_MESSAGE = 'A null dereference or something, I dunno.';
+      const OPEN_FEATURE_ERROR_MESSAGE = "This ain't the flag you're looking for.";
+      let nonOpenFeatureErrorDetails: EvaluationDetails<number>;
+      let openFeatureErrorDetails: EvaluationDetails<string>;
+      let client: Client;
+      const errorProvider = {
         metadata: {
-          name: 'flag-metadata',
+          name: 'error-mock',
         },
-        resolveBooleanEvaluation: jest.fn((): ResolutionDetails<boolean> => {
-          return {
-            value: true,
-            flagMetadata,
-          };
+        resolveNumberEvaluation: jest.fn((): Promise<ResolutionDetails<number>> => {
+          throw new Error(NON_OPEN_FEATURE_ERROR_MESSAGE); // throw a non-open-feature error
+        }),
+        resolveStringEvaluation: jest.fn((): Promise<ResolutionDetails<string>> => {
+          throw new FlagNotFoundError(OPEN_FEATURE_ERROR_MESSAGE); // throw an open-feature error
         }),
       } as unknown as Provider;
-
-      OpenFeature.setProvider(flagMetadataProvider);
-      const client = OpenFeature.getClient();
-      const response = client.getBooleanDetails('some-flag', false);
-      expect(response.flagMetadata).toBe(flagMetadata);
-      expect(Object.isFrozen(response.flagMetadata)).toBeTruthy();
+      const defaultNumberValue = 123;
+      const defaultStringValue = 'hey!';
+  
+      beforeEach(() => {
+        OpenFeature.setProvider(errorProvider);
+        client = OpenFeature.getClient();
+        nonOpenFeatureErrorDetails = client.getNumberDetails('some-flag', defaultNumberValue);
+        openFeatureErrorDetails = client.getStringDetails('some-flag', defaultStringValue);
+      });
+  
+      describe('Requirement 1.4.7', () => {
+        describe('OpenFeatureError', () => {
+          it('should contain error code', () => {
+            expect(openFeatureErrorDetails.errorCode).toBeTruthy();
+            expect(openFeatureErrorDetails.errorCode).toEqual(ErrorCode.FLAG_NOT_FOUND); // should get code from thrown OpenFeatureError
+          });
+        });
+  
+        describe('Non-OpenFeatureError', () => {
+          it('should contain error code', () => {
+            expect(nonOpenFeatureErrorDetails.errorCode).toBeTruthy();
+            expect(nonOpenFeatureErrorDetails.errorCode).toEqual(ErrorCode.GENERAL); // should fall back to GENERAL
+          });
+        });
+      });
+  
+      describe('Requirement 1.4.8', () => {
+        it('should contain error reason', () => {
+          expect(nonOpenFeatureErrorDetails.reason).toEqual(StandardResolutionReasons.ERROR);
+          expect(openFeatureErrorDetails.reason).toEqual(StandardResolutionReasons.ERROR);
+        });
+      });
+  
+      describe('Requirement 1.4.9', () => {
+        it('must not throw, must return default', () => {
+          nonOpenFeatureErrorDetails = client.getNumberDetails('some-flag', defaultNumberValue);
+  
+          expect(nonOpenFeatureErrorDetails).toBeTruthy();
+          expect(nonOpenFeatureErrorDetails.value).toEqual(defaultNumberValue);
+        });
+      });
+  
+      describe('Requirement 1.4.12', () => {
+        describe('OpenFeatureError', () => {
+          it('should contain "error" message', () => {
+            expect(openFeatureErrorDetails.errorMessage).toEqual(OPEN_FEATURE_ERROR_MESSAGE);
+          });
+        });
+  
+        describe('Non-OpenFeatureError', () => {
+          it('should contain "error" message', () => {
+            expect(nonOpenFeatureErrorDetails.errorMessage).toEqual(NON_OPEN_FEATURE_ERROR_MESSAGE);
+          });
+        });
+      });
     });
-
-    it('should return empty `flag metadata` because it was not set by the provider', () => {
-      // The mock provider doesn't contain flag metadata
-      OpenFeature.setProvider(MOCK_PROVIDER);
-      const client = OpenFeature.getClient();
-      const response = client.getBooleanDetails('some-flag', false);
-      expect(response.flagMetadata).toEqual({});
+  
+    describe('Requirement 1.4.13, Requirement 1.4.14', () => {
+      it('should return immutable `flag metadata` as defined by the provider', () => {
+        const flagMetadata = {
+          url: 'https://test.dev',
+          version: '1',
+        };
+  
+        const flagMetadataProvider = {
+          metadata: {
+            name: 'flag-metadata',
+          },
+          resolveBooleanEvaluation: jest.fn((): ResolutionDetails<boolean> => {
+            return {
+              value: true,
+              flagMetadata,
+            };
+          }),
+        } as unknown as Provider;
+  
+        OpenFeature.setProvider(flagMetadataProvider);
+        const client = OpenFeature.getClient();
+        const response = client.getBooleanDetails('some-flag', false);
+        expect(response.flagMetadata).toBe(flagMetadata);
+        expect(Object.isFrozen(response.flagMetadata)).toBeTruthy();
+      });
+  
+      it('should return empty `flag metadata` because it was not set by the provider', () => {
+        // The mock provider doesn't contain flag metadata
+        OpenFeature.setProvider(MOCK_PROVIDER);
+        const client = OpenFeature.getClient();
+        const response = client.getBooleanDetails('some-flag', false);
+        expect(response.flagMetadata).toEqual({});
+      });
     });
   });
 });
+
diff --git a/packages/client/test/events.spec.ts b/packages/client/test/events.spec.ts
index 5715b30a..e445cae0 100644
--- a/packages/client/test/events.spec.ts
+++ b/packages/client/test/events.spec.ts
@@ -79,7 +79,8 @@ describe('Events', () => {
   jest.setTimeout(TIMEOUT);
   let clientId = uuid();
 
-  afterEach(() => {
+  afterEach(async () => {
+    await OpenFeature.clearProviders();
     jest.clearAllMocks();
     clientId = uuid();
     // hacky, but it's helpful to clear the handlers between tests
diff --git a/packages/client/test/hooks.spec.ts b/packages/client/test/hooks.spec.ts
index e525a024..7f94f85c 100644
--- a/packages/client/test/hooks.spec.ts
+++ b/packages/client/test/hooks.spec.ts
@@ -45,15 +45,13 @@ describe('Hooks', () => {
   let client: Client;
   const FLAG_KEY = 'my-flag';
 
-  afterEach(() => {
+  afterEach(async () => {
+    await OpenFeature.clearProviders();
     jest.clearAllMocks();
   });
 
-  beforeAll(() => {
+  beforeEach(async () => {
     OpenFeature.setProvider(MOCK_PROVIDER);
-  });
-
-  beforeEach(() => {
     client = OpenFeature.getClient();
   });
 
@@ -226,7 +224,7 @@ describe('Hooks', () => {
   });
 
   describe('"error" stage', () => {
-    beforeAll(() => {
+    beforeEach(() => {
       OpenFeature.setProvider(MOCK_ERROR_PROVIDER);
     });
 
diff --git a/packages/client/test/open-feature.spec.ts b/packages/client/test/open-feature.spec.ts
index 1dbe4420..0cced369 100644
--- a/packages/client/test/open-feature.spec.ts
+++ b/packages/client/test/open-feature.spec.ts
@@ -18,7 +18,8 @@ const mockProvider = (config?: { initialStatus?: ProviderStatus; runsOn?: Paradi
 };
 
 describe('OpenFeature', () => {
-  afterEach(() => {
+  afterEach(async () => {
+    await OpenFeature.clearProviders();
     jest.clearAllMocks();
   });
 
diff --git a/packages/server/test/client.spec.ts b/packages/server/test/client.spec.ts
index be0b0ee6..19c0829b 100644
--- a/packages/server/test/client.spec.ts
+++ b/packages/server/test/client.spec.ts
@@ -87,7 +87,8 @@ describe('OpenFeatureClient', () => {
     OpenFeature.setProvider(MOCK_PROVIDER);
   });
 
-  afterEach(() => {
+  afterEach(async () => {
+    await OpenFeature.clearProviders();
     jest.clearAllMocks();
   });
 
@@ -366,7 +367,7 @@ describe('OpenFeatureClient', () => {
     let details: EvaluationDetails<number>;
 
     describe('Normal execution', () => {
-      beforeAll(async () => {
+      beforeEach(async () => {
         const client = OpenFeature.getClient();
         details = await client.getNumberDetails(flagKey, defaultValue);
 
diff --git a/packages/server/test/events.spec.ts b/packages/server/test/events.spec.ts
index 37e0ba3b..55f076d0 100644
--- a/packages/server/test/events.spec.ts
+++ b/packages/server/test/events.spec.ts
@@ -82,7 +82,8 @@ describe('Events', () => {
   jest.setTimeout(TIMEOUT);
   let clientId = uuid();
 
-  afterEach(() => {
+  afterEach(async () => {
+    await OpenFeature.clearProviders();
     jest.clearAllMocks();
     clientId = uuid();
     // hacky, but it's helpful to clear the handlers between tests
diff --git a/packages/server/test/hooks.spec.ts b/packages/server/test/hooks.spec.ts
index cef0e9f3..849db312 100644
--- a/packages/server/test/hooks.spec.ts
+++ b/packages/server/test/hooks.spec.ts
@@ -41,15 +41,13 @@ describe('Hooks', () => {
   let client: Client;
   const FLAG_KEY = 'my-flag';
 
-  afterEach(() => {
+  afterEach(async () => {
+    await OpenFeature.clearProviders();
     jest.clearAllMocks();
   });
 
-  beforeAll(() => {
-    OpenFeature.setProvider(MOCK_PROVIDER);
-  });
-
   beforeEach(() => {
+    OpenFeature.setProvider(MOCK_PROVIDER);
     client = OpenFeature.getClient();
   });
 
@@ -280,7 +278,7 @@ describe('Hooks', () => {
   });
 
   describe('"error" stage', () => {
-    beforeAll(() => {
+    beforeEach(() => {
       OpenFeature.setProvider(MOCK_ERROR_PROVIDER);
     });
 
diff --git a/packages/server/test/logger.spec.ts b/packages/server/test/logger.spec.ts
index bcb9844a..08a539a5 100644
--- a/packages/server/test/logger.spec.ts
+++ b/packages/server/test/logger.spec.ts
@@ -45,11 +45,12 @@ const MOCK_PROVIDER: Provider = {
 };
 
 describe('Logger', () => {
-  beforeAll(() => {
+  beforeEach(() => {
     OpenFeature.setProvider(MOCK_PROVIDER);
   });
 
-  afterEach(() => {
+  afterEach(async () => {
+    await OpenFeature.clearProviders();
     jest.clearAllMocks();
     // Resetting the default logger on the singleton
     OpenFeature['_logger'] = new DefaultLogger();
diff --git a/packages/server/test/open-feature.spec.ts b/packages/server/test/open-feature.spec.ts
index 83097857..a8422962 100644
--- a/packages/server/test/open-feature.spec.ts
+++ b/packages/server/test/open-feature.spec.ts
@@ -18,7 +18,8 @@ const mockProvider = (config?: { initialStatus?: ProviderStatus; runsOn?: Paradi
 };
 
 describe('OpenFeature', () => {
-  afterEach(() => {
+  afterEach(async () => {
+    await OpenFeature.clearProviders();
     jest.clearAllMocks();
   });