Skip to content

Commit 65e652b

Browse files
committed
Fix mockResolvedValue not working with mocked objects
1 parent fd2b91d commit 65e652b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

extensions/ql-vscode/test/vscode-tests/utils/mocking.helpers.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ export function mockedObject<T extends object>(
3030
if (dynamicProperties && prop in dynamicProperties) {
3131
return (dynamicProperties as any)[prop]();
3232
}
33+
34+
// The `then` method is accessed by `Promise.resolve` to check if the object is a thenable.
35+
// We don't want to throw an error when this happens.
36+
if (prop === "then") {
37+
return undefined;
38+
}
39+
3340
throw new Error(`Method ${String(prop)} not mocked`);
3441
},
3542
});

0 commit comments

Comments
 (0)