Skip to content

Commit 0c70980

Browse files
Sarath1018claude
andauthored
test(data-fabric): make ApiClient mocks constructable for vitest 4 (#571)
The DataFabric directory and roles service tests landed after the vitest-4 mock migration, so they still mocked ApiClient with an arrow function: `vi.mocked(ApiClient).mockImplementation(() => mockApiClient as unknown as ApiClient)`. 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 both suites failed to run. Converted both to constructable regular functions, matching every other service test. Full unit suite (2021 tests) passes on vitest 4.1.9. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7f13da9 commit 0c70980

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

tests/unit/services/data-fabric/directory.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('DataFabricDirectoryService Unit Tests', () => {
2222
beforeEach(() => {
2323
const { instance } = createServiceTestDependencies();
2424
mockApiClient = createMockApiClient();
25-
vi.mocked(ApiClient).mockImplementation(() => mockApiClient as unknown as ApiClient);
25+
vi.mocked(ApiClient).mockImplementation(function () { return mockApiClient as unknown as ApiClient; });
2626
directoryService = new DataFabricDirectoryService(instance);
2727
});
2828

tests/unit/services/data-fabric/roles.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('DataFabricRoleService Unit Tests', () => {
1818
beforeEach(() => {
1919
const { instance } = createServiceTestDependencies();
2020
mockApiClient = createMockApiClient();
21-
vi.mocked(ApiClient).mockImplementation(() => mockApiClient as unknown as ApiClient);
21+
vi.mocked(ApiClient).mockImplementation(function () { return mockApiClient as unknown as ApiClient; });
2222
rolesService = new DataFabricRoleService(instance);
2323
});
2424

0 commit comments

Comments
 (0)