diff options
| author | Tommaso Sciortino <[email protected]> | 2025-06-18 08:34:22 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-18 08:34:22 -0700 |
| commit | cd03d96b349b7bdfbce13635cc899bca86d417d1 (patch) | |
| tree | ddc33d6580c3dd0993f209dd843a6257fee85583 /packages/core/src | |
| parent | 9b34762d97101306406a995eb63d08b45089fdf3 (diff) | |
Fix flakey test (#1178)
Diffstat (limited to 'packages/core/src')
| -rw-r--r-- | packages/core/src/code_assist/oauth2.test.ts | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/packages/core/src/code_assist/oauth2.test.ts b/packages/core/src/code_assist/oauth2.test.ts index cd06a11a..47bd45b3 100644 --- a/packages/core/src/code_assist/oauth2.test.ts +++ b/packages/core/src/code_assist/oauth2.test.ts @@ -67,11 +67,18 @@ describe('oauth2', () => { typeof http.IncomingMessage, typeof http.ServerResponse >; + + let serverListeningCallback: (value: unknown) => void; + const serverListeningPromise = new Promise( + (resolve) => (serverListeningCallback = resolve), + ); + const mockHttpServer = { listen: vi.fn((port: number, callback?: () => void) => { if (callback) { callback(); } + serverListeningCallback(undefined); }), close: vi.fn((callback?: () => void) => { if (callback) { @@ -91,8 +98,8 @@ describe('oauth2', () => { const clientPromise = getOauthClient(); - // Wait for the server to be created - await new Promise((resolve) => setTimeout(resolve, 0)); + // wait for server to start listening. + await serverListeningPromise; const mockReq = { url: `/oauth2callback?code=${mockCode}&state=${mockState}`, |
