From 2539b7ebc261899c3a6c12f2c6663ae59450be25 Mon Sep 17 00:00:00 2001 From: Daniel Reichhart Date: Sun, 15 Mar 2026 22:17:34 +0700 Subject: [PATCH] fix: return Promise from setOutputDeviceAsync() --- __tests__/vapi.test.ts | 11 +++++++++++ vapi.ts | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/__tests__/vapi.test.ts b/__tests__/vapi.test.ts index 63822586a..9c47d7424 100644 --- a/__tests__/vapi.test.ts +++ b/__tests__/vapi.test.ts @@ -53,4 +53,15 @@ describe("Vapi", () => { expect(res).toBe(false); }); }); + + describe("setOutputDeviceAsync", () => { + it("should return the Promise from setOutputDeviceAsync", async () => { + const mockError = new Error("setSinkId failed"); + mockCall.setOutputDeviceAsync = jest.fn().mockRejectedValue(mockError); + + await expect( + vapi.setOutputDeviceAsync({ outputDeviceId: "test-device" }) + ).rejects.toThrow("setSinkId failed"); + }); + }); }); diff --git a/vapi.ts b/vapi.ts index e659313ff..281ac0e45 100644 --- a/vapi.ts +++ b/vapi.ts @@ -1020,7 +1020,7 @@ export default class Vapi extends VapiEventEmitter { public setOutputDeviceAsync( options: Parameters[0], ) { - this.call?.setOutputDeviceAsync(options); + return this.call?.setOutputDeviceAsync(options); } public getDailyCallObject(): DailyCall | null {