From 4cf06bdf6b3b6378c01b862dc62f526bba8a9a15 Mon Sep 17 00:00:00 2001 From: Chris Wilton-Magras Date: Mon, 5 Feb 2024 10:40:51 +0000 Subject: [PATCH] Use mockReset where possible in langchain tests --- backend/test/integration/langchain.test.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/backend/test/integration/langchain.test.ts b/backend/test/integration/langchain.test.ts index 83f12327b..7c87589b9 100644 --- a/backend/test/integration/langchain.test.ts +++ b/backend/test/integration/langchain.test.ts @@ -1,5 +1,6 @@ import { afterEach, + beforeAll, beforeEach, describe, test, @@ -117,22 +118,24 @@ jest.mock('@src/openai', () => { }); describe('langchain integration tests ', () => { + beforeAll(() => { + mockFromLLM.mockImplementation(() => mockRetrievalQAChain); + mockLoader.mockResolvedValue([]); + }); + beforeEach(() => { // reset environment variables process.env = { OPENAI_API_KEY: 'sk-12345', }; - - mockFromLLM.mockImplementation(() => mockRetrievalQAChain); - mockLoader.mockResolvedValue([]); }); afterEach(() => { mockPromptEvalChain.call.mockReset(); mockRetrievalQAChain.call.mockReset(); - mockFromLLM.mockReset(); - mockFromTemplate.mockReset(); - mockLoader.mockReset(); + mockFromLLM.mockClear(); + mockFromTemplate.mockClear(); + mockLoader.mockClear(); }); test('GIVEN application WHEN application starts THEN document vectors are loaded for all levels', async () => {