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 {