Skip to content

Commit 7f13da9

Browse files
Sarath1018claude
andauthored
test(notifications): make ApiClient mock constructable for vitest 4 (#570)
The Notifications service test landed after the vitest-4 mock migration, so it still mocked ApiClient with an arrow function: `vi.mocked(ApiClient).mockImplementation(() => mockApiClient ...)`. Vitest 4 constructs mock implementations via the function's [[Construct]] slot, which arrow functions lack, so `new ApiClient(...)` in the service constructor threw `() => ... is not a constructor` and the suite failed to run. Converted to a constructable regular function, matching every other service test. Full unit suite (1992 tests) passes on vitest 4.1.9. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7381d26 commit 7f13da9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tests/unit/services/notification/notifications.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('NotificationService Unit Tests', () => {
3434
beforeEach(() => {
3535
const { instance } = createServiceTestDependencies();
3636
mockApiClient = createMockApiClient();
37-
vi.mocked(ApiClient).mockImplementation(() => mockApiClient as unknown as ApiClient);
37+
vi.mocked(ApiClient).mockImplementation(function () { return mockApiClient as unknown as ApiClient; });
3838
vi.mocked(PaginationHelpers.getAll).mockReset();
3939

4040
notificationService = new NotificationService(instance);

0 commit comments

Comments
 (0)