Skip to content

Commit

Permalink
Use mockReset where possible in langchain tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswilty committed Feb 5, 2024
1 parent 1e62b9a commit 4cf06bd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions backend/test/integration/langchain.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
afterEach,
beforeAll,
beforeEach,
describe,
test,
Expand Down Expand Up @@ -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 () => {
Expand Down

0 comments on commit 4cf06bd

Please sign in to comment.