1
0
Fork 0
mirror of synced 2024-10-04 03:54:37 +13:00
This commit is contained in:
Adria Navarro 2023-08-01 13:36:38 +02:00
parent 672666d96b
commit 559f52d904

View file

@ -22,6 +22,10 @@ jest.mock(
}))
)
const mockedOpenAIApi = openai.OpenAIApi as jest.MockedClass<
typeof openai.OpenAIApi
>
const OPENAI_PROMPT = "What is the meaning of life?"
describe("test the openai action", () => {
@ -68,11 +72,16 @@ describe("test the openai action", () => {
})
it("should present the correct error message when an error is thrown from the createChatCompletion call", async () => {
;(openai.OpenAIApi as any).mockImplementation(() => ({
createChatCompletion: jest.fn(() => {
throw new Error("An error occurred while calling createChatCompletion")
}),
}))
mockedOpenAIApi.mockImplementation(
() =>
({
createChatCompletion: jest.fn(() => {
throw new Error(
"An error occurred while calling createChatCompletion"
)
}),
} as any)
)
const res = await setup.runStep("OPENAI", {
prompt: OPENAI_PROMPT,