diff --git a/packages/oauth-provider/src/oauth.test.ts b/packages/oauth-provider/src/oauth.test.ts index aa1569a175..7cb0ec23f6 100644 --- a/packages/oauth-provider/src/oauth.test.ts +++ b/packages/oauth-provider/src/oauth.test.ts @@ -1367,18 +1367,10 @@ describe("oauth - prompt", async () => { }); }); -describe("oauth - config", async () => { - const tempServer = await listen( - toNodeHandler(async () => new Response("temp")), - { - port: 0, - }, - ); - const port = tempServer.address?.port ?? 3002; - await tempServer.close(); - - const authServerBaseUrl = `http://localhost:${port}`; - const authServerUrl = `${authServerBaseUrl}/api/auth`; +describe("oauth - config", () => { + let port = 3002; + let authServerBaseUrl = `http://localhost:${port}`; + let authServerUrl = `${authServerBaseUrl}/api/auth`; const rpBaseUrl = "http://localhost:5000"; const providerId = "test"; const redirectUri = `${rpBaseUrl}/api/auth/oauth2/callback/${providerId}`; @@ -1386,6 +1378,19 @@ describe("oauth - config", async () => { let server: Listener; let oauthClient: OAuthClient | null; + beforeAll(async () => { + const tempServer = await listen( + toNodeHandler(async () => new Response("temp")), + { + port: 0, + }, + ); + port = tempServer.address?.port ?? 3002; + authServerBaseUrl = `http://localhost:${port}`; + authServerUrl = `${authServerBaseUrl}/api/auth`; + await tempServer.close(); + }); + afterEach(async () => { if (server) { await server.close();