diff --git a/packages/test-kit/src/with-feature.ts b/packages/test-kit/src/with-feature.ts index 31ebcd653..6e2ad6c90 100644 --- a/packages/test-kit/src/with-feature.ts +++ b/packages/test-kit/src/with-feature.ts @@ -335,6 +335,12 @@ export function withFeature(withFeatureOptions: IWithFeatureOptions = {}) { throw new Error('Browser is not open!'); } dedicatedBrowserContext = await browser.newContext(browserContextOptions); + + dispose(() => dedicatedBrowserContext?.close(), { + group: WITH_FEATURE_DISPOSABLES, + name: `close browser context for feature "${featureName}"`, + timeout: 5000, + }); await enableTestBrowserContext({ browserContext: dedicatedBrowserContext, @@ -346,11 +352,6 @@ export function withFeature(withFeatureOptions: IWithFeatureOptions = {}) { capturedErrors, consoleLogAllowedErrors, }); - dispose(() => dedicatedBrowserContext?.close(), { - group: WITH_FEATURE_DISPOSABLES, - name: `close browser context for feature "${featureName}"`, - timeout: 5000, - }); } if (!executableApp) {