[GH-ISSUE #5776] Fix openaiCompatible.test.js mock setup for getVectorDbClass #5569

Closed
opened 2026-06-07 16:36:41 -04:00 by yindo · 1 comment
Owner

Originally created by @Delqhi on GitHub (Jun 7, 2026).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/5776

Problem

4 tests in server/tests/utils/chats/openaiCompatible.test.js fail because getVectorDbClass.mockReturnValue is not a function.

Root Cause

jest.mock('../../../utils/helpers') creates an auto-mock for the entire module, but getVectorDbClass, getLLMProvider, and resolveProviderConnector are not properly set up as jest mock functions in the test's beforeEach.

Fix

Either:

  1. Use helpers.getVectorDbClass.mockReturnValue(...) after importing the module as namespace, OR
  2. Use jest.mock('../../../utils/helpers', () => ({ getVectorDbClass: jest.fn(), getLLMProvider: jest.fn(), resolveProviderConnector: jest.fn() })) to explicitly create jest mock functions.

Failing Tests

  • chatSync should handle OpenAI vision multimodal messages
  • chatSync should handle regular text messages in OpenAI format
  • streamChat should handle OpenAI vision multimodal messages in streaming mode
  • streamChat should handle regular text messages in streaming mode

Related to #34 (Jest config fix).

Originally created by @Delqhi on GitHub (Jun 7, 2026). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/5776 ## Problem 4 tests in server/__tests__/utils/chats/openaiCompatible.test.js fail because getVectorDbClass.mockReturnValue is not a function. ## Root Cause jest.mock('../../../utils/helpers') creates an auto-mock for the entire module, but getVectorDbClass, getLLMProvider, and resolveProviderConnector are not properly set up as jest mock functions in the test's beforeEach. ## Fix Either: 1. Use helpers.getVectorDbClass.mockReturnValue(...) after importing the module as namespace, OR 2. Use jest.mock('../../../utils/helpers', () => ({ getVectorDbClass: jest.fn(), getLLMProvider: jest.fn(), resolveProviderConnector: jest.fn() })) to explicitly create jest mock functions. ## Failing Tests - chatSync should handle OpenAI vision multimodal messages - chatSync should handle regular text messages in OpenAI format - streamChat should handle OpenAI vision multimodal messages in streaming mode - streamChat should handle regular text messages in streaming mode Related to #34 (Jest config fix).
yindo closed this issue 2026-06-07 16:36:41 -04:00
Author
Owner

@Delqhi commented on GitHub (Jun 7, 2026):

Wrong repo, created in error

<!-- gh-comment-id:4642693276 --> @Delqhi commented on GitHub (Jun 7, 2026): Wrong repo, created in error
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#5569